MCPcopy Create free account
hub / github.com/HKUST-Aerial-Robotics/GVINS / predict

Function predict

estimator/src/estimator_node.cpp:60–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58int skip_parameter;
59
60void predict(const sensor_msgs::ImuConstPtr &imu_msg)
61{
62 double t = imu_msg->header.stamp.toSec();
63 if (init_imu)
64 {
65 latest_time = t;
66 init_imu = 0;
67 return;
68 }
69 double dt = t - latest_time;
70 latest_time = t;
71
72 double dx = imu_msg->linear_acceleration.x;
73 double dy = imu_msg->linear_acceleration.y;
74 double dz = imu_msg->linear_acceleration.z;
75 Eigen::Vector3d linear_acceleration{dx, dy, dz};
76
77 double rx = imu_msg->angular_velocity.x;
78 double ry = imu_msg->angular_velocity.y;
79 double rz = imu_msg->angular_velocity.z;
80 Eigen::Vector3d angular_velocity{rx, ry, rz};
81
82 Eigen::Vector3d un_acc_0 = tmp_Q * (acc_0 - tmp_Ba) - estimator_ptr->g;
83
84 Eigen::Vector3d un_gyr = 0.5 * (gyr_0 + angular_velocity) - tmp_Bg;
85 tmp_Q = tmp_Q * Utility::deltaQ(un_gyr * dt);
86
87 Eigen::Vector3d un_acc_1 = tmp_Q * (linear_acceleration - tmp_Ba) - estimator_ptr->g;
88
89 Eigen::Vector3d un_acc = 0.5 * (un_acc_0 + un_acc_1);
90
91 tmp_P = tmp_P + dt * tmp_V + 0.5 * dt * dt * un_acc;
92 tmp_V = tmp_V + dt * un_acc;
93
94 acc_0 = linear_acceleration;
95 gyr_0 = angular_velocity;
96}
97
98void update()
99{

Callers 2

updateFunction · 0.85
imu_callbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected