13
13
14
14
extern struct Params Config;
15
15
16
- // class State {
16
+ // class State
17
17
// public:
18
- State::State () {
19
- // Read from YAML
18
+
19
+ State::State () : State::State (0 .) {
20
+ // Read YAML parameters
20
21
this ->g = Eigen::Map<Eigen::Vector3f>(Config.initial_gravity .data (), 3 );
21
22
this ->tLI = Eigen::Map<Eigen::Vector3f>(Config.I_Translation_L .data (), 3 );
22
23
this ->RLI = Eigen::Map<Eigen::Matrix3f>(Config.I_Rotation_L .data (), 3 , 3 ).transpose ();
23
24
24
- // Assume object is static at the begging
25
+ // State
26
+ this ->pos = Eigen::Vector3f::Zero ();
27
+ this ->R = Eigen::Matrix3f::Identity ();
25
28
this ->vel = Eigen::Vector3f::Zero ();
26
29
27
- // Assume biases and noises zero as a first estimation
30
+ // Biases
28
31
this ->bw = Eigen::Vector3f::Zero ();
29
32
this ->ba = Eigen::Vector3f::Zero ();
30
33
34
+ // Noise
31
35
this ->nw = Eigen::Vector3f::Zero ();
32
36
this ->na = Eigen::Vector3f::Zero ();
33
37
this ->nbw = Eigen::Vector3f::Zero ();
34
38
this ->nba = Eigen::Vector3f::Zero ();
35
-
36
- // Assume vehicle at origin
37
- this ->pos = Eigen::Vector3f::Zero ();
38
- this ->R = Eigen::Matrix3f::Identity ();
39
39
}
40
40
41
- State::State (double time) : State::State() {
42
- this ->time = time ;
41
+ State::State (const state_ikfom& s, const IMU& imu, double time) : State::State(s, time) {
42
+ this ->a = imu.a ;
43
+ this ->w = imu.w ;
43
44
}
44
45
45
- State::State (const state_ikfom& s, double time) : State () {
46
- // Export state_ikfom parameters
46
+ State::State (const state_ikfom& s, double time) : State::State (time) {
47
47
this ->R = s.rot .toRotationMatrix ().cast <float >();
48
48
this ->pos = s.pos .cast <float >();
49
49
this ->vel = s.vel .cast <float >();
@@ -53,13 +53,12 @@ extern struct Params Config;
53
53
54
54
this ->RLI = s.offset_R_L_I .toRotationMatrix ().cast <float >();
55
55
this ->tLI = s.offset_T_L_I .cast <float >();
56
-
57
- // Get closest IMU to time
58
- IMU imu = Accumulator::getInstance ().get_next_imu (time );
59
- this ->a = imu.a ;
60
- this ->w = imu.w ;
56
+ }
61
57
58
+ State::State (double time) {
62
59
this ->time = time ;
60
+ this ->a = -this ->g ;
61
+ this ->w = Eigen::Vector3f::Zero ();
63
62
}
64
63
65
64
RotTransl State::I_Rt_L () const {
@@ -119,4 +118,4 @@ extern struct Params Config;
119
118
this ->time = imu.time ;
120
119
this ->a = 0.5 *this ->a + 0.5 *imu.a ; // Exponential mean (noisy inputs)
121
120
this ->w = 0.5 *this ->w + 0.5 *imu.w ; // Exponential mean (noisy inputs)
122
- }
121
+ }
0 commit comments