一、安装evo
pip install evo --upgrade --no-binary evo --user
检查
二、使用evo
2.1evo_traj: 主要是用来画轨迹、输出轨迹文件、转换数据格式等功能
//针对 bag 文件 使用 evo_traj 命令
evo_traj bag文件 话题名1 话题名2 .... 话题名n [参数]
evo_traj bag data_pose_2020-07-25-17-19-16.bag /odom /amcl_pose -p
//针对 kitti、tum、euroc 格式 使用 evo_traj 命令
evo_traj tum --ref=gt.txt 1.txt 2.txt 3.txt -a -p --save_plot ./output.pdf
2.2evo_ape: 计算绝对位姿误差
命令语法:命令 格式 参考轨迹 估计轨迹 [可选项]
evo_ape kitti ground_truth.txt laser_odom.txt -r full --plot --plot_mode xyz
三、EVO评估KITTI数据集
3.1bag数据订阅
(1)bag话题查询
rosbag info
(2)订阅相关话题
ros::Subscriber subLaserCloud = nh.subscribe<sensor_msgs::PointCloud2>("/points_raw", 100, laserCloudHandler);
3.2保存轨迹
将机器人的位姿数据(全局坐标系)写入一个文件中。实现原理是将机器人当前的位姿数据(odomAftMapped.pose.pose)
std::ofstream pose1("/home/zengmiao/code/odom_evo/ALOAM.txt", std::ios::app);
pose1.setf(std::ios::scientific, std::ios::floatfield);
//设置输出浮点数的精度为6位。
pose1.precision(6);
pose1 << odomAftMapped.header.stamp << " "
<< odomAftMapped.pose.pose.position.x << " "
<< odomAftMapped.pose.pose.position.y << " "
<< odomAftMapped.pose.pose.position.z << " "
<< odomAftMapped.pose.pose.orientation.x << " "
<< odomAftMapped.pose.pose.orientation.y << " "
<< odomAftMapped.pose.pose.orientation.z << " "
<< odomAftMapped.pose.pose.orientation.w << std::endl;
pose1.close();
3.3评估轨迹
evo_traj tum --ref=LOAM1.txt LOAM2.txt LOAM3.txt --plot --plot_mode=xyz --align --correct_scale