From 666d4e7b02b97402d2e977864528b743b9e1c184 Mon Sep 17 00:00:00 2001 From: Martin Miller Date: Sun, 19 Mar 2017 14:26:28 -0500 Subject: Add motion model. The motion model is broken into two parts, the creation of the L matrix and the state update. This means that ydot can be computed from the state object for many features at once, saving computation time. --- src/feature.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/feature.cpp') diff --git a/src/feature.cpp b/src/feature.cpp index 45e24e7..e44d597 100644 --- a/src/feature.cpp +++ b/src/feature.cpp @@ -18,6 +18,52 @@ */ #include "feature.h" +/* + *-------------------------------------------------------------------------------------- + * Class: Feature + * Method: Feature :: L + * Description: Returns the motion model matrix L. These can be stacked to + * update the states of many features simultaneously. + *-------------------------------------------------------------------------------------- + */ +Matrix +Feature::L ( ) +{ + double y0,y1,y2; + Matrix L; + y0 = X[0]; + y1 = X[1]; + y2 = X[2]; + + L << -y2, 0, y2*y0, y0*y1, -(1+y0*y0), y1, + 0, -y2, y1*y2, 1+y1*y1, -y0*y1, -y0, + 0, 0, y2*y2, y2*y1, -y2*y0, 0; + + return L; +} /* ----- end of method Feature::L ----- */ + +/* + *-------------------------------------------------------------------------------------- + * Class: Feature + * Method: Feature :: motionModel + * Description: Updates the feature state according to the motion model. + *-------------------------------------------------------------------------------------- + */ +void +Feature::motionModel ( const Vector3d &ang, const Vector3d &vel, const double dt) +{ + Matrix L; + L = L(); + + Matrix V; + V << vel[1], vel[2], vel[0], ang[1], ang[2], ang[0]; + + Matrix ydot; + ydot = L*V; + X += ydot*dt; + return ; +} /* ----- end of method Feature::motionModel ----- */ + Matrix Feature::h ( const Vector3d &x, const Quaterniond &q ) { -- cgit v1.1