gtsam
Loading...
Searching...
No Matches
VelocityConstraint3.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
20#include <gtsam/config.h>
21
22#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V43
23
26
27namespace gtsam {
28
33class VelocityConstraint3
34 : public NoiseModelFactorT<Vector1, double, double, double> {
35public:
36
37protected:
38 typedef NoiseModelFactorT<Vector1, double, double, double> Base;
39
41 VelocityConstraint3() {}
42
43 double dt_;
44
45public:
46
47 // Provide access to the Matrix& version of evaluateError:
48 using Base::evaluateError;
49
50 typedef std::shared_ptr<VelocityConstraint3 > shared_ptr;
51
53 VelocityConstraint3(Key key1, Key key2, Key velKey, double dt, double mu = 1000.0)
54 : Base(noiseModel::Constrained::All(1, std::abs(mu)), key1, key2, velKey), dt_(dt) {}
55 ~VelocityConstraint3() override {}
56
58 gtsam::NonlinearFactor::shared_ptr clone() const override {
59 return std::static_pointer_cast<gtsam::NonlinearFactor>(
60 gtsam::NonlinearFactor::shared_ptr(new VelocityConstraint3(*this))); }
61
63 Vector1 evaluateError(const double& x1, const double& x2, const double& v,
64 OptionalMatrixType H1, OptionalMatrixType H2,
65 OptionalMatrixType H3) const override {
66 const size_t p = 1;
67 if (H1) *H1 = Matrix::Identity(p,p);
68 if (H2) *H2 = -Matrix::Identity(p,p);
69 if (H3) *H3 = Matrix::Identity(p,p)*dt_;
70 return Vector{{x1 + v * dt_ - x2}};
71 }
72
73private:
74
75#if GTSAM_ENABLE_BOOST_SERIALIZATION
77 friend class boost::serialization::access;
78 template<class ARCHIVE>
79 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
80 // NoiseModelFactor3 instead of NoiseModelFactorN for backward compatibility
81 ar & boost::serialization::make_nvp("NoiseModelFactor3",
82 boost::serialization::base_object<Base>(*this));
83 }
84#endif
85}; // \VelocityConstraint3
86
87}
88
89#endif // GTSAM_ALLOW_DEPRECATED_SINCE_V43
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
A convenient base class for creating your own NoiseModelFactor with n variables.
Definition NoiseModelFactorN.h:155