35 IMUFactor(
const Vector3& accel,
const Vector3& gyro,
37 :
Base(model, key1, key2),
accel_(accel), gyro_(gyro), dt_(dt) {}
42 :
Base(model, key1, key2),
accel_(imu_vector.head(3)), gyro_(imu_vector.tail(3)), dt_(dt) {}
47 virtual gtsam::NonlinearFactor::shared_ptr
clone()
const {
48 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
49 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
53 const This*
const f = dynamic_cast<const This*>(&e);
57 fabs(dt_ - f->dt_) < tol;
61 std::string a =
"IMUFactor: " + s;
65 std::cout <<
"dt: " << dt_ << std::endl;
69 const Vector3& gyro()
const {
return gyro_; }
70 const Vector3& accel()
const {
return accel_; }
71 Vector6 z()
const {
return (Vector6() <<
accel_, gyro_).finished(); }
78 boost::optional<Matrix&> H1 = boost::none,
79 boost::optional<Matrix&> H2 = boost::none)
const {
80 const Vector6 meas = z();
81 if (H1) *H1 = numericalDerivative21<Vector6, PoseRTV, PoseRTV>(
82 boost::bind(This::predict_proxy, _1, _2, dt_, meas), x1, x2, 1e-5);
83 if (H2) *H2 = numericalDerivative22<Vector6, PoseRTV, PoseRTV>(
84 boost::bind(This::predict_proxy, _1, _2, dt_, meas), x1, x2, 1e-5);
85 return predict_proxy(x1, x2, dt_, meas);
90 boost::optional<Matrix&> H1 = boost::none,
91 boost::optional<Matrix&> H2 = boost::none)
const {
93 return Vector6::Zero();
99 double dt,
const Vector6& meas) {
This is the base class for all factor types.
Definition: Factor.h:54
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:345
Class that represents integrating IMU measurements over time for dynamic systems Templated to allow f...
Definition: IMUFactor.h:21
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print.
Definition: NonlinearFactor.cpp:63
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
equals with a tolerance
Definition: Matrix.h:82
Robot state for use with IMU measurements.
Definition: PoseRTV.h:23
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Pose3 with translational velocity.
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: IMUFactor.h:47
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
Nonlinear factor base class.
Definition: NonlinearFactor.h:50
virtual Vector evaluateError(const PoseRTV &x1, const PoseRTV &x2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
Error evaluation with optional derivatives - calculates z - h(x1,x2)
Definition: IMUFactor.h:77
Non-linear factor base classes.
Vector6 imuPrediction(const PoseRTV &x2, double dt) const
Dynamics predictor for both ground and flying robots, given states at 1 and 2 Always move from time 1...
Definition: PoseRTV.cpp:133
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:1072
IMUFactor(const Vector6 &imu_vector, double dt, const Key &key1, const Key &key2, const SharedNoiseModel &model)
Full IMU vector specification.
Definition: IMUFactor.h:40
IMUFactor(const Vector3 &accel, const Vector3 &gyro, double dt, const Key &key1, const Key &key2, const SharedNoiseModel &model)
time between measurements
Definition: IMUFactor.h:35
Some functions to compute numerical derivatives.
virtual Vector evaluateError(const Pose3 &x1, const Pose3 &x2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
dummy version that fails for non-dynamic poses
Definition: IMUFactor.h:89
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.cpp:71
Vector3 accel_
measurements from the IMU
Definition: IMUFactor.h:29
virtual bool equals(const NonlinearFactor &e, double tol=1e-9) const
Check if two factors are equal.
Definition: IMUFactor.h:52
void print(const std::string &s="", const gtsam::KeyFormatter &formatter=gtsam::DefaultKeyFormatter) const
Print.
Definition: IMUFactor.h:60