一、当我们成功运行VINS-mono后,我们需要进行EVO工具的评估,我们应该做如下的改动:
(1)在项目文件夹下面找到euroc_config.yaml中的 pose_graph_save_path项:
pose_graph_save_path: "/home/kk/自己的路径/"
(2)euroc_config.yaml中的output_path项
output_path: "/home/kk/自己的路径/"
上述""里填写自己的路径,先创建好该路径,注意最后面有个/,代表着是一个文件夹。
修改完之后,记得在ros工作空间中重新编译一下catkin_make。---记住!!!
二、修改数据格式
在项目src文件夹下面搜visualization.cpp这个文件,然后打开,将
// write result to file
ofstream foutC(VINS_RESULT_PATH, ios::app);
foutC.setf(ios::fixed, ios::floatfield);
foutC.precision(0);
foutC << header.stamp.toSec() * 1e9 << ",";
foutC.precision(5);
foutC << estimator.Ps[WINDOW_SIZE].x() << ","
<< estimator.Ps[WINDOW_SIZE].y() << ","
<< estimator.Ps[WINDOW_SIZE].z() << ","
<< tmp_Q.w() << ","
<< tmp_Q.x() << ","
<< tmp_Q.y() << ","
<< tmp_Q.z() << ","
<< estimator.Vs[WINDOW_SIZE].x() << ","
<< estimator.Vs[WINDOW_SIZE].y() << ","
<< estimator.Vs[WINDOW_SIZE].z() << "," << endl;
write result to file
改为:
ofstream foutC(VINS_RESULT_PATH, ios::app);
foutC.setf(ios::fixed, ios::floatfield);
foutC.precision(0);
foutC << header.stamp.toSec() << " ";
foutC.precision(5);
foutC << estimator.Ps[WINDOW_SIZE].x() << " "
<< estimator.Ps[WINDOW_SIZE].y() << " "
<< estimator.Ps[WINDOW_SIZE].z() << " "
<< tmp_Q.x() << " "
<< tmp_Q.y() << " "
<< tmp_Q.z() << " "
<< tmp_Q.w() << endl;
// << estimator.Vs[WINDOW_SIZE].x() << ","
// << estimator.Vs[WINDOW_SIZE].y() << ","
//<< estimator.Vs[WINDOW_SIZE].z() << "," << endl;
在pose_graph.cpp,中需要改两处,第一处:updatePath()函数
ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
loop_path_file.setf(ios::fixed, ios::floatfield);
loop_path_file.precision(0);
loop_path_file << (*it)->time_stamp * 1e9 << ",";
loop_path_file.precision(5);
loop_path_file << P.x() << ","
<< P.y() << ","
<< P.z() << ","
<< Q.w() << ","
<< Q.x() << ","
<< Q.y() << ","
<< Q.z() << ","
<< endl;
改为:
ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
loop_path_file.setf(ios::fixed, ios::floatfield);
loop_path_file.precision(0);
loop_path_file << (*it)->time_stamp << " ";
loop_path_file.precision(5);
loop_path_file << P.x() << " "
<< P.y() << " "
<< P.z() << " "
<< Q.x() << " "
<< Q.y() << " "
<< Q.z() << " "
<< Q.w() << endl;
第二处, addKeyFrame()函数
ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
loop_path_file.setf(ios::fixed, ios::floatfield);
loop_path_file.precision(0);
loop_path_file << cur_kf->time_stamp * 1e9 << ",";
loop_path_file.precision(5);
loop_path_file << P.x() << ","
<< P.y() << ","
<< P.z() << ","
<< Q.w() << ","
<< Q.x() << ","
<< Q.y() << ","
<< Q.z() << ","
<< endl;
改成:
ofstream loop_path_file(VINS_RESULT_PATH, ios::app);
loop_path_file.setf(ios::fixed, ios::floatfield);
loop_path_file.precision(0);
loop_path_file << cur_kf->time_stamp << " ";
loop_path_file.precision(5);
loop_path_file << P.x() << " "
<< P.y() << " "
<< P.z() << " "
<< Q.x() << " "
<< Q.y() << " "
<< Q.z() << " "
<< Q.w() << endl;
三、将 pose_graph_node.cpp中的main()函数,原本是csv文件,改成txt。
VINS_RESULT_PATH = VINS_RESULT_PATH + "/vins_result_loop.txt";
2、在我们建的数据保存文件下会生成一个vins_result_loop.txt文件,然后在catkin_ws/src/VINS-Mono/benchmark_publisher/config/MH_01_easy文件下有data.csv,我们利用命令转化:
evo_traj euroc data.csv --save_as_tum
3、这样会生成data.tum文件,然后利用生成图像,注意一定要将vins_result_loop.txt,data.tum两个文件放在一个文件夹,在这个文件夹下面建立终端输入:
evo_traj tum vins_result_loop.txt --ref=data.tum -p --plot_mode=xyz