《视觉SLAM进阶:从零开始手写VIO》(二)

《视觉SLAM进阶:从零开始手写VIO》第二讲

1 安装im_utils
这个工具之前就使用过了,还写了博客,没想到在这里用上了,博客地址:https://blog.csdn.net/learning_tortosie/article/details/89878769 ,现直接搬运到这里。

imu_utils是一个用于分析IMU性能的ROS工具包。

1.1 安装

首先,安装依赖:

sudo apt-get install li

作者在README.md中的编译步骤为:

download required code_utils;
put the ROS package imu_utils and code_utils into your workspace, usually named catkin_ws;
cd to your workspace, build with catkin_make;

但是,如果这样操作,会编译出错。查了一下,需要先编译code_utils,然后再编译imu_utils,不能同时编译,应该是依赖问题。

正确的编译步骤:

mkdir -p imu-calibration/src
cd imu-calibration/src
git clone https://github.com/gaowenliang/code_utils.git
cd ..
catkin_make
cd imu-calibration/src
git clone https://github.com/gaowenliang/imu_utils.git
cd ..
catkin_make

1.2 可能出现的Error
当然,还有可能遇到一些错误。

错误1:找不到Eigen

我们一般通过以下命令安装Eigen:

sudo apt-get install libeigen3-dev
1
这样Eigen就默认安装在/usr/include/eigen3,需要在/home/jlg/imu-calibration/src/code_utils/CMakeLists.txt中注释掉find_package(Eigen3 REQUIRED),然后添加:

include_directories(/usr/include/eigen3)
1
错误2:找不到backward.hpp

atal error: backward.hpp: No such file or directory

把文件code_utils/src/sumpixel_test.cpp中的#include "backward.hpp"改成#include "code_utils/backward.hpp"即可。

错误3:std::ofstream未定义

/home/***/imu-calibration/src/imu_utils/src/imu_an.cpp:69:19: error: aggregate ‘std::ofstream out_t’ has incomplete type and cannot be defined

打开文件imu_utils/src/imu_an.cpp,添加:

#include <fstream>

1.3 运行
1.采集IMU数据

在 IMU 静止时收集数据,持续两小时。

2.播放数据

rosbag play -r 200 imu_A3.bag

作者提供了5个IMU数据集,可以先测试一下。

3.启动节点

roslaunch imu_utils A3.launch

注意launch文件:

<launch>
    <node pkg="imu_utils" type="imu_an" name="imu_an" output="screen">
        <param name="imu_topic" type="string" value= "/djiros/imu"/>
        <param name="imu_name" type="string" value= "A3"/>
        <param name="data_save_path" type="string" value= "$(find imu_utils)/data/"/>
        <param name="max_time_min" type="int" value= "120"/>
        <param name="max_cluster" type="int" value= "100"/>
    </node>
</launch>

要根据自己的IMU,修改imu_topic 和imu_name。

4.样例

我使用的imu_16448.bag,结果保存在imu_utils/data/16448_imu_param.yaml,对于其他 txt 文件,可以用imu_utils/scripts中的Matlab脚本绘图。

%YAML:1.0
type: IMU
name: “16448”
Gyr:
unit: rad/s
avg-axis:
gyr_n: 2.5540703819967830e-03
gyr_w: 7.3979547257109791e-05
x-axis:
gyr_n: 2.5732073264841159e-03
gyr_w: 7.9169715719978401e-05
y-axis:
gyr_n: 2.5490825380843534e-03
gyr_w: 6.8388779942953886e-05
z-axis:
gyr_n: 2.5399212814218798e-03
gyr_w: 7.4380146108397072e-05
Acc:
unit: " m/s^2"
avg-axis:
acc_n: 2.7851422418165215e-02
acc_w: 1.2053367145964710e-03
x-axis:
acc_n: 2.6671201438493906e-02
acc_w: 9.3260697511083528e-04
y-axis:
acc_n: 3.2016249942269592e-02
acc_w: 1.8349143250976515e-03
z-axis:
acc_n: 2.4866815873732146e-02
acc_w: 8.4848884358092636e-04

1.4 参考资料

2 编译vio_data_simulation-master
vio_data_simulation-master是一个Cmake工程,按套路操作就好。

cd vio_data_simulation-master
mkdir build
cd build
camke ..
make
cd ../bin
./data_gen

此时,在vio_data_simulation-master/bin目录下会生成一些txt文件,我们需要的是imu_pose.txt和imu_int_pose.txt,然后用Python的matplotlib绘图。

