使用evo评估ORB-SLAM3 精度(3)--TUM数据集APE、RPE分析

1.数据格式转换

TUM/EuRoC/Kitti数据集都有各自的格式,evo可以直接用命令相互转换。

可参考SLAM精度测评——EVO_sunshine_guoqiang的博客-CSDN博客_slam精度

  • 1.1"把EuRoc的数据格式转化成TUM数据格式"

evo_traj euroc data.csv --save_as_tum

将生成的 KeyFrameNavStateTrajectory.txt 文件,总共17位(timestamp;position3;q4;v3;bw3;ba3),转化成符合TUM 形式的轨迹文件格式:8位 

timestamp x y z q_x q_y q_z q_w

  • 1.2"TUM数据转换成kitti格式"

evo_traj tum traj_1.txt  traj_2.txt  traj_3.txt  --save_as_kitti

  • 1.3"TUM数据转换成rosbag格式"

  • " 把一些文件的数据格式转化成rosbag"
  • evo_traj tum traj_1.txt traj_2.txt traj_3.txt --save_as_bag
  • 2.evo画图

  • 2.1 画单个数据

  • evo_traj euroc v203_truth.csv --plot

      2.2 画多个轨迹


      evo自带的示例如下,里面有自带的轨迹数据,命令如下:
      cd test/data
      evo_traj kitti KITTI_00_ORB.txt KITTI_00_SPTAM.txt --ref=KITTI_00_gt.txt -p --plot_mode=xz

  • 3.Run a metric on trajectories

  • 3.1 evo_ape

绝对位姿误差,常被用作绝对轨迹误差,比较估计轨迹和参考轨迹并计算整个轨迹的统计数据,适用于测试轨迹的全局一致性。
命令语法:命令 格式 参考轨迹 估计轨迹 [可选项]
其中格式包括euroc、tum等数据格式,可选项有对齐命令、画图、保存结果等。

For example, here we calculate the absolute pose error for two trajectories from ORB-SLAM and S-PTAM using evo_ape (KITTI_00_gt.txt is the reference (ground truth)) and plot and save the individual results to .zip files for evo_res:

mkdir results
evo_ape kitti KITTI_00_gt.txt KITTI_00_ORB.txt -r full 
-va --plot --plot_mode xz --save_results results/ORB.zip
命令的含义为:计算考虑平移和旋转部分误差的ape,进行平移和旋转对齐,以详细模式显示,保存画图并保存计算结果。
其中-r表示ape所基于的姿态关系

 不添加-r/–pose_relation和可选项,则默认为trans_part。

-v表示verbose mode,详细模式,-a表示采用SE(3) Umeyama对齐,其余可选项如下表所示。不加-s表示默认尺度对齐参数为1.0,即不进行尺度对齐。

详情:

可通过 evo_ape +数据格式 + --help查看更多参数的含义以及如何使用。例如
evo_ape euroc --help

3.2 evo_rpe

相对位姿误差不进行绝对位姿的比较,相对位姿误差比较运动(姿态增量)。相对位姿误差可以给出局部精度,例如slam系统每米的平移或者旋转漂移量。

命令语法:命令 格式 参考轨迹 估计轨迹 [可选项]
其中格式包括euroc、tum等数据格式,可选项有对齐命令、画图、保存结果等。
常用命令示例:

evo_rpe euroc data.csv V102.txt -r angle_deg --delta 1 --delta_unit m 
-va --plot --plot_mode xyz --save_plot ./VIO --save_results ./VIO.zip
 命令的含义为 求每米考虑旋转角的rpe,以详细模式显示并画图。
其中-r表示ape所基于的姿态关系

 不添加-r/–pose_relation和可选项,则默认为trans_part。
–d/–delta表示相对位姿之间的增量,–u/–delta_unit表示增量的单位,可选参数为[f, d, r, m],分别表示[frames, deg, rad, meters]。–d/–delta -u/–delta_unit合起来表示衡量局部精度的单位,如每米,每弧度,每百米等。其中–delta_unit为f时,–delta的参数必须为整形,其余情况下可以为浮点型。–delta 默认为1,–delta_unit默认为f。
-v --plot --plot_mode xyz --save_results results/VINS.zip --save_plot等同evo_ape中所讲。
当在命令中加上–all_pairs,则计算rpe时使用位置数据中所有的对而不是仅连续对,此时,可以通过-t/–delta_tol控制–all_pairs模式下的相对增量的容差(relative delta tolerance)。需要注意–all_pairs下不能使用–plot函数。
可通过 evo_rpe +数据格式 + --help查看更多参数的含义以及如何使用。例如
evo_rpe euroc --help

