imumodel
ImuError.hpp
Go to the documentation of this file.
1 #ifndef IMUMODEL_IMUMODEL_HPP__
2 #define IMUMODEL_IMUMODEL_HPP__
3 
4 #include <base/Eigen.hpp>
5 #include <base/samples/IMUSensors.hpp>
6 #include <boost/random.hpp>
7 
8 namespace imumodel
9 {
10 
12 {
15  int seed;
17  double dt;
18 
20  base::Matrix3d Dacc;
22  base::Matrix3d Dgyro;
23 
25  base::Vector3d accrw;
27  base::Vector3d accrrw;
29  base::Vector3d accbias;
33  base::Vector3d abeta;
34 
36  base::Vector3d gyrorw;
38  base::Vector3d gyrorrw;
40  base::Vector3d gyrobias;
44  base::Vector3d gbeta;
45 
48  seed(-1),
49  dt(0.01),
50  Dacc( base::Matrix3d::Zero() ),
51  Dgyro( base::Matrix3d::Zero() ),
52  accrw( base::Vector3d::Zero() ),
53  accrrw( base::Vector3d::Zero() ),
54  accbias( base::Vector3d::Zero() ),
55  abeta( base::Vector3d::Zero() ),
56  gyrorw( base::Vector3d::Zero() ),
57  gyrorrw( base::Vector3d::Zero() ),
58  gyrobias( base::Vector3d::Zero() ),
59  gbeta( base::Vector3d::Zero() )
60  {}
61 };
62 
63 class ImuError
64 {
65 public:
66  static const int NUMAXIS = 3;
67 
68  void init();
69  void reset();
70  void step();
71  void addNoise( base::samples::IMUSensors &imu_sample );
72  void setConfiguration( const Configuration& config );
73  const Configuration& getConfiguration() const;
75 
76  base::Vector3d getGyroError() const;
77 
78 protected:
80 
81  base::Vector2d xax;
82  base::Vector2d xay;
83  base::Vector2d xaz;
85  base::Matrix2d Aax;
86  base::Vector2d Gax;
87  base::Matrix2d Aay;
88  base::Vector2d Gay;
89  base::Matrix2d Aaz;
90  base::Vector2d Gaz;
91  base::Vector2d Ha;
93  base::Vector2d xgx;
94  base::Vector2d xgy;
95  base::Vector2d xgz;
97  base::Matrix2d Agx;
98  base::Vector2d Ggx;
99  base::Matrix2d Agy;
100  base::Vector2d Ggy;
101  base::Matrix2d Agz;
102  base::Vector2d Ggz;
103  base::Vector2d Hg;
105  Eigen::Matrix <double,NUMAXIS,1> acc, gyros;
106  Eigen::Matrix <double,NUMAXIS,NUMAXIS> Dacc, Dgyro;
108  typedef boost::mt19937 RandomGenerator;
110  double GetNormalDistri(double mean, double sigma);
111 };
112 
117 {
118  base::Transform3d orientationError;
119  ImuError model;
120 
121 public:
123  {
124  reset();
125  }
126 
127  void setZGyroProperties( double bias, double rw, double rrw )
128  {
129  Configuration &config( model.getConfiguration() );
130  config.gyrobias = base::Vector3d::UnitZ() * bias;
131  config.gyrorw = base::Vector3d::UnitZ() * rw;
132  config.gyrorrw = base::Vector3d::UnitZ() * rrw;
133  model.init();
134  };
135 
136  void reset( int seed = -1 )
137  {
138  model.getConfiguration().seed = seed;
139  model.init();
140  model.reset();
141  orientationError = base::Transform3d::Identity();
142  }
143 
144  void step()
145  {
146  model.step();
147  base::Vector3d error = model.getGyroError();
148  orientationError = Eigen::AngleAxisd( error.z(), Eigen::Vector3d::UnitZ() ) *
149  orientationError;
150  }
151 
152  base::Transform3d getErrorTransform()
153  {
154  return orientationError;
155  }
156 };
157 
158 }
159 
160 #endif
Configuration()
Definition: ImuError.hpp:47
Eigen::Matrix< double, NUMAXIS, NUMAXIS > Dgyro
Definition: ImuError.hpp:106
base::Vector2d xay
Definition: ImuError.hpp:82
Definition: ImuError.hpp:63
base::Matrix2d Agx
Definition: ImuError.hpp:97
base::Vector3d accrw
Definition: ImuError.hpp:25
base::Matrix2d Aaz
Definition: ImuError.hpp:89
double GetNormalDistri(double mean, double sigma)
Definition: ImuError.cpp:154
void setZGyroProperties(double bias, double rw, double rrw)
Definition: ImuError.hpp:127
base::Vector2d xgz
Definition: ImuError.hpp:95
base::Vector2d Ggz
Definition: ImuError.hpp:102
void step()
Definition: ImuError.hpp:144
base::Transform3d getErrorTransform()
Definition: ImuError.hpp:152
base::Vector2d Gaz
Definition: ImuError.hpp:90
base::Matrix3d Dacc
Definition: ImuError.hpp:20
base::Vector3d getGyroError() const
Definition: ImuError.cpp:142
Definition: ImuError.hpp:116
base::Vector3d accrrw
Definition: ImuError.hpp:27
Eigen::Matrix< double, NUMAXIS, NUMAXIS > Dacc
Definition: ImuError.hpp:106
base::Vector3d gyrorw
Definition: ImuError.hpp:36
base::Vector3d abeta
Definition: ImuError.hpp:33
base::Vector2d Hg
Definition: ImuError.hpp:103
static const int NUMAXIS
Definition: ImuError.hpp:66
base::Vector2d xaz
Definition: ImuError.hpp:83
boost::mt19937 RandomGenerator
Definition: ImuError.hpp:108
void setConfiguration(const Configuration &config)
Definition: ImuError.cpp:172
void step()
Definition: ImuError.cpp:103
base::Vector3d gyrobias
Definition: ImuError.hpp:40
void addNoise(base::samples::IMUSensors &imu_sample)
Definition: ImuError.cpp:147
base::Vector3d gyrorrw
Definition: ImuError.hpp:38
base::Matrix2d Agz
Definition: ImuError.hpp:101
double dt
Definition: ImuError.hpp:17
Eigen::Matrix< double, NUMAXIS, 1 > gyros
Definition: ImuError.hpp:105
base::Vector2d xax
Definition: ImuError.hpp:81
base::Matrix2d Agy
Definition: ImuError.hpp:99
void init()
Definition: ImuError.cpp:5
int seed
Definition: ImuError.hpp:15
base::Matrix2d Aay
Definition: ImuError.hpp:87
base::Vector2d Ha
Definition: ImuError.hpp:91
base::Vector3d accbias
Definition: ImuError.hpp:29
AhrsError()
Definition: ImuError.hpp:122
RandomGenerator rng
Definition: ImuError.hpp:109
base::Matrix3d Dgyro
Definition: ImuError.hpp:22
base::Matrix2d Aax
Definition: ImuError.hpp:85
Definition: ImuError.hpp:11
base::Vector2d Ggx
Definition: ImuError.hpp:98
Configuration config
Definition: ImuError.hpp:79
base::Vector2d Ggy
Definition: ImuError.hpp:100
base::Vector2d Gax
Definition: ImuError.hpp:86
base::Vector3d gbeta
Definition: ImuError.hpp:44
base::Vector2d xgy
Definition: ImuError.hpp:94
void reset()
Definition: ImuError.cpp:85
const Configuration & getConfiguration() const
Definition: ImuError.cpp:177
void reset(int seed=-1)
Definition: ImuError.hpp:136
base::Vector2d Gay
Definition: ImuError.hpp:88
Eigen::Matrix< double, NUMAXIS, 1 > acc
Definition: ImuError.hpp:105
base::Vector2d xgx
Definition: ImuError.hpp:93