1 安装依赖
1.1 opencv
这里用的之前安装的4.4.0版本 参考上一篇ORBSLAM3文章
1.2 Eigen3
1.3 Ceres
参考IMU标定,装的2.1.0
2 修改VINS-mono轨迹保存代码
如果需要用evo测评的话,就得改
一共三个地方
No.1 vins_estimator/src/utility/visualization.cpp
150多行
// 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(9);
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;
foutC.close();
No.2 and 3 pose_graph/src/pose_graph.cpp
No.2 150多行addKeyFrame()函数里面
if (SAVE_LOOP_PATH)
{
//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;
loop_path_file.close();
}
No.3 600多行updatePath()函数里面
if (SAVE_LOOP_PATH)
{
//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;
loop_path_file.close();
}
2 编译VINS-Mono
1、CMake Error at /usr/local/lib/cmake/Ceres/CeresConfig.cmake:85 (message): Failed to find Ceres - Found Eigen dependency, but the version of Eigen found (3.3.90) does not exactly match the version of Eigen Ceres was compiled with (3.3.7). This can cause subtle bugs by triggering violations of the One Definition Rule. See the Wikipedia article http://en.wikipedia.org/wiki/One_Definition_Rule for more details
试了各种方法,重新安装了一下ceres-solver
2、error: ‘std::integer_sequence’ has not been declared
改std为14
3、error:‘ CV_* ’was not declared in this scope
加头文件,参考文章
/VINS-Mono/camera_model/src/intrinsic_calib.cc
加
#include <opencv2/imgproc/imgproc_c.h>
/VINS-Mono/camera_model/src/chessboard/Chessboard.cc
加
#include <opencv2/calib3d/calib3d_c.h>
#include <opencv2/imgproc/types_c.h>
/VINS-Mono/camera_model/src/calib/CameraCalibration.cc
#include <opencv2/imgproc/types_c.h>
#include <opencv2/imgproc/imgproc_c.h>
或236行修改为
cv::COLOR_GRAY2BGR
/VINS-Mono/pose_graph/src/ThirdParty/DVision/BRIEF.cpp
#include <opencv2/imgproc/types_c.h>
/VINS-Mono/pose_graph/src/pose_graph.cpp
和/VINS-Mono/pose_graph/src/keyframe.cpp
CV_FONT_HERSHEY_SIMPLEX修改为
cv::FONT_HERSHEY_SIMPLEX
运行VINS-mono
roslaunch vins_estimator euroc.launch
roslaunch vins_estimator vins_rviz.launch
rosbag play ~/catkin_ws/Dataset/MH_01_easy.bag
.yaml文件参数参考文章
evo安装
github官网地址
大概的使用方法
evo_traj tum vio.csv -p //显示轨迹 -p画图
evo_traj bag 你的bag名 你的topic名 --save_as_tum //bag转tum
evo_ape tum groundtruth.csv vio.csv -p -va --save_results results.zip //计算j绝对位姿误差,-v显示详细信息,-a对齐,--save_results保存结果
evo_rpe //使用方法同上,计算相对位姿误差
evo_res 1.zip 2.zip -p //比较1和2