MCPcopy Create free account
hub / github.com/Robotics-STAR-Lab/H2-Mapping / predict

Function predict

src/dvins/vins_estimator/src/estimator_node.cpp:82–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80};
81
82void predict(const sensor_msgs::ImuConstPtr &imu_msg)
83{
84 double t = imu_msg->header.stamp.toSec();
85 if (init_imu) {
86 latest_time = t;
87 init_imu = 0;
88 P_rt.setZero();
89 V_rt.setZero();
90 Q_rt.setIdentity();
91 Ba_rt.setZero();
92 Bg_rt.setZero();
93 acc_0 = Eigen::Vector3d(imu_msg->linear_acceleration.x, imu_msg->linear_acceleration.y, imu_msg->linear_acceleration.z);
94 gyr_0 = Eigen::Vector3d(imu_msg->angular_velocity.x, imu_msg->angular_velocity.y, imu_msg->angular_velocity.z);
95 return;
96 }
97 double dt = t - latest_time;
98 latest_time = t;
99
100 double dx = imu_msg->linear_acceleration.x;
101 double dy = imu_msg->linear_acceleration.y;
102 double dz = imu_msg->linear_acceleration.z;
103 Eigen::Vector3d acc_1{dx, dy, dz};
104
105 double rx = imu_msg->angular_velocity.x;
106 double ry = imu_msg->angular_velocity.y;
107 double rz = imu_msg->angular_velocity.z;
108 Eigen::Vector3d gyr_1{rx, ry, rz};
109
110 Eigen::Vector3d un_acc_0 = Q_rt * (acc_0 - Ba_rt) - estimator.g;
111 Eigen::Vector3d un_gyr = 0.5 * (gyr_0 + gyr_1) - Bg_rt;
112 Q_rt = Q_rt * Utility::deltaQ(un_gyr * dt);
113 Eigen::Vector3d un_acc_1 = Q_rt * (acc_1 - Ba_rt) - estimator.g;
114 Eigen::Vector3d un_acc = 0.5 * (un_acc_0 + un_acc_1);
115 P_rt = P_rt + dt * V_rt + 0.5 * dt * dt * un_acc;
116 V_rt = V_rt + dt * un_acc;
117 W_rt = gyr_1 - Bg_rt;
118
119 acc_0 = acc_1;
120 gyr_0 = gyr_1;
121}
122
123void update()
124{

Callers 2

updateFunction · 0.85
imuCallbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected