gtsam 4.1.1
gtsam
VelocityConstraint3.h
Go to the documentation of this file.
1
7#pragma once
8
10
11namespace gtsam {
12
13class VelocityConstraint3 : public NoiseModelFactor3<double, double, double> {
14public:
15
16protected:
18
21
22 double dt_;
23
24public:
25
26 typedef boost::shared_ptr<VelocityConstraint3 > shared_ptr;
27
29 VelocityConstraint3(Key key1, Key key2, Key velKey, double dt, double mu = 1000.0)
30 : Base(noiseModel::Constrained::All(1, std::abs(mu)), key1, key2, velKey), dt_(dt) {}
31 ~VelocityConstraint3() override {}
32
34 gtsam::NonlinearFactor::shared_ptr clone() const override {
35 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
36 gtsam::NonlinearFactor::shared_ptr(new VelocityConstraint3(*this))); }
37
39 Vector evaluateError(const double& x1, const double& x2, const double& v,
40 boost::optional<Matrix&> H1 = boost::none,
41 boost::optional<Matrix&> H2 = boost::none,
42 boost::optional<Matrix&> H3 = boost::none) const override {
43 const size_t p = 1;
44 if (H1) *H1 = Matrix::Identity(p,p);
45 if (H2) *H2 = -Matrix::Identity(p,p);
46 if (H3) *H3 = Matrix::Identity(p,p)*dt_;
47 return (Vector(1) << x1+v*dt_-x2).finished();
48 }
49
50private:
51
54 template<class ARCHIVE>
55 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
56 ar & boost::serialization::make_nvp("NoiseModelFactor3",
57 boost::serialization::base_object<Base>(*this));
58 }
59}; // \VelocityConstraint3
60
61}
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
This is the base class for all factor types.
Definition: Factor.h:56
const SharedNoiseModel & noiseModel() const
access to the noise model
Definition: NonlinearFactor.h:211
A convenient base class for creating your own NoiseModelFactor with 3 variables.
Definition: NonlinearFactor.h:444
Key key1() const
methods to retrieve keys
Definition: NonlinearFactor.h:478
Definition: VelocityConstraint3.h:13
VelocityConstraint3()
default constructor to allow for serialization
Definition: VelocityConstraint3.h:20
VelocityConstraint3(Key key1, Key key2, Key velKey, double dt, double mu=1000.0)
TODO: comment.
Definition: VelocityConstraint3.h:29
Vector evaluateError(const double &x1, const double &x2, const double &v, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const override
x1 + v*dt - x2 = 0, with optional derivatives
Definition: VelocityConstraint3.h:39
friend class boost::serialization::access
Serialization function.
Definition: VelocityConstraint3.h:53
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: VelocityConstraint3.h:34