cd ../python_tool
python draw_trajctory.py

说明
imu_pose.txt是由给定的轨迹方程和欧拉角,生成IMU的pose,imu_int_pose.txt是由给定的轨迹得到速度和加速度,再根据欧拉法和中值法得到IMU的pose,通过比较两个pose,可以得到欧拉法和中值法的效果。

2.1 欧拉法
(1)公式

在这里插入图片描述

在这里插入图片描述

2.2 中值积分法

(1)公式

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

对比:目测中值法比欧拉法精度高。

3 编译vio_data_simulation-ros_version
3.1 编译

mkdir -p catkin_ws_vio_data_simulation-ros_version/src
cp vio_data_simulation-ros_version catkin_ws_vio_data_simulation-ros_version/src
cd catkin_ws_vio_data_simulation-ros_version
catkin_make

3.2 生成imu.bag
首先,打开catkin_ws_vio_data_simulation/src/vio_data_simulation-ros_version/src/gener_alldata.cpp,设置imu.bag的存储路径。

bag.open("/your-path/imu.bag", rosbag::bagmode::Write);

然后,启动节点,生成imu.bag。

source devel/setup.bash
rosrun vio_data_simulation vio_data_simulation_node

3.3 使用imu_utils标定IMU的白噪声和零偏不稳定性
执行以下命令可知imu.bag的topic为imu。

rosbag info imu.bag
path: imu.bag
version: 2.0
duration: 3hr 59:59s (14399s)
start: Jun 23 2019 19:46:01.57 (1561290361.57)
end: Jun 23 2019 23:46:01.57 (1561304761.57)
size: 1.0 GB
messages: 2880001
compression: none [1344/1344 chunks]
types: sensor_msgs/Imu\ [6a62c6daae103f4ff57a132d6f95cec2]
topics: imu 2880001 msgs : sensor_msgs/Imu


方便起见,可以直接使用imu_utils/launch/16448.launch,然后将imu_topic改为imu,将imu_name改为mems。

roslaunch imu_utils mems.launch

播放数据:

rosbag play imu.bag

一段时间后,在imu_utils/data下会生成一些txt文件和yaml文件。

其中,mems_imu_param.yaml为:

%YAML:1.0
type: IMU
name: mems
Gyr:
unit: rad/s
avg-axis:
gyr_n: 2.0890432536871339e-01
gyr_w: 1.0350659865036070e-03
x-axis:
gyr_n: 2.1267688959379552e-01
gyr_w: 9.9416942028848852e-04
y-axis:
gyr_n: 2.0914260308003346e-01
gyr_w: 1.1582639020507859e-03
z-axis:
gyr_n: 2.0489348343231117e-01
gyr_w: 9.5276463717154658e-04
Acc:
unit: " m/s^2"
avg-axis:
acc_n: 2.6687745286836656e-01
acc_w: 3.5593223039378573e-03
x-axis:
acc_n: 2.6424317346164494e-01
acc_w: 4.2147930911496092e-03
y-axis:
acc_n: 2.7021759937094070e-01
acc_w: 3.1101473189795565e-03
z-axis:
acc_n: 2.6617158577251410e-01
acc_w: 3.3530265016844057e-03

修改imu_utils/scripts/draw_allan.m中txt文件的路径,然后使用Matlab运行。

(1)陀螺仪的艾伦方差曲线如下:

在这里插入图片描述

分析:陀螺仪的高斯白噪声比较准确,但bias随机游走噪声与设定值相差两个数量级,不清楚原因,可能是imu_utlis自身的问题。后面会用kalibr_allan工具标定一下。

(2)加速度的艾伦方差曲线如下:

在这里插入图片描述

分析:加速度计的高斯白噪声和bias随机游走噪声比较准确。

PS:刚发现,Sigma单位应为:m/s^2,这里先不改了,原谅我偷下懒。

4 总结
由于时间精力有限:

没有测试kalibr_allan工具(https://github.com/rpng/kalibr_allan)的性能
没有做提升作业
对艾伦方差的理解还不够深入

参考:

[1] https://blog.csdn.net/cuifeng1993/article/details/107420874?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-9.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-9.control

[2] https://blog.csdn.net/learning_tortosie/article/details/102415313

[3] https://blog.csdn.net/weixin_44580210/article/details/92846020?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-9.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromMachineLearnPai2%7Edefault-9.control

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大江东去浪淘尽千古风流人物

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值