imu_utils標定程序

本文详细介绍了如何安装imu_utils库,设置WS工作空间,下载并构建项目,录制rosbag数据,配置imu校准参数,以及使用rosbag快速播放来校准imu。最后,步骤涉及查看校准结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

imu_utils標定程序

1. 安裝

step1:
sudo apt-get install libdw-dev

step2:建立WS文件夾


export TARTGET_WS_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib/imu_utils_workspace
mkdir -p $TARTGET_WS_DIR/src

step3: download

export TARTGET_WS_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib/imu_utils_workspace

# remove the previous files

cd $TARTGET_WS_DIR/src

git clone https://github.com/gaowenliang/code_utils
git clone https://github.com/gaowenliang/imu_utils


 


step4:build
 

export TARTGET_WS_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib/imu_utils_workspace
cd $TARTGET_WS_DIR
catkin_make

運行-----------------------------------------------------------------------------------------------------------------

step1:確保imu正確發佈

#!/bin/bash

#rostopic hz /mavros/imu/data_raw

rostopic echo /mavros/imu/data_raw

step2:錄製rosbag,一般說是最少120分鐘,但是目前imu_utils的源代碼默認你錄製200分鐘,能錄久一點就錄久一點

export TARTGET_PROJECT_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib
export TARTGET_WS_DIR=$TARTGET_PROJECT_DIR/imu_utils_workspace

export IMU_TOPIC=/mavros/imu/data_raw
export BAG_PATH=$TARTGET_PROJECT_DIR/rosbag/imu.bag
rosbag record $IMU_TOPIC -O $BAG_PATH


#rm $BAG_PATH
#rm $USB_BAG_PATH

# record at least 2 hours
rosbag record $IMU_TOPIC -O $BAG_PATH

step3:
修改以下的launch
imu_utils/launch/xsens.launch
將max_time_min修改成你錄製的時間長(分鐘)。不能長於你錄製的時間,否則會一直等待資料。

<launch>
    <node pkg="imu_utils" type="imu_an" name="imu_an" output="screen">
<!--         <param name="imu_topic" type="string" value= "/imu/data"/> -->
        <param name="imu_topic" type="string" value= "/mavros/imu/data_raw"/>
        <param name="imu_name" type="string" value= "xsens"/>
        <param name="data_save_path" type="string" value= "$(find imu_utils)/data/"/>
<!--         <param name="max_time_min" type="int" value= "200"/> -->
        <param name="max_time_min" type="int" value= "150"/>
        <param name="max_cluster" type="int" value= "100"/>
    </node>
</launch>

step4 運行標定程序,運行後會開始等待rosbag的資料

#!/bin/bash


export TARTGET_WS_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib/imu_utils_workspace



source $TARTGET_WS_DIR/devel/setup.bash

#默認imu topic是/imu/data
#如果rosbag裏記錄的不是,就要修改
#imu_utils_workspace/src/imu_utils/launch/xsens.launch

#https://blog.csdn.net/qq_49959714/article/details/129211822
# 此处可能会一直出现wait for imu data
# 这时需要修改xsens_driver.launch文件中的max_time_min的值,这个值改为小于自己的bag持续时间。
roslaunch imu_utils xsens.launch

#尽快执行rosbag play -r 200 test_imu_2020_20xx-xx-xx-xx-xx-xx.bag,
# 程序进入bag读取,并计算allan方差。当bag包加速回放完毕后,执行launch的窗口仍然会显示wait for imu data.,
# 等待一段时间计算,计算完毕后会显示计算结果。

step5 運行rosbag,速度200倍

#!/bin/bash

export TARTGET_PROJECT_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib
export TARTGET_WS_DIR=$TARTGET_PROJECT_DIR/imu_utils_workspace


export NEW_IMU_BAG=$TARTGET_PROJECT_DIR/rosbag/imu_0325_wheeltec.bag
#---------------------------------------------------------------

export IMU_TOPIC=/mavros/imu/data_raw

#export BAG_PATH=$TARTGET_PROJECT_DIR/rosbag/imu_0320_short.bag
#export BAG_PATH=$TARTGET_PROJECT_DIR/rosbag/imu_0320_long.bag

