从零写VIO|第二节——作业:使用Allen方差工具标定IMU

作业内容

在这里插入图片描述
在IMU采集数据时,会产生两种误差:确定性误差和随机性误差,为获得精确的数据,需要对上述两种误差进行标定。

1、确定性误差

确定性误差主要包括bias(偏置)、scale(尺度)、**misalignment(坐标轴互相不垂直)**等多种。常使用六面静置法标定加速度计和陀螺仪的确定性误差。

2、随机误差

随机误差主要包括:高斯白噪声、bias随机游走(bias的导数)。加速度计和陀螺仪随机误差的标定通常使用Allan方差法,Allan方差法是20世纪60年代由美国国家标准局的David Allan提出的基于时域的分析方法。

在这里插入图片描述
在这里插入图片描述

IMU标定Allan方差工具:
常用的Allan方差工具,主要有以下两种:
https://github.com/gaowenliang/imu_utils
https://github.com/rpng/kalibr_allan

  • 下面是imu_utils的主页,可以下载代码,也有使用步骤
    https://github.com/gaowenliang/imu_utils
    可以下载imu_utils主页最后面提供的数据集。

在这里插入图片描述
首先安装ROS——指路 https://blog.csdn.net/weixin_40224537/article/details/105520833
安装ceres-solver

1 安装im_utils

1.1. 安装依赖:
sudo apt-get install libdw-dev
1.2 编译

先编译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.3 可能出的错误

错误一 路径错误:

imu-calibration/src/code_utils/src/sumpixel_test.cpp:2:10: fatal error: backward.hpp: 没有那个文件或目录
 #include "backward.hpp"
          ^~~~~~~~~~~~~~
compilation terminated.

解决办法:
在CMakeLists.txt中加入包含路径:include_directories( "include/code_utils")
再次catkin_make,即可成功。

错误2: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>

2. 运行

2.1 采集IMU数据

参考资料
让IMU静止不动两个小时,录制IMU的bag.~~

cd MYNT-EYE-D-SDK
source wrappers/ros/devel/setup.bash
roslaunch mynteye_wrapper_d display.launch
rosbag record /mynteye/imu/data_raw -O imu.bag

两个小时以后按Ctrl+C完成录制。

2.2 生成imu.bag

【提醒!!!】记得另外开一个终端运行roscore
将贺老师给的vio_data_simulation-ros_version放在~/imu-calibration/src

XXX/vio_data_simulation-ros_version/src/gener_alldata.cpp中修改文件的路径:

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

进行编译:

cd ~/imu-calibration
catkin_make

出现类似下图的错误:
在这里插入图片描述
解决办法:

// 在出错文件内imu.cpp包含万能的头文件:
#include<bits/stdc++.h>

出现下图即成功:
在这里插入图片描述环境变量

source  ./devel/setup.bash

这儿可能用source devel/setup.bash依然会报找不到功能报的错误,所以加上./
自此生成了一个节点,可以生成一个imu.bag的包
运行

roscore
cd ~/imu-calibration/devel/lib/vio_data_simulation
rosrun vio_data_simulation vio_data_simulation_node

运行完之后在此文件夹下就生成了imu.bag的包(模拟imu的采集数据)
这个bag包就是模拟的IMU采集数据,于是我们使用这个数据,进行下面的实验——生成allen方差计算:

2.3 新建imu.launch文件

进入imu-calibration/src/imu_utils/launch 文件夹,新建imu.launch文件:

<launch>
    <node pkg="imu_utils" type="imu_an" name="imu_an" output="screen">
        <param name="imu_topic" type="string" value= "/imu"/>
        <param name="imu_name" type="string" value= "imutest"/>
        <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

然后,运行(在~/imu-calibration/devel/lib/vio_data_simulation文件夹下)

2.4 播放数据
rosbag play -r 200 imu.bag

在这里插入图片描述

2.5 启动节点

(此终端与roscore终端共同并行运行)

roslaunch imu_utils imu.launch

在这里插入图片描述
在imu-calibration/src/imu_utils/data文件夹下,会生成16个txt文件:

在这里插入图片描述

3. 绘制Allan方差图

接下来,去画出来这些方差图,在scripts下有很多matlab的脚本文件.

  1. 修改 imu_utils/scripts/draw_allan.m中文件路径:

  2. 由于ubuntu上还没装matlab,因此我把这程序和txt文件放到windows下的matlab去运行,网址:https://www.tutorialspoint.com/execute_matlab_online.phphttps://octave-online.net/

在这里插入图片描述
在这里插入图片描述
根据Allan方差图即可读出相应的误差。

可在如下路径中修改测试IMU仿真参数:

/home/ubuntu/imu-calibration/src/vio_data_simulation-ros_version/src/param.h
// noise

double gyro_bias_sigma = 0.00001;  // 零偏稳定性,运行中缓慢变化

double acc_bias_sigma = 0.0001;     // 零偏稳定性,运行中缓慢变化

double gyro_noise_sigma = 0.025;    // rad/s  测量噪声

double acc_noise_sigma = 0.029;      // m/(s^2)  测量噪声

4. 编译vio_data_simulation-master

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

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

cd ../python_tool
python draw_trajcory.py

【遇到error以及解决办法】——指路

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

(1)欧拉法效果

在这里插入图片描述
(2)中值法效果

5. 实验结果分析

参考资料

附:vio学习第二节代码运行教程

1. 安装根据官方教程安装ros
2. 打开终端执行
mkdir ros_workspace
cd ros_workspace
mkdir src

ros_workspace文件夹就是你的工作空间…(本博客中实际工作空间可以在imu-calibration/src)
3. 将文件夹vio_data_simulation-ros_version放入刚刚新建的~/ros_workspace/src文件夹里面
4. 编译

cd ~/ros_workspace
catkin_make
  1. 打开vio_data_simulation-ros_version/src/param.h可以设置参数
  2. 执行
source devel/setup.bash
rosrun vio_data_simulation gener_alldata.cpp

出现错误:
在这里插入图片描述
解决办法:

 cd ‘gener_alldata.cpp所在的文件夹’
 chmod +x gener_alldata.cpp

运行后再执行rosrun,出现错误:
lldata.cpp: 行 9: 未预期的符号 `(’ 附近有语法错误

发布了38 篇原创文章 · 获赞 0 · 访问量 1511

猜你喜欢

转载自blog.csdn.net/weixin_40224537/article/details/105520053
今日推荐