35 typedef gtsam::NoiseModelFactor2<PoseRTV,PoseRTV> Base;
38 using Base::evaluateError;
51 double dt,
double mu = 1000)
52 : Base(noiseModel::Constrained::All(3, mu), key1, key2), dt_(dt), integration_mode_(mode) {}
59 : Base(noiseModel::Constrained::All(3, mu), key1, key2),
60 dt_(dt), integration_mode_(dynamics::TRAPEZOIDAL) {}
67 : Base(model, key1, key2), dt_(dt), integration_mode_(mode) {}
74 : Base(model, key1, key2), dt_(dt), integration_mode_(dynamics::TRAPEZOIDAL) {}
79 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
88 if (H1) *H1 = gtsam::numericalDerivative21<gtsam::Vector,PoseRTV,PoseRTV>(
89 std::bind(VelocityConstraint::evaluateError_, std::placeholders::_1,
90 std::placeholders::_2, dt_, integration_mode_), x1, x2, 1e-5);
91 if (H2) *H2 = gtsam::numericalDerivative22<gtsam::Vector,PoseRTV,PoseRTV>(
92 std::bind(VelocityConstraint::evaluateError_, std::placeholders::_1,
93 std::placeholders::_2, dt_, integration_mode_), x1, x2, 1e-5);
94 return evaluateError_(x1, x2, dt_, integration_mode_);
98 std::string a =
"VelocityConstraint: " + s;
100 switch(integration_mode_) {
101 case dynamics::TRAPEZOIDAL: std::cout <<
"Integration: Trapezoidal\n";
break;
102 case dynamics::EULER_START: std::cout <<
"Integration: Euler (start)\n";
break;
103 case dynamics::EULER_END: std::cout <<
"Integration: Euler (end)\n";
break;
104 default: std::cout <<
"Integration: Unknown\n" << std::endl;
break;
106 std::cout <<
"dt: " << dt_ << std::endl;
110 static gtsam::Vector evaluateError_(
const PoseRTV& x1,
const PoseRTV& x2,
113 const Velocity3& v1 = x1.v(), v2 = x2.v();
114 const Point3& p1 = x1.t(), p2 = x2.t();
117 case dynamics::TRAPEZOIDAL: hx = p1 +
Point3((v1 + v2) * dt *0.5);
break;
118 case dynamics::EULER_START: hx = p1 +
Point3(v1 * dt);
break;
119 case dynamics::EULER_END : hx = p1 +
Point3(v2 * dt);
break;
120 default: assert(
false);
break;
Definition: NonlinearFactor.h:431
VelocityConstraint(Key key1, Key key2, double dt, double mu=1000)
Definition: VelocityConstraint.h:58
IntegrationMode
Definition: VelocityConstraint.h:18
VelocityConstraint(Key key1, Key key2, double dt, const gtsam::SharedNoiseModel &model)
Definition: VelocityConstraint.h:73
Vector3 Velocity3
Velocity is currently typedef'd to Vector3.
Definition: NavState.h:28
Definition: NonlinearFactor.h:68
Some functions to compute numerical derivatives.
gtsam::Vector evaluateError(const PoseRTV &x1, const PoseRTV &x2, OptionalMatrixType H1, OptionalMatrixType H2) const override
Definition: VelocityConstraint.h:86
VelocityConstraint(Key key1, Key key2, const dynamics::IntegrationMode &mode, double dt, const gtsam::SharedNoiseModel &model)
Definition: VelocityConstraint.h:65
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Pose3 with translational velocity.
Definition: chartTesting.h:28
Non-linear factor base classes.
Definition: VelocityConstraint.h:33
VelocityConstraint(Key key1, Key key2, const dynamics::IntegrationMode &mode, double dt, double mu=1000)
Definition: VelocityConstraint.h:50
Vector3 Point3
Definition: Point3.h:38
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
void print(const std::string &s="", const gtsam::KeyFormatter &formatter=gtsam::DefaultKeyFormatter) const override
Definition: VelocityConstraint.h:97
dynamics::IntegrationMode integration_mode_
time difference between frames in seconds
Definition: VelocityConstraint.h:43
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: VelocityConstraint.h:79