# speed x 200
rosbag play -r 200 $NEW_IMU_BAG

因爲rosbag的播放速度是200倍,運行時間就幾分鐘,如果20分鐘內沒有出結果,大概率是launch文件max_time_min寫的比rosbag的大,導致程序一直在等待資料

step 6 查看結果

#!/bin/bash


export TARTGET_WS_DIR=/home/hao/Documents/WKS_Current/camera_imu_calib/imu_utils_workspace
source $TARTGET_WS_DIR/devel/setup.bash
# imu标定内参参数将保存在imu_utils/data目录下的xsens_imu_param.yaml文件中
cat $TARTGET_WS_DIR/src/imu_utils/data/xsens_imu_param.yaml

### 使用 imu_utils 标定 IMU 参数 `imu_utils` 是一个基于 ROS 的工具包,主要用于标定惯性测量单元(IMU)的参数。以下是关于如何使用 `imu_utils` 进行 IMU 参数标定的相关说明。 #### 工具准备 在 Ubuntu 20.04 环境下,确保已安装以下依赖项: - ROS(推荐版本为 Noetic 或 Melodic) - Python 和 C++ 编译器 - 安装 `imu_utils` 软件包[^2] 可以通过以下命令克隆并编译该软件包: ```bash cd ~/catkin_ws/src/ git clone https://github.com/your-repo/imu_utils.git cd ~/catkin_ws && catkin_make source devel/setup.bash ``` #### 配置节点 启动 `imu_an` 节点以收集和分析 IMU 数据。配置文件中的关键参数包括: - **imu_topic**: 指定要订阅的 IMU 主题名称。 - **imu_name**: 给设备命名以便区分多个传感器。 - **data_save_path**: 存储数据的路径。 - **max_time_min**: 收集数据的最大时间长度(单位:分钟)。 - **max_cluster**: 数据分组的最大数量。 示例配置如下所示: ```xml <node pkg="imu_utils" type="imu_an" name="imu_an" output="screen"> <param name="imu_topic" type="string" value="/android/imu"/> <param name="imu_name" type="string" value="shoujiIMU"/> <param name="data_save_path" type="string" value="$(find imu_utils)/shoujiimu/"/> <param name="max_time_min" type="int" value="4"/> <param name="max_cluster" type="int" value="100"/> </node> ``` 上述 XML 片段定义了一个名为 `imu_an` 的节点,并设置了必要的参数来采集来自 `/android/imu` 主题的数据。 #### 启动标定过程 运行以下命令启动标定流程: ```bash roslaunch imu_utils imu_calibration.launch ``` 此命令会加载预设的 launch 文件,自动执行一系列操作以完成 IMU 参数估计。 #### 输出结果解释 标定完成后,生成的结果通常保存在一个 YAML 文件中,其结构类似于下面的例子: ```yaml # Accelerometer parameters accelerometer_noise_density: 0.020546933436785896 # Noise density (continuous-time) accelerometer_random_walk: 0.0010213093603518382 # Bias random walk # Gyroscope parameters gyroscope_noise_density: 0.0019035698029406516 # Noise density (continuous-time) gyroscope_random_walk: 1.9530927686562762e-05 # Bias random walk rostopic: /imu # The IMU ROS topic update_rate: 200.0 # Hz (for discretization of the values above) ``` 这些参数描述了加速度计和陀螺仪的噪声特性以及更新频率等重要信息[^3]。 #### 示例代码片段 为了进一步验证标定后的性能,可以编写简单的测试脚本读取 YAML 文件并将结果打印出来: ```python import yaml def load_imu_params(file_path): with open(file_path, 'r') as file: params = yaml.safe_load(file) acc_noise = params['accelerometer_noise_density'] gyro_noise = params['gyroscope_noise_density'] print(f'Accelerometer noise density: {acc_noise}') print(f'Gyroscope noise density: {gyro_noise}') if __name__ == "__main__": path_to_yaml = '/path/to/imu.yaml' load_imu_params(path_to_yaml) ``` 通过以上步骤即可实现对 IMU 参数的有效标定---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值