25 using namespace gtsam;
35 static const Vector9
kZeroXi = Vector9::Zero();
39 boost::function<NavState(const Rot3&, const Point3&, const Vector3&)>
create =
40 boost::bind(&NavState::Create, _1, _2, _3, boost::none, boost::none,
59 boost::function<NavState(const Pose3&, const Vector3&)>
construct =
60 boost::bind(&NavState::FromPoseVelocity, _1, _2, boost::none,
75 eH = numericalDerivative11<Rot3, NavState>(
85 eH = numericalDerivative11<Point3, NavState>(
95 eH = numericalDerivative11<Velocity3, NavState>(
105 eH = numericalDerivative11<Velocity3, NavState>(
120 xi << 0.1, 0.1, 0.1, 0.2, 0.3, 0.4, -0.1, -0.2, -0.3;
137 boost::function<NavState(const NavState&, const Vector9&)> retract =
138 boost::bind(&NavState::retract, _1, _2, boost::none, boost::none);
143 const Vector9 xi2 = -3.0*
xi;
149 boost::function<Vector9(const NavState&, const NavState&)> local =
150 boost::bind(&NavState::localCoordinates, _1, _2, boost::none,
167 static const double dt = 2.0;
168 boost::function<Vector9(const NavState&, const bool&)>
coriolis = boost::bind(
204 double dt = 2.0, dt2 = dt *
dt;
205 Vector3 n_omega(0.0, 0.0, 1.0), n_t(1.0, 0.0, 0.0), n_v(0.0, 1.0, 0.0);
206 Vector3 n_aCorr1 = -2.0 * n_omega.cross(n_v),
207 n_aCorr2 = -n_omega.cross(n_omega.cross(n_t));
208 Rot3 nRb =
Rot3(-1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0),
212 Vector3 n_dP1e = 0.5 * dt2 * n_aCorr1,
213 n_dP2e = 0.5 * dt2 * (n_aCorr1 + n_aCorr2),
214 n_dV1e = dt * n_aCorr1,
215 n_dV2e = dt * (n_aCorr1 + n_aCorr2);
218 Vector3 dRe = -dt * (bRn * n_omega),
219 b_dP1e = bRn * n_dP1e, b_dP2e = bRn * n_dP2e,
220 b_dV1e = bRn * n_dV1e, b_dV2e = bRn * n_dV2e;
224 Vector9 dXi1a = kState2.coriolis(dt, n_omega,
false),
225 dXi2a = kState2.coriolis(dt, n_omega,
true);
226 Vector3 dRa = NavState::dR(dXi1a),
227 b_dP1a = NavState::dP(dXi1a), b_dV1a = NavState::dV(dXi1a),
228 b_dP2a = NavState::dP(dXi2a), b_dV2a = NavState::dV(dXi2a);
241 xi << 0.1, 0.1, 0.1, 0.2, 0.3, 0.4, -0.1, -0.2, -0.3;
244 boost::function<Vector9(const NavState&, const Vector9&)> correctPIM =
246 false, boost::none, boost::none);
257 std::ostringstream
os;
261 expected =
"R: [\n\t1, 0, 0;\n\t0, 1, 0;\n\t0, 0, 1\n]\np: 0 0 0\nv: 0 0 0";
Provides additional testing facilities for common data structures.
static const Vector9 kZeroXi
static const Point3 kPosition(1.0, 2.0, 3.0)
Vector9 correctPIM(const Vector9 &pim, double dt, const Vector3 &n_gravity, const boost::optional< Vector3 > &omegaCoriolis, bool use2ndOrderCoriolis=false, OptionalJacobian< 9, 9 > H1=boost::none, OptionalJacobian< 9, 9 > H2=boost::none) const
static int runAllTests(TestResult &result)
Vector9 localCoordinates(const NavState &g, OptionalJacobian< 9, 9 > H1=boost::none, OptionalJacobian< 9, 9 > H2=boost::none) const
localCoordinates with optional derivatives
static const Pose3 kPose(kAttitude, kPosition)
Vector3 Velocity3
Velocity is currently typedef'd to Vector3.
Point3 unrotate(const Point3 &p, OptionalJacobian< 3, 3 > H1=boost::none, OptionalJacobian< 3, 3 > H2=boost::none) const
rotate point from world to rotated frame
Pose2_ Expmap(const Vector3_ &xi)
static const Velocity3 kVelocity(0.4, 0.5, 0.6)
Some functions to compute numerical derivatives.
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative31(boost::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative21(const boost::function< Y(const X1 &, const X2 &)> &h, const X1 &x1, const X2 &x2, double delta=1e-5)
Vector9 coriolis(double dt, const Vector3 &omega, bool secondOrder=false, OptionalJacobian< 9, 9 > H=boost::none) const
Compute tangent space contribution due to Coriolis forces.
boost::function< Vector9(const NavState &, const bool &)> coriolis
Rot3 inverse() const
inverse of a rotation
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative32(boost::function< Y(const X1 &, const X2 &, const X3 &)> h, const X1 &x1, const X2 &x2, const X3 &x3, double delta=1e-5)
TEST(NavState, Constructor)
NavState retract(const Vector9 &v, OptionalJacobian< 9, 9 > H1=boost::none, OptionalJacobian< 9, 9 > H2=boost::none) const
retract with optional derivatives
Velocity3 bodyVelocity(OptionalJacobian< 3, 9 > H=boost::none) const
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative22(boost::function< Y(const X1 &, const X2 &)> h, const X1 &x1, const X2 &x2, double delta=1e-5)
static const NavState kState1(kAttitude, kPosition, kVelocity)
static const NavState state2(x2, v2)
static const NavState kIdentity
#define EXPECT(condition)
Navigation state composing of attitude, position, and velocity.
int BLASFUNC() drot(int *, double *, int *, double *, int *, double *, double *)
static const Vector3 kGravity(0, 0, 9.81)
Velocity3 velocity(const NavState &X, OptionalJacobian< 3, 9 > H)
const Velocity3 & velocity(OptionalJacobian< 3, 9 > H=boost::none) const
static const Rot3 kAttitude
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Rot3 attitude(const NavState &X, OptionalJacobian< 3, 9 > H)
static const Vector3 kOmegaCoriolis(0.02, 0.03, 0.04)
ADT create(const Signature &signature)
ofstream os("timeSchurFactors.csv")
const Point3 & position(OptionalJacobian< 3, 9 > H=boost::none) const
Point3 position(const NavState &X, OptionalJacobian< 3, 9 > H)
Vector3 bodyVelocity(const Pose3 &w_t_b, const Vector3 &vec_w, OptionalJacobian< 3, 6 > Hpose=boost::none, OptionalJacobian< 3, 3 > Hvel=boost::none)
const Rot3 & attitude(OptionalJacobian< 3, 9 > H=boost::none) const