Propagates pose, speeds and biases with given IMU measurements.
| 264 | |
| 265 | // Propagates pose, speeds and biases with given IMU measurements. |
| 266 | int ImuError::propagation(const okvis::ImuMeasurementDeque& imuMeasurements, |
| 267 | const okvis::ImuParameters& imuParams, |
| 268 | okvis::kinematics::Transformation& T_WS, |
| 269 | okvis::SpeedAndBias& speedAndBiases, |
| 270 | const okvis::Time& t_start, |
| 271 | const okvis::Time& t_end, |
| 272 | covariance_t* covariance, |
| 273 | jacobian_t* jacobian) { |
| 274 | // now the propagation |
| 275 | okvis::Time time = t_start; |
| 276 | okvis::Time end = t_end; |
| 277 | |
| 278 | // sanity check: |
| 279 | assert(imuMeasurements.front().timeStamp <= time); |
| 280 | if (!(imuMeasurements.back().timeStamp >= end)) return -1; // nothing to do... |
| 281 | |
| 282 | // initial condition |
| 283 | Eigen::Vector3d r_0 = T_WS.r(); |
| 284 | Eigen::Quaterniond q_WS_0 = T_WS.q(); |
| 285 | Eigen::Matrix3d C_WS_0 = T_WS.C(); |
| 286 | |
| 287 | // increments (initialise with identity) |
| 288 | Eigen::Quaterniond Delta_q(1, 0, 0, 0); |
| 289 | Eigen::Matrix3d C_integral = Eigen::Matrix3d::Zero(); |
| 290 | Eigen::Matrix3d C_doubleintegral = Eigen::Matrix3d::Zero(); |
| 291 | Eigen::Vector3d acc_integral = Eigen::Vector3d::Zero(); |
| 292 | Eigen::Vector3d acc_doubleintegral = Eigen::Vector3d::Zero(); |
| 293 | |
| 294 | // cross matrix accumulatrion |
| 295 | Eigen::Matrix3d cross = Eigen::Matrix3d::Zero(); |
| 296 | |
| 297 | // sub-Jacobians |
| 298 | Eigen::Matrix3d dalpha_db_g = Eigen::Matrix3d::Zero(); |
| 299 | Eigen::Matrix3d dv_db_g = Eigen::Matrix3d::Zero(); |
| 300 | Eigen::Matrix3d dp_db_g = Eigen::Matrix3d::Zero(); |
| 301 | |
| 302 | // the Jacobian of the increment (w/o biases) |
| 303 | Eigen::Matrix<double, 15, 15> P_delta = Eigen::Matrix<double, 15, 15>::Zero(); |
| 304 | |
| 305 | double Delta_t = 0; |
| 306 | bool hasStarted = false; |
| 307 | int i = 0; |
| 308 | |
| 309 | for (okvis::ImuMeasurementDeque::const_iterator it = imuMeasurements.begin(); it != imuMeasurements.end(); ++it) { |
| 310 | Eigen::Vector3d omega_S_0 = it->measurement.gyroscopes; |
| 311 | Eigen::Vector3d acc_S_0 = it->measurement.accelerometers; |
| 312 | Eigen::Vector3d omega_S_1 = (it + 1)->measurement.gyroscopes; |
| 313 | Eigen::Vector3d acc_S_1 = (it + 1)->measurement.accelerometers; |
| 314 | |
| 315 | // time delta |
| 316 | okvis::Time nexttime; |
| 317 | if ((it + 1) == imuMeasurements.end()) { |
| 318 | nexttime = t_end; |
| 319 | } else { |
| 320 | nexttime = (it + 1)->timeStamp; |
| 321 | } |
| 322 | double dt = (nexttime - time).toSec(); |
| 323 |
no test coverage detected