ORB-SLAM2实验

运行双目EUROC数据集

./Examples/Stereo/stereo_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo/EuRoC.yaml ../datasets/euroc/V1_03_difficult/mav0/cam0/data ../datasets/euroc/V1_03_difficult/mav0/cam1/data ./Examples/Stereo/EuRoC_TimeStamps/V103.txt

运行ICL数据集

./Examples/RGB-D/rgbd_ICL ./Vocabulary/ORBvoc.txt ./Examples/RGB-D/ICL.yaml ../datasets/ICL/living_room_traj3_frei_png/ ../datasets/ICL/living_room_traj3_frei_png/associations.txt 

ORB-SLAM3实验篇

运行TUM数据集

./Examples/RGB-D/rgbd_tum ./Vocabulary/ORBvoc.txt ./Examples/RGB-D/TUM1.yaml ../datasets/TUM/rgbd_dataset_freiburg1_desk/ ../datasets/TUM/rgbd_dataset_freiburg1_desk/associate.txt

运行Kitti数据集

为了后面方便用EVO来评估轨迹误差我们将预测的轨迹保存成TUM格式:

// Save camera trajectory
//SLAM.SaveTrajectoryKITTI("CameraTrajectory.txt");
SLAM.SaveTrajectoryTUM("CameraTrajectory.txt");
SLAM.SaveKeyFrameTrajectoryTUM("KeyFrameTrajectory.txt");

ORB_SLAM3 双目模式下的命令(双目+IMU官方没有提供)

./Examples/Stereo/stereo_kitti ./Vocabulary/ORBvoc.txt ./Examples/Stereo/KITTI04-12.yaml ../datasets/KITTI/data_odometry/dataset/sequences/05/

运行EUROC数据集

这里以ORB_SLAM3 双目+imu模式为例:

./Examples/Stereo-Inertial/stereo_inertial_euroc ./Vocabulary/ORBvoc.txt ./Examples/Stereo-Inertial/EuRoC.yaml ../datasets/euroc/V2_03_difficult/ ./Examples/Stereo-Inertial/EuRoC_TimeStamps/V203.txt V2_03_result

ORB-SLAM3自带的评估脚本

python脚本是用python2写的

cd ORB-SLAM3/Example
 
#evaluate & plot
python ../evaluation/evaluate_ate_scale.py ../evaluation/Ground_truth/EuRoC_left_cam/MH03_GT.txt f_dataset-MH03_mono.txt --plot MH03_mono.pdf

TUM数据集

TUM数据集官网链接

associate.py使用

使用方法

python2 associate.py rgb.txt depth.txt > associate.txt

注意:这里官方提供的脚本是python2的

evo

evo_ape和evo_rpe计算方法

介绍前,先对定义一下公式标注:
算法估计位姿: P 1 . . . . . . P n ∈ S E ( 3 ) P_1......P_n\in SE(3) P1......PnSE(3)
真实位姿: Q 1 . . . . . . Q n ∈ S E ( 3 ) Q_1......Q_n\in SE(3) Q1......QnSE(3)
下标代表时间 t t t(或帧),这里我们假设估计位姿和真实位姿各帧时间已对齐,总帧数相同。 △ \triangle 表示相隔时间time interval。

安装

建议参考官网

错误一

在运行evo_traj tum data.tum -p报以下错误

