gtsam
Loading...
Searching...
No Matches
ConstantVelocityFactor.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
17
18#pragma once
19
23
24namespace gtsam {
25
30class ConstantVelocityFactor
31 : public NoiseModelFactorT<Vector9, NavState, NavState> {
32 double dt_;
33
34 public:
36
37 // Provide access to the Matrix& version of evaluateError:
39
40 public:
41 ConstantVelocityFactor(Key i, Key j, double dt, const SharedNoiseModel &model)
42 : Base(model, i, j), dt_(dt) {}
43 ~ConstantVelocityFactor() override {}
44
55 Vector9 evaluateError(const NavState &x1, const NavState &x2,
57 OptionalMatrixType H2) const override {
58 // only used to use update() below
59 static const Vector3 b_accel{0.0, 0.0, 0.0};
60 static const Vector3 b_omega{0.0, 0.0, 0.0};
61
62 Matrix99 predicted_H_x1;
63 NavState predicted = x1.update(b_accel, b_omega, dt_, H1 ? &predicted_H_x1 : nullptr, {}, {});
64
65 Matrix99 error_H_predicted;
66 Vector9 error = predicted.localCoordinates(x2, H1 ? &error_H_predicted : nullptr, H2);
67
68 if (H1) {
69 *H1 = error_H_predicted * predicted_H_x1;
70 }
71 return error;
72 }
73};
74
75} // namespace gtsam
Navigation state composing of attitude, position, and velocity.
Base class for noise model factors with N variables.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
Vector9 evaluateError(const NavState &x1, const NavState &x2, OptionalMatrixType H1, OptionalMatrixType H2) const override
Calculate error: (x2 - x1.update(dt))) where X1 and X1 are NavStates and dt is the time difference in...
Definition ConstantVelocityFactor.h:55
Navigation state: Pose (rotation, translation) + velocity Following Barrau20icra, this class belongs ...
Definition NavState.h:45
NavState update(const Vector3 &b_acceleration, const Vector3 &b_omega, const double dt, OptionalJacobian< 9, 9 > F={}, OptionalJacobian< 9, 3 > G1={}, OptionalJacobian< 9, 3 > G2={}) const
Integrate forward in time given angular velocity and acceleration in body frame.
Definition NavState.cpp:223
Vector9 localCoordinates(const NavState &g, OptionalJacobian< 9, 9 > H1={}, OptionalJacobian< 9, 9 > H2={}) const
Inverse of the optimization chart selected by GTSAM_NAVSTATE_EXPMAP.
Definition NavState.cpp:137
NoiseModelFactorT()
Definition NoiseModelFactorN.h:257
virtual Vector9 evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
double error(const Values &c) const override
Calculate the error of the factor.
Definition NonlinearFactor.cpp:146