20#include <gtsam/config.h>
22#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V43
53class VelocityConstraint
54 :
public gtsam::NoiseModelFactorT<gtsam::Vector3, PoseRTV, PoseRTV> {
56 typedef gtsam::NoiseModelFactorT<gtsam::Vector3, PoseRTV, PoseRTV> Base;
59 using Base::evaluateError;
64 dynamics::IntegrationMode integration_mode_;
71 VelocityConstraint(Key key1, Key key2,
const dynamics::IntegrationMode& mode,
72 double dt,
double mu = 1000)
73 : Base(noiseModel::Constrained::All(3, mu), key1, key2), dt_(dt), integration_mode_(mode) {}
79 VelocityConstraint(Key key1, Key key2,
double dt,
double mu = 1000)
80 : Base(noiseModel::Constrained::All(3, mu), key1, key2),
81 dt_(dt), integration_mode_(
dynamics::TRAPEZOIDAL) {}
86 VelocityConstraint(Key key1, Key key2,
const dynamics::IntegrationMode& mode,
88 : Base(model, key1, key2), dt_(dt), integration_mode_(mode) {}
95 : Base(model, key1, key2), dt_(dt), integration_mode_(
dynamics::TRAPEZOIDAL) {}
97 ~VelocityConstraint()
override {}
100 gtsam::NonlinearFactor::shared_ptr clone()
const override {
101 return std::static_pointer_cast<gtsam::NonlinearFactor>(
102 gtsam::NonlinearFactor::shared_ptr(
new VelocityConstraint(*
this))); }
107 gtsam::Vector3 evaluateError(
const PoseRTV& x1,
const PoseRTV& x2,
108 OptionalMatrixType H1,
109 OptionalMatrixType H2)
const override {
111 std::bind(VelocityConstraint::evaluateError_, std::placeholders::_1,
112 std::placeholders::_2, dt_, integration_mode_), x1, x2, 1e-5);
114 std::bind(VelocityConstraint::evaluateError_, std::placeholders::_1,
115 std::placeholders::_2, dt_, integration_mode_), x1, x2, 1e-5);
116 return evaluateError_(x1, x2, dt_, integration_mode_);
120 std::string a =
"VelocityConstraint: " + s;
121 Base::print(a, formatter);
122 switch(integration_mode_) {
123 case dynamics::TRAPEZOIDAL: std::cout <<
"Integration: Trapezoidal\n";
break;
124 case dynamics::EULER_START: std::cout <<
"Integration: Euler (start)\n";
break;
125 case dynamics::EULER_END: std::cout <<
"Integration: Euler (end)\n";
break;
126 default: std::cout <<
"Integration: Unknown\n" << std::endl;
break;
128 std::cout <<
"dt: " << dt_ << std::endl;
132 static gtsam::Vector evaluateError_(
const PoseRTV& x1,
const PoseRTV& x2,
133 double dt,
const dynamics::IntegrationMode& mode) {
135 const Velocity3& v1 = x1.v(), v2 = x2.v();
136 const Point3& p1 = x1.t(), p2 = x2.t();
139 case dynamics::TRAPEZOIDAL: hx = p1 +
Point3((v1 + v2) * dt *0.5);
break;
140 case dynamics::EULER_START: hx = p1 +
Point3(v1 * dt);
break;
141 case dynamics::EULER_END : hx = p1 +
Point3(v2 * dt);
break;
142 default: assert(
false);
break;
Numerical derivative helpers for manifold-valued functions.
Base class for noise model factors with N variables.
Non-linear factor base classes.
Pose3 with translational velocity.
State< N >::TangentVector dynamics(const Vector3 &omega, const State< N > &xi)
Continuous-time dynamics on the manifold M = SO(3) x R^3 x SO(3)^N, as in Eq.
Definition ABC.h:251
internal::MatrixMN< traits< internal::OutputType< Y, F, X1, X2 > >::dimension, N >::type numericalDerivative21(F &&h, const X1 &x1, const X2 &x2, double delta=1e-5)
Compute numerical derivative in argument 1 of binary function.
Definition numericalDerivative.h:236
internal::MatrixMN< traits< internal::OutputType< Y, F, X1, X2 > >::dimension, N >::type numericalDerivative22(F &&h, const X1 &x1, const X2 &x2, double delta=1e-5)
Compute numerical derivative in argument 2 of binary function.
Definition numericalDerivative.h:265
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition Point3.h:38
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
Vector3 Velocity3
Velocity is currently typedef'd to Vector3.
Definition Gal3.h:33
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
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846