diff --git a/gtsam_unstable/dynamics/SimpleHelicopter.h b/gtsam_unstable/dynamics/SimpleHelicopter.h index 8e1a2cf55..eadcb8739 100644 --- a/gtsam_unstable/dynamics/SimpleHelicopter.h +++ b/gtsam_unstable/dynamics/SimpleHelicopter.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -20,6 +21,8 @@ namespace gtsam { * \f$ \xi_k \f$: the body-fixed velocity (Lie algebra) * It is somewhat similar to BetweenFactor, but treats the body-fixed velocity * \f$ \xi_k \f$ as a variable. So it is a three-way factor. + * Note: this factor is necessary if one needs to smooth the entire graph. It's not needed + * in sequential update method. */ class Reconstruction : public NoiseModelFactor3 { @@ -78,8 +81,8 @@ class DiscreteEulerPoincareHelicopter : public NoiseModelFactor3 H1 = boost::none, + boost::optional H2 = boost::none, + boost::optional H3 = boost::none) const { + if (H1) { + (*H1) = numericalDerivative31( + boost::function( + boost::bind(&DiscreteEulerPoincareHelicopter::computeError, *this, _1, _2, _3) + ), + xik, xik_1, gk, 1e-5 + ); + } + if (H2) { + (*H2) = numericalDerivative32( + boost::function( + boost::bind(&DiscreteEulerPoincareHelicopter::computeError, *this, _1, _2, _3) + ), + xik, xik_1, gk, 1e-5 + ); + } + if (H3) { + (*H3) = numericalDerivative33( + boost::function( + boost::bind(&DiscreteEulerPoincareHelicopter::computeError, *this, _1, _2, _3) + ), + xik, xik_1, gk, 1e-5 + ); + } + + return computeError(xik, xik_1, gk); + } +#endif + };