VINS未读懂代码

run_euroc.cpp

主函数中

pSystem.reset(new System(sConfig_path));// shared_ptr引用计数减一,这里的用法是?????

 System.cpp的getMeasurements()函数定义

vector<pair<vector<ImuConstPtr>, ImgConstPtr>> System::getMeasurements()
{
    vector<pair<vector<ImuConstPtr>, ImgConstPtr>> measurements;

    while (true)
    {
        if (imu_buf.empty() || feature_buf.empty())// 如果两个buf出现空的
        {
            // cerr << "1 imu_buf.empty() || feature_buf.empty()" << endl;
            return measurements;
        }

        if (!(imu_buf.back()->header > feature_buf.front()->header + estimator.td))// 等待imu进来
        {
            cerr << "wait for imu, only should happen at the beginning sum_of_wait: " // 新加的imu比最老的图片还要大???
                << sum_of_wait << endl;
            sum_of_wait++;
            return measurements;
        }

        if (!(imu_buf.front()->header < feature_buf.front()->header + estimator.td)) // 添加图片
        {
            cerr << "throw img, only should happen at the beginning" << endl;// 最老的imu比最老的图片要小???
            feature_buf.pop();
            continue;
        }
        ImgConstPtr img_msg = feature_buf.front(); // 取出最之前加进去的图片
        feature_buf.pop();

        vector<ImuConstPtr> IMUs;
        while (imu_buf.front()->header < img_msg->header + estimator.td)// imu最之前的ID小于当前取出图像的ID就可以往里面push_back了?????
        {
            IMUs.emplace_back(imu_buf.front());  //取出最之前加进去的imu
            imu_buf.pop();
        }
        // cout << "1 getMeasurements IMUs size: " << IMUs.size() << endl;
        IMUs.emplace_back(imu_buf.front());
        if (IMUs.empty()){
            cerr << "no imu between two image" << endl;
        }
        // cout << "1 getMeasurements img t: " << fixed << img_msg->header
        //     << " imu begin: "<< IMUs.front()->header 
        //     << " end: " << IMUs.back()->header
        //     << endl;
        measurements.emplace_back(IMUs, img_msg);
    }
    return measurements;
}
发布了176 篇原创文章 · 获赞 84 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/try_again_later/article/details/104618348