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