4.Process multiple results from a metric

evo_res can be used to compare multiple result files from the metrics, i.e

print infos and statistics (default)
plot the results
save the statistics in a table
Here, we use the results from above to generate a plot and a table:

evo_ape/evo_rpe中将结果保存为.zip文件后,可以利用evo_res对不同的结果进行比较。

evo_res results/*.zip -p --save_table results/table.csv
evo_res --help可查看可选参数含义。

evo其他常用命令

结果如下所示:

evo_ape kitti KITTI_00_gt.txt KITTI_00_ORB.txt -r trans_part -va --plot --plot_mode xz --save_results results/ORB.zip

5.运行tum数据集

tum数据集生成的.txt轨迹,用下面命令转成tum格式

evo_traj tum f_dataset-room1_512_stereoi.txt --save_as_tum

数据集自带的动捕系统真值转tum格式如下:

evo_traj tum data.csv --save_as_tum

计算ape,画图等,如下命令

evo_ape tum data.tum f_dataset-room1_512_stereoi.tum -r full 
-va --plot --plot_mode xyz --save_results results/Stereoi_IMU.zip

6.时间戳对齐问题与解决方法

evo可以自动对齐两类带有时间戳的数,对于帧率不同的两类数据,evo可以自动匹配对齐相应时间。如tum数据库,真值帧率是由动捕系统,约100帧每秒;相机帧率约20帧每秒,evo可以通过搜索时间帧,使相机帧20帧找到真值中的20帧并对齐,进而得到ape等。

一个bug

在stereo_inertial_tum_vi.cc中,tum数据集用了euroc数据集的存储轨迹的函数,如下

    if (bFileName)

    {

        const string kf_file =  "kf_" + string(argv[argc-1]) + ".txt";

        const string f_file =  "f_" + string(argv[argc-1]) + ".txt";

        SLAM.SaveTrajectoryEuRoC(f_file);

        SLAM.SaveKeyFrameTrajectoryEuRoC(kf_file);

    }

    else

    {

        SLAM.SaveTrajectoryEuRoC("CameraTrajectory.txt");

        SLAM.SaveKeyFrameTrajectoryEuRoC("KeyFrameTrajectory.txt");

    }

而函数SLAM.SaveTrajectoryEuRoC(f_file)在保存tum数据集时,*1e9,会导致时间戳单位不匹配(秒与纳秒),代码如下

if (mSensor == IMU_MONOCULAR || mSensor == IMU_STEREO)

        {

            cv::Mat Tbw = pKF->mImuCalib.Tbc*(*lit)*Trw;

            cv::Mat Rwb = Tbw.rowRange(0,3).colRange(0,3).t();

            cv::Mat twb = -Rwb*Tbw.rowRange(0,3).col(3);

            vector<float> q = Converter::toQuaternion(Rwb);

            f << setprecision(6) << 1e9*(*lT) << " " <<  setprecision(9) << twb.at<float>(0) << " " << twb.at<float>(1) << " " << twb.at<float>(2) << " " << q[0] << " " << q[1] << " " << q[2] << " " << q[3] << endl;

        }

        else

        {

            cv::Mat Tcw = (*lit)*Trw;

            cv::Mat Rwc = Tcw.rowRange(0,3).colRange(0,3).t();

            cv::Mat twc = -Rwc*Tcw.rowRange(0,3).col(3);

            vector<float> q = Converter::toQuaternion(Rwc);

            f << setprecision(6) << 1e9*(*lT) << " " <<  setprecision(9) << twc.at<float>(0) << " " << twc.at<float>(1) << " " << twc.at<float>(2) << " " << q[0] << " " << q[1] << " " << q[2] << " " << q[3] << endl;

        }

删掉此处的*1e9,用5中的方法,成功运行!

猜你喜欢

转载自blog.csdn.net/weixin_45834800/article/details/124587201
今日推荐