[ERROR] Unhandled error in evo.main_traj
Traceback (most recent call last):
  File "/home/houyiliang/.local/lib/python3.8/site-packages/evo/entry_points.py", line 99, in launch
    main_module.run(args)
  File "/home/houyiliang/.local/lib/python3.8/site-packages/evo/main_traj.py", line 420, in run
    from evo.tools import plot
  File "/home/houyiliang/.local/lib/python3.8/site-packages/evo/tools/plot.py", line 43, in <module>
    import seaborn as sns
  File "/home/houyiliang/.local/lib/python3.8/site-packages/seaborn/__init__.py", line 2, in <module>
    from .rcmod import *  # noqa: F401,F403
  File "/home/houyiliang/.local/lib/python3.8/site-packages/seaborn/rcmod.py", line 5, in <module>
    from . import palettes
  File "/home/houyiliang/.local/lib/python3.8/site-packages/seaborn/palettes.py", line 9, in <module>
    from .utils import desaturate, get_color_cycle
  File "/home/houyiliang/.local/lib/python3.8/site-packages/seaborn/utils.py", line 11, in <module>
    import pandas as pd
  File "/home/houyiliang/.local/lib/python3.8/site-packages/pandas/__init__.py", line 48, in <module>
    from pandas.core.api import (
  File "/home/houyiliang/.local/lib/python3.8/site-packages/pandas/core/api.py", line 22, in <module>
    from pandas.core.algorithms import (
  File "/home/houyiliang/.local/lib/python3.8/site-packages/pandas/core/algorithms.py", line 40, in <module>
    from pandas.core.dtypes.cast import (
  File "/home/houyiliang/.local/lib/python3.8/site-packages/pandas/core/dtypes/cast.py", line 23, in <module>
    from dateutil.parser import ParserError
ImportError: cannot import name 'ParserError' from 'dateutil.parser' (/usr/lib/python3/dist-packages/dateutil/parser/__init__.py)

[ERROR] evo module evo.main_traj crashed - no logfile written (disabled)

可以看到这里错误是ImportError: cannot import name 'ParserError' from 'dateutil.parser'
缺什么我们就安什么

pip install python-dateutil==2.8.2

可以从 pypi网站上,查看 python-dateutil 最新版本编号
安装成功我们继续执行evo_traj tum data.tum -p,又出现了新的错误

File "/home/houyiliang/.local/lib/python3.8/site-packages/matplotlib/backends/_backend_tk.py", line 8, in <module>
    import tkinter as tk
ModuleNotFoundError: No module named 'tkinter'

老规矩缺什么安装什么

sudo apt-get update
sudo apt-get install python3-tk

安装完成后再次运行,又又又报错

from PIL import Image, ImageTk
ImportError: cannot import name 'ImageTk' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

再来

sudo apt-get install python3-pil python3-pil.imagetk

大功告成

支持的轨迹

  1. ros——ROS数据包
    当数据包中含有topic:geometry_msgs/PoseStamped, geometry_msgs/TransformStamped, geometry_msgs/PoseWithCovarianceStamped 和nav_msgs/Odometry,可以使用EVO工具进行轨迹对比。
    在v1.9版本之后,TF类topic也同样支持EVO评估。
  2. euroc——EuRoC MAV数据集
    本身EuRoC数据集不支持EVO工具的直接使用,需要转换成TUM类型数据集进行评估。
    EuRoC数据集中以csv结尾的文件存储了地面真值信息。
    使用EuRoC数据集时要注意坐标系,ground truth,IMU和Camera之间有着不同的轴约定。
  3. kitti——KITTI数据集
    KITTI数据集输出的轨迹数据中不包含时间戳信息。KITTI轨迹的文件中存储12个描述数据,是齐次位姿矩阵SE(3)的前三行
//SE(3)
a b c d
e f g h
i j k l
0 0 0 1
//kitti traj file
a b c d e f g h i j k l
  1. tum——TUM RGB-D数据集
    每行有8个条目,包含时间戳(以秒为单位)、位置和方向(四元数),每个值由空格分隔,结尾没有空格
timestamps x y z q_x q_y q_z q_w

轨迹之间的转换

不同类型的轨迹之间有的可以互相转换有的则不可以,下表给出了轨迹类型之间的转换关系

–save_as_bag –save_as_kitti –save_as_tum
bag yes yes yes
euroc yes yes yes
kitti no yes no
tum yes yes yes
//Example
// export a EuRoC groundtruth file to a TUM trajectory
evo_traj euroc data.csv --save_as_tum
//(will be saved as data.tum)

//export TUM trajectories to KITTI format
evo_traj tum traj_1.txt traj_2.txt traj_3.txt --save_as_kitti
//(will be saved as *.kitti)

//export TUM trajectories to ROS bagfile
evo_traj tum traj_1.txt traj_2.txt traj_3.txt --save_as_bag
//(will be saved as <timestamp>.bag with topics traj_1, traj_2 and traj_3)

在ORB-SLAM中修改版跑euroc数据集,在使用evo评估绝对轨迹误差时出现下面的报错:
found no matching timestamps between CameraTrajectory.txt and gt/MH01_GT.txt with max. time diff 0.01 (s) and time offset 0.0 (s)

原因是生成的轨迹和groundtruth,发现时间戳的格式不一样。
定位到问题是在例子程序中调用的轨迹保存函数是SaveTrajectoryTUM,因此得到的时间戳的小数点位是按照TUM数据集保存的
解决: 找到System.cc中的SaveTrajectoryTUM函数,将*lT改为1e9*(*lT)

//修改前
f << setprecision(6) << (*lT) << " " << setprecision(9) 
  << twc.at<float>(0) << " " << twc.at<float>(1) << " "<< twc.at<float>(2) << " "
  << q[0] << " " << q[1] << " " << q[2] << " " << q[3] << endl;
//修改后
  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;

评估KITTI数据集

将kitti位姿文件转换为tum格式:
KITTIground truth加上时间戳,转换成TUM格式的。在evo文件夹下有一个contrib文件夹,里面有一个kitti_poses_and_timestamps_to_trajectory.py文件。把KITTI数据集下的00.txttimes.txt文件拷贝到该目录,运行如下命令:

python3 kitti_poses_and_timestamps_to_trajectory.py 00.txt times.txt kitti_00_gt.txt

如果evo没有使用源码安装的话,直接去github上找到对应的.py文件下载,执行pip install evo就能用了

绘制轨迹

evo_traj tum KeyFrameTrajectory.txt --ref=kitti_00_tum.txt -p --plot_mode=xz --correct_scale --align

评估绝对误差

evo_ape tum kitti_00_tum.txt KeyFrameTrajectory.txt -va --plot --plot_mode xz --correct_scale --align   
#保存结果
evo_ape tum kitti_00_tum.txt kitti_00_gt.txt -p --plot -s --correct_scale -a --align -v --save_results kitti_00_ape.zip

-v --save_results一样表示保存结果
输出ape结果,以便进行比较

evo_res kitti_00_ape.zip -p --save_table kitti_00_apetable.csv
evo_res results/*.zip -p --save_table results/table.csv


evo_config set plot_seaborn_style whitegrid
这是修改背景,其中whitegrid可以替换成darkgrid, whitegrid, dark,white, ticks
evo_config set plot_seaborn_palette bright
这是修改线条,其中bright可以替换成deep, muted, bright, pastel, dark, colorblind

调整字体大小:evo_config set plot_fontfamily serif plot_fontscale 2

调整图像大小:evo_config set plot_figsize 10 9

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