vins中IMU预计分

对于vins-mono,首先需要进行积分处理,对于两帧关键帧之间的图像数据,进行处理:

for (auto &imu_msg : measurement.first)
            {
                double t = imu_msg->header.stamp.toSec();
                double img_t = img_msg->header.stamp.toSec() + estimator.td;
                // std::cout<<"imu_msg: "<<t<<std::endl;
                // std::cout<<"img_msg: "<<img_t<<std::endl;
                std::cout.precision(15);
                // std::cout<<"imu_msg: "<<t<<"  img_msg: "<<img_t<<"  current_time: "<<current_time<<std::endl;
                if (t <= img_t)
                { 
                    // std::cout<<"&&&&&&&&&&&&&&&&&&&&&&&&&* "<<std::endl;
                    std::cout<<"imu_msg: "<<t<<"  img_msg: "<<img_t<<"  current_time: "<<current_time<<std::endl;
                    double dt;
                    if (current_time < 0){
                        current_time = t;
                        dt = 0;
                        // std::cout<<"t - current_time: "<<t - current_time<<std::endl;
                    }
                    else dt = t - current_time;
                    // std::cout<<"dt: "<<dt<<std::endl;
                    ROS_ASSERT(dt >= 0);
                    current_time = t;
                    dx = imu_msg->linear_acceleration.x;
                    dy = imu_msg->linear_acceleration.y;
                    dz = imu_msg->linear_acceleration.z;
                    rx = imu_msg->angular_velocity.x;
                    ry = imu_msg->angular_velocity.y;
                    rz = imu_msg->angular_velocity.z;
                    //cout<<"acc: "<<"dx:"<<dx<<" dy"<<dy<<" dz"<<dz<<endl;
                   // cout<<"gyr: "<<"rx: "<<rx<<" ry: "<<ry<<" rz: "<<rz<<endl;
                    estimator.processIMU(dt, Vector3d(dx, dy, dz), Vector3d(rx, ry, rz));
                    //printf("imu: dt:%f a: %f %f %f w: %f %f %f\n",dt, dx, dy, dz, rx, ry, rz);

                }
                else
                {
                    // std::cout<<"********************* "<<std::endl;
                    std::cout<<"imu_msg: "<<t<<"  img_msg: "<<img_t<<"  current_time: "<<current_time<<std::endl;
                    double dt_1 = img_t - current_time;
                    double dt_2 = t - img_t;
                    // std::cout<<"dt_1: "<<dt_1<<"  dt_2: "<<dt_2<<std::endl;
                    current_time = img_t;
                    // std::cout<<"dt_1: "<<dt_1<<std::endl;
                    // std::cout<<"dt_2: "<<dt_2<<std::endl;
                    // std::cout<<"dt_1 + dt_2: "<<dt_1 + dt_2<<std::endl;
                    ROS_ASSERT(dt_1 >= 0);
                    ROS_ASSERT(dt_2 >= 0);
                    ROS_ASSERT(dt_1 + dt_2 > 0);
                    double w1 = dt_2 / (dt_1 + dt_2);
                    double w2 = dt_1 / (dt_1 + dt_2);
                    dx = w1 * dx + w2 * imu_msg->linear_acceleration.x;
                    dy = w1 * dy + w2 * imu_msg->linear_acceleration.y;
                    dz = w1 * dz + w2 * imu_msg->linear_acceleration.z;
                    rx = w1 * rx + w2 * imu_msg->angular_velocity.x;
                    ry = w1 * ry + w2 * imu_msg->angular_velocity.y;
                    rz = w1 * rz + w2 * imu_msg->angular_velocity.z;
                    estimator.processIMU(dt_1, Vector3d(dx, dy, dz), Vector3d(rx, ry, rz));
                    //printf("dimu: dt:%f a: %f %f %f w: %f %f %f\n",dt_1, dx, dy, dz, rx, ry, rz);
                }

            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值