VINS( 二 )


问题3:
配置文件里面的IMU 变成1 ,运行不了!为什么?
答:
需要改程序! 文件里面虽然有IMU数据,但是我们仅仅是读取出来了,
并没有用它!GPS和IMU数据是放在一起的,具体的意思如下:
问题4:
为什么很少见 “视觉+IMU+GPS的组合”呢?是因为他们没有必要嘛?
答:
其实VINS-已经实现了,只是需要进行一下组合罢了!也可能做这方面的人少,个人感觉还是有价值的,
对于大场景来说很有必要的!后面自己会尝试组合一下,感觉更多是数据的处理!
五、视觉 + IMU + GPS
前面我们跑的程序其实是:双目+GPS; VINS- 里面并没有 双目+IMU+GPS!
但是本人想把这个组合跑起来,所以自己动手写了一下,具体步骤如下,如果效果好,会公开细节!
数据预处理
以为例,这个数据是图片和激光雷达对齐后的数据;
此数据中GPS和IMU数据在一起,但是IMU的时间是和图片的时间一样的,10HZ!
因此我们如果想实现 IMU+图像+GPS的数据,必须把100HZ的IMU数据和时间提取出来;
还有对应的 , 这是没有对齐的数据,其中IMU的时间为100HZ,因此
我们要从这个文件里面把IMU数据提取出来!值的注意的是,KITTI数据里面的图像、激光雷达、GPS的数据是10HZ !
下面是我提取数据的程序!
#include #include #include #include #include #include #include #include "estimator/estimator.h"int main(int argc, char** argv){ros::init(argc, argv, "vins_estimator");ros::NodeHandle n("~");string sequence1 = "/home/hltt3838/kitti_data/2011_10_03_drive_0042_extract/";string dataPath1 = sequence1 + "/";string sequence2 = "/home/hltt3838/kitti_data/2011_10_03_drive_0042_sync/";string dataPath2 = sequence2 + "/";/*----------------------------IMU读取数据----------------------------------*///读取 100HZ的IMU时间FILE* file1;file1 = std::fopen((dataPath1 + "oxts/timestamps.txt").c_str() , "r");if(file1 == NULL){printf("cannot find file: %soxts/timestamps.txt \n", dataPath1.c_str());return 0;}vector imuTimeList;int year1, month1, day1;int hour1, minute1;double second1;while (fscanf(file1, "%d-%d-%d %d:%d:%lf", &year1, &month1, &day1, &hour1, &minute1, &second1) != EOF){imuTimeList.push_back(hour1 * 60 * 60 + minute1 * 60 + second1);}std::fclose(file1);/*------------------------------IMU读取数据-------------------------------*//*----------------------------GPS读取数据----------------------------------*///读取 100HZ的IMU时间FILE* file2;file2 = std::fopen((dataPath2 + "oxts/timestamps.txt").c_str() , "r");if(file2 == NULL){printf("cannot find file: %soxts/timestamps.txt \n", dataPath2.c_str());return 0;}vector gpsTimeList;int year2, month2, day2;int hour2, minute2;double second2;while (fscanf(file2, "%d-%d-%d %d:%d:%lf", &year2, &month2, &day2, &hour2, &minute2, &second2) != EOF){gpsTimeList.push_back(hour2 * 60 * 60 + minute2 * 60 + second2);}std::fclose(file2);/*------------------------------GPS读取数据-------------------------------*/string OUTPUT_imu = "/home/hltt3838/kitti_data/imu_data_100hz/"; //不能有空格FILE* outFile_imu;outFile_imu = fopen((OUTPUT_imu + "/imu.txt").c_str(),"w");string OUTPUT_gps = "/home/hltt3838/kitti_data/gps_data_10hz/"; //不能有空格FILE* outFile_gps;outFile_gps = fopen((OUTPUT_gps + "/gps.txt").c_str(),"w");for (size_t i = 0; i < imuTimeList.size(); i++){ stringstream ss;ss << setfill('0') << setw(10) << i;//读取GPS信息FILE* imuFile;string imuFilePath = dataPath1 + "oxts/data/" + ss.str() + ".txt";imuFile = std::fopen(imuFilePath.c_str() , "r");if(imuFile == NULL){printf("cannot find file: %s\n", imuFilePath.c_str());return 0;}double lat, lon, alt, roll, pitch, yaw;double vn, ve, vf, vl, vu;double ax, ay, az, af, al, au;double wx, wy, wz, wf, wl, wu;double pos_accuracy, vel_accuracy;double navstat, numsats;double velmode, orimode;fscanf(imuFile, "%lf %lf %lf %lf %lf %lf ", &lat, &lon, &alt, &roll, &pitch, &yaw);fscanf(imuFile, "%lf %lf %lf %lf %lf ", &vn, &ve, &vf, &vl, &vu);fscanf(imuFile, "%lf %lf %lf %lf %lf %lf ", &ax, &ay, &az, &af, &al, &au);fscanf(imuFile, "%lf %lf %lf %lf %lf %lf ", &wx, &wy, &wz, &wf, &wl, &wu);fscanf(imuFile, "%lf %lf %lf %lf %lf %lf ", &pos_accuracy, &vel_accuracy, &navstat, &numsats, &velmode, &orimode);std::fclose(imuFile);fprintf (outFile_imu, "%f %f %f %f %f %f %f \n",imuTimeList[i],ax,ay,az,wx,wy,wz);}for (size_t i = 0; i