49 boost::optional<Matrix&> H1 = boost::none,
50 boost::optional<Matrix&> H2 = boost::none,
51 boost::optional<Matrix&> H3 = boost::none)
const override {
53 if (H1) *H1 = -Matrix::Identity(p,p);
54 if (H2) *H2 = Matrix::Identity(p,p);
55 if (H3) *H3 = Matrix::Identity(p,p)*
h_;
56 return (
Vector(1) << qk+v*h_-qk1).finished();
88 : Base(
noiseModel::Constrained::All(1,
std::
abs(
mu)), vk1, vk, qkey), h_(h), g_(
g), r_(r) {}
97 boost::optional<Matrix&> H1 = boost::none,
98 boost::optional<Matrix&> H2 = boost::none,
99 boost::optional<Matrix&> H3 = boost::none)
const override {
101 if (H1) *H1 = -Matrix::Identity(p,p);
102 if (H2) *H2 = Matrix::Identity(p,p);
103 if (H3) *H3 = -Matrix::Identity(p,p)*h_*g_/r_*
cos(q);
104 return (
Vector(1) << vk - h_ * g_ / r_ *
sin(q) - vk1).finished();
137 double h,
double m = 1.0,
double r = 1.0,
double g = 9.81,
double alpha = 0.0,
double mu = 1000.0)
139 h_(h), m_(
m), r_(r), g_(
g), alpha_(
alpha) {}
148 boost::optional<Matrix&> H1 = boost::none,
149 boost::optional<Matrix&> H2 = boost::none,
150 boost::optional<Matrix&> H3 = boost::none)
const override {
153 double qmid = (1-alpha_)*qk + alpha_*qk1;
154 double mr2_h = 1/h_*m_*r_*r_;
155 double mgrh = m_*g_*r_*
h_;
157 if (H1) *H1 = -Matrix::Identity(p,p);
158 if (H2) *H2 = Matrix::Identity(p,p)*(-mr2_h + mgrh*(1-alpha_)*(1-alpha_)*
cos(qmid));
159 if (H3) *H3 = Matrix::Identity(p,p)*( mr2_h + mgrh*(1-alpha_)*(alpha_)*
cos(qmid));
161 return (
Vector(1) << mr2_h * (qk1 - qk) + mgrh * (1 - alpha_) *
sin(qmid) - pk).finished();
193 double h,
double m = 1.0,
double r = 1.0,
double g = 9.81,
double alpha = 0.0,
double mu = 1000.0)
195 h_(h), m_(
m), r_(r), g_(
g), alpha_(
alpha) {}
204 boost::optional<Matrix&> H1 = boost::none,
205 boost::optional<Matrix&> H2 = boost::none,
206 boost::optional<Matrix&> H3 = boost::none)
const override {
209 double qmid = (1-alpha_)*qk + alpha_*qk1;
210 double mr2_h = 1/h_*m_*r_*r_;
211 double mgrh = m_*g_*r_*
h_;
213 if (H1) *H1 = -Matrix::Identity(p,p);
214 if (H2) *H2 = Matrix::Identity(p,p)*(-mr2_h - mgrh*(1-alpha_)*alpha_*
cos(qmid));
215 if (H3) *H3 = Matrix::Identity(p,p)*( mr2_h - mgrh*alpha_*alpha_*
cos(qmid));
217 return (
Vector(1) << mr2_h * (qk1 - qk) - mgrh * alpha_ *
sin(qmid) - pk1).finished();
boost::shared_ptr< PendulumFactor1 > shared_ptr
Vector evaluateError(const double &pk, const double &qk, const double &qk1, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const override
Vector evaluateError(const double &vk1, const double &vk, const double &q, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const override
Vector evaluateError(const double &pk1, const double &qk, const double &qk1, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const override
NoiseModelFactor3< double, double, double > Base
Vector evaluateError(const double &qk1, const double &qk, const double &v, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none, boost::optional< Matrix & > H3=boost::none) const override
gtsam::NonlinearFactor::shared_ptr clone() const override
const SharedNoiseModel & noiseModel() const
access to the noise model
void g(const string &key, int i)
EIGEN_DEVICE_FUNC const CosReturnType cos() const
PendulumFactorPk1(Key pKey1, Key qKey, Key qKey1, double h, double m=1.0, double r=1.0, double g=9.81, double alpha=0.0, double mu=1000.0)
Constructor.
PendulumFactor1(Key k1, Key k, Key velKey, double h, double mu=1000.0)
Constructor. k1: q_{k+1}, k: q_k, velKey: velocity variable depending on the chosen method...
boost::shared_ptr< PendulumFactor2 > shared_ptr
PendulumFactor2(Key vk1, Key vk, Key qkey, double h, double r=1.0, double g=9.81, double mu=1000.0)
Constructor. vk1: v_{k+1}, vk: v_k, qkey: q's key depending on the chosen method, h: time step...
boost::shared_ptr< PendulumFactorPk > shared_ptr
in [0,1], define the mid-point between [q_k,q_{k+1}] for approximation. The sympletic rule above can ...
boost::shared_ptr< This > shared_ptr
boost::shared_ptr< PendulumFactorPk1 > shared_ptr
in [0,1], define the mid-point between [q_k,q_{k+1}] for approximation. The sympletic rule above can ...
EIGEN_DEVICE_FUNC const Scalar & q
gtsam::NonlinearFactor::shared_ptr clone() const override
PendulumFactorPk(Key pKey, Key qKey, Key qKey1, double h, double m=1.0, double r=1.0, double g=9.81, double alpha=0.0, double mu=1000.0)
Constructor.
Non-linear factor base classes.
EIGEN_DEVICE_FUNC const SinReturnType sin() const
gtsam::NonlinearFactor::shared_ptr clone() const override
NoiseModelFactor3< double, double, double > Base
std::uint64_t Key
Integer nonlinear key type.
NoiseModelFactor3< double, double, double > Base
NoiseModelFactor3< double, double, double > Base
gtsam::NonlinearFactor::shared_ptr clone() const override