gtsam
Loading...
Searching...
No Matches
ImuBias.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
22#include <gtsam/base/VectorSpace.h>
23
24#include <iosfwd>
25#if GTSAM_ENABLE_BOOST_SERIALIZATION
26#include <boost/serialization/nvp.hpp>
27#endif
28
29namespace gtsam {
30
32namespace imuBias {
33
34class GTSAM_EXPORT ConstantBias {
35private:
36 Vector3 biasAcc_;
37 Vector3 biasGyro_;
38
39public:
41 static const size_t dimension = 6;
42
45
46 ConstantBias() :
47 biasAcc_(0.0, 0.0, 0.0), biasGyro_(0.0, 0.0, 0.0) {
48 }
49
50 ConstantBias(const Vector3& biasAcc, const Vector3& biasGyro) :
51 biasAcc_(biasAcc), biasGyro_(biasGyro) {
52 }
53
54 explicit ConstantBias(const Vector6& v) :
55 biasAcc_(v.head<3>()), biasGyro_(v.tail<3>()) {
56 }
57
59
61 Vector6 vector() const {
62 Vector6 v;
63 v << biasAcc_, biasGyro_;
64 return v;
65 }
66
68 const Vector3& accelerometer() const {
69 return biasAcc_;
70 }
71
73 const Vector3& gyroscope() const {
74 return biasGyro_;
75 }
76
78 Vector3 correctAccelerometer(const Vector3& measurement,
80 OptionalJacobian<3, 3> H2 = {}) const {
81 if (H1) (*H1) << -I_3x3, Z_3x3;
82 if (H2) *H2 = I_3x3;
83 return measurement - biasAcc_;
84 }
85
87 Vector3 correctGyroscope(const Vector3& measurement,
89 OptionalJacobian<3, 3> H2 = {}) const {
90 if (H1) (*H1) << Z_3x3, -I_3x3;
91 if (H2) *H2 = I_3x3;
92 return measurement - biasGyro_;
93 }
94
97
99 GTSAM_EXPORT friend std::ostream& operator<<(std::ostream& os,
100 const ConstantBias& bias);
101
103 void print(const std::string& s = "") const;
104
106 inline bool equals(const ConstantBias& expected, double tol = 1e-5) const {
107 return equal_with_abs_tol(biasAcc_, expected.biasAcc_, tol)
108 && equal_with_abs_tol(biasGyro_, expected.biasGyro_, tol);
109 }
110
114
116 static ConstantBias Identity() {
117 return ConstantBias();
118 }
119
121 inline ConstantBias operator-() const {
122 return ConstantBias(-biasAcc_, -biasGyro_);
123 }
124
126 ConstantBias operator+(const Vector6& v) const {
127 return ConstantBias(biasAcc_ + v.head<3>(), biasGyro_ + v.tail<3>());
128 }
129
131 ConstantBias operator+(const ConstantBias& b) const {
132 return ConstantBias(biasAcc_ + b.biasAcc_, biasGyro_ + b.biasGyro_);
133 }
134
136 ConstantBias operator-(const ConstantBias& b) const {
137 return ConstantBias(biasAcc_ - b.biasAcc_, biasGyro_ - b.biasGyro_);
138 }
139
143
145 ConstantBias retract(const Vector6& v) const {
146 return ConstantBias(biasAcc_ + v.head<3>(), biasGyro_ + v.tail<3>());
147 }
148
150 Vector6 localCoordinates(const ConstantBias& other) const {
151 return other.vector() - vector();
152 }
153
155
156private:
157
160
161#if GTSAM_ENABLE_BOOST_SERIALIZATION
163 friend class boost::serialization::access;
164 template<class ARCHIVE>
165 void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
166 ar & BOOST_SERIALIZATION_NVP(biasAcc_);
167 ar & BOOST_SERIALIZATION_NVP(biasGyro_);
168 }
169#endif
170
172
173}; // ConstantBias class
174} // namespace imuBias
175
176template<>
177struct traits<imuBias::ConstantBias> : public internal::VectorSpace<
178 imuBias::ConstantBias> {
179};
180
181} // namespace gtsam
Macros for Matrix constants to avoid excessive template instantiation.
Special class for optional Jacobian arguments.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
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:81
All bias models live in the imuBias namespace.
Definition ImuBias.cpp:26
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
VectorSpace provides both Testable and VectorSpaceTraits.
Definition VectorSpace.h:221
Definition ImuBias.h:34
const Vector3 & gyroscope() const
get gyroscope bias
Definition ImuBias.h:73
static ConstantBias Identity()
identity for group operation
Definition ImuBias.h:116
bool equals(const ConstantBias &expected, double tol=1e-5) const
equality up to tolerance
Definition ImuBias.h:106
ConstantBias operator-(const ConstantBias &b) const
subtraction
Definition ImuBias.h:136
Vector6 localCoordinates(const ConstantBias &other) const
The local coordinates function.
Definition ImuBias.h:150
Vector3 correctGyroscope(const Vector3 &measurement, OptionalJacobian< 3, 6 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
Correct a gyroscope measurement using this bias model, and optionally compute Jacobians.
Definition ImuBias.h:87
ConstantBias operator-() const
inverse
Definition ImuBias.h:121
static const size_t dimension
dimension of the variable - used to autodetect sizes
Definition ImuBias.h:41
Vector3 correctAccelerometer(const Vector3 &measurement, OptionalJacobian< 3, 6 > H1={}, OptionalJacobian< 3, 3 > H2={}) const
Correct an accelerometer measurement using this bias model, and optionally compute Jacobians.
Definition ImuBias.h:78
Vector6 vector() const
return the accelerometer and gyro biases in a single vector
Definition ImuBias.h:61
ConstantBias operator+(const Vector6 &v) const
addition of vector on right
Definition ImuBias.h:126
ConstantBias operator+(const ConstantBias &b) const
addition
Definition ImuBias.h:131
const Vector3 & accelerometer() const
get accelerometer bias
Definition ImuBias.h:68
ConstantBias retract(const Vector6 &v) const
The retract function.
Definition ImuBias.h:145