55 if (H1) *H1 = -Matrix::Identity(p,p);
56 if (H2) *H2 = Matrix::Identity(p,p);
57 if (H3) *H3 = Matrix::Identity(p,p)*
h_;
58 return (
Vector(1) << qk+v*h_-qk1).finished();
93 : Base(
noiseModel::Constrained::All(1,
std::
abs(
mu)), vk1, vk, qkey), h_(h), g_(
g), r_(r) {}
105 if (H1) *H1 = -Matrix::Identity(p,p);
106 if (H2) *H2 = Matrix::Identity(p,p);
107 if (H3) *H3 = -Matrix::Identity(p,p)*h_*g_/r_*
cos(q);
108 return (
Vector(1) << vk - h_ * g_ / r_ *
sin(q) - vk1).finished();
144 double h,
double m = 1.0,
double r = 1.0,
double g = 9.81,
double alpha = 0.0,
double mu = 1000.0)
146 h_(h), m_(
m), r_(r), g_(
g), alpha_(
alpha) {}
159 double qmid = (1-alpha_)*qk + alpha_*qk1;
160 double mr2_h = 1/h_*m_*r_*r_;
161 double mgrh = m_*g_*r_*
h_;
163 if (H1) *H1 = -Matrix::Identity(p,p);
164 if (H2) *H2 = Matrix::Identity(p,p)*(-mr2_h + mgrh*(1-alpha_)*(1-alpha_)*
cos(qmid));
165 if (H3) *H3 = Matrix::Identity(p,p)*( mr2_h + mgrh*(1-alpha_)*(alpha_)*
cos(qmid));
167 return (
Vector(1) << mr2_h * (qk1 - qk) + mgrh * (1 - alpha_) *
sin(qmid) - pk).finished();
202 double h,
double m = 1.0,
double r = 1.0,
double g = 9.81,
double alpha = 0.0,
double mu = 1000.0)
204 h_(h), m_(
m), r_(r), g_(
g), alpha_(
alpha) {}
217 double qmid = (1-alpha_)*qk + alpha_*qk1;
218 double mr2_h = 1/h_*m_*r_*r_;
219 double mgrh = m_*g_*r_*
h_;
221 if (H1) *H1 = -Matrix::Identity(p,p);
222 if (H2) *H2 = Matrix::Identity(p,p)*(-mr2_h - mgrh*(1-alpha_)*alpha_*
cos(qmid));
223 if (H3) *H3 = Matrix::Identity(p,p)*( mr2_h - mgrh*alpha_*alpha_*
cos(qmid));
225 return (
Vector(1) << mr2_h * (qk1 - qk) - mgrh * alpha_ *
sin(qmid) - pk1).finished();
Jet< T, N > cos(const Jet< T, N > &f)
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Jet< T, N > sin(const Jet< T, N > &f)
gtsam::NonlinearFactor::shared_ptr clone() const override
void g(const string &key, int i)
NoiseModelFactorN< double, double, double > Base
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...
const SharedNoiseModel & noiseModel() const
access to the noise model
Matrix * OptionalMatrixType
Vector evaluateError(const double &pk1, const double &qk, const double &qk1, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
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...
Vector evaluateError(const double &vk1, const double &vk, const double &q, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
Array< int, Dynamic, 1 > v
EIGEN_DEVICE_FUNC const Scalar & q
NoiseModelFactorN< double, double, double > Base
Vector evaluateError(const double &qk1, const double &qk, const double &v, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
NoiseModelFactorN< double, double, double > Base
std::shared_ptr< PendulumFactor2 > shared_ptr
std::shared_ptr< PendulumFactor1 > shared_ptr
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.
NoiseModelFactorN< double, double, double > Base
std::shared_ptr< PendulumFactorPk > shared_ptr
std::shared_ptr< This > shared_ptr
gtsam::NonlinearFactor::shared_ptr clone() const override
std::uint64_t Key
Integer nonlinear key type.
Vector evaluateError(const double &pk, const double &qk, const double &qk1, OptionalMatrixType H1, OptionalMatrixType H2, OptionalMatrixType H3) const override
gtsam::NonlinearFactor::shared_ptr clone() const override
std::shared_ptr< PendulumFactorPk1 > shared_ptr