相机+imu标定,在plvins上运行

目录

1.标定imu

2.标定相机

3.imu和相机联合标定

4.realsenseD455配置


1.标定imu

使用imu_utils对imu进行标定

sudo apt-get install libdw-dev
download required code_utils

创建一个catkin_ws空文件再创建src

在src目录下git clone https://github.com/gaowenliang/code_utils

返回上一级src目录catkin_make

扫描二维码关注公众号,回复: 17220322 查看本文章
  1. 问题1:fatal error: backward.hpp: 没有那个文件或目录
  • 方案一:把src/code_utils/CMakeList.txt中,添加路径:(首选)include_directories(“include/code_utils”

    方案二:把src/code_utils/src/sumpixel_test.cpp中的#include "backward.hpp"改为#include “code_utils/backward.hpp”

    方案三:把src/code_utils/include/backward.hpp文件扔到src/code_utils/src中

3)安装imu_utils

安装方式与2)相同,到src目录下

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

再catkin_make

  1. 完成标定库的编译开始录制数据
    1. 首先运行自己的imu并且发布sensor_msg/imu
    2. rosbag record -O xxx.bag topic-name#注-O表示生成的bag名字不带时间戳
  2. 开始标定
    1. 更改launch文件,加粗字体需要更改
      1. 打开./carkin_ws/src/imu_utils-master/launch/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_topic:表示自己录制的imu话题名字

imu_name:自己的imu名字,可以随便取,最后标定数据的结果也会根据这个保存。

data_save_path:表示存放的目录,默认在imu_utils/data下,找到相应的yaml 即可查看标定的结果。

max_time_min:取数据的时长,一般默认120分钟,程序会在最大时间截断读取 数据

roslaunch imu_utils A3.launch#更改好A3.launch之后也可以自己改名

rosbag play -r 200 imu_A3.bag#运行自己的imu.bag

如果你没有更改保存路径./carkin_ws/src/imu_utils-master/data下保存了你的imu标定的结果。比如:

2.标定相机

  1. 录制你的bag文件

1)首先连接你的摄像头通过rostopic得到话题/usb_cam/image_raw

rosbag record -O xxx.bag topic-name#录制一个文件

2)之后播放话题,并且同时完成录制新话题

#这一步讲你讲要收到的话题改为4赫兹发送并且话题改名/usb_cam/image_raw_throttle

rosrun topic_tools throttle messages /usb_cam/image_raw 4.0

#运行上面的话题,同时录制新的bag

rosbag play xxx.bag   同时运行 rosbag record -O xxx.bag /usb_cam/image_raw_throttle

录制要求:

保证图像能够涵盖整个棋盘格

分别在x,y,z轴上进行充分平移,各来回三次

分别在x,y,z轴上进行充分旋转,各三次

  1. 下载.yaml文件,按照自己的板子修改

官网:https://github.com/ethz-asl/kalibr/wiki/downloads

target_type: 'aprilgrid' #gridtype

tagCols: 6               #number of apriltags

tagRows: 6               #number of apriltags

tagSize: 0.088           #size of apriltag, edge to edge [m]

tagSpacing: 0.3          #ratio of space between tags to tagSize

               #example: tagSize=2m, spacing=0.5m --> tagSpacing=0.25[-]

%YAML:1.0

---

type: IMU

name: ch100

Gyr:

   unit: " rad/s"

   avg-axis:

      gyr_n: 1.5251602268499464e-03

      gyr_w: 1.0405618221734089e-04

   x-axis:

      gyr_n: 2.2137294224712873e-03

      gyr_w: 1.5958962007417895e-04

   y-axis:

      gyr_n: 1.0643431567029509e-03

      gyr_w: 6.8623761076836451e-05

   z-axis:

      gyr_n: 1.2974081013756012e-03

      gyr_w: 8.3955165501007259e-05

Acc:

   unit: " m/s^2"

   avg-axis:

      acc_n: 3.3789328041507104e-02

      acc_w: 2.0664358067633650e-03

   x-axis:

      acc_n: 1.9670094288014223e-02

      acc_w: 1.4135701237766908e-03

   y-axis:

      acc_n: 2.3605154389329266e-02

      acc_w: 1.6841663462252101e-03

   z-axis:

      acc_n: 5.8092735447177815e-02

      acc_w: 3.1015709502881946e-03

4)开始运行

进入你的kalibr_workspace

source ./devel/setup.bash

rosrun kalibr kalibr_calibrate_cameras --target ./april_6x6_80x80cm.yaml --bag ./runcamer.bag --models pinhole-radtan --topics /usb_cam/image_raw_throttle

--bag你的bag位置

--target 标定板配置文件 需要自己修改yaml文件

--topics 订阅的topics

--models 你的相机模型pinhole表示针孔相机

相机模型:https://github.com/ethz-asl/kalibr/wiki/supported-models

运行完成后会在你的工作空间生成3个文件!

问题:

存在以下内容:

import igraph

raise RuntimeError("This package is deprecated. See the deprecation notice above.")

RuntimeError: This package is deprecated. See the deprecation notice above.

解决:https://github.com/ethz-asl/kalibr/issues/466

sudo pip uninstall igraph

sudo apt install python-igraph #可以解决问题

3.imu和相机联合标定

1、和之前相机标定其实已经类似了,这里在开始需要注意,官网推荐我们相机的频率在20HZ而IMU的频率在200HZ时效果最好(之前测试使用400HZ相机4hz出现无法优化的问题)

rosrun topic_tools throttle messages /usb_cam/image_raw 20.0

#imu更具厂商说明更改频率,如果你的频率已经高于200HZ你可以直接更改话题的频率,如果低于则需要设置

2、创建一个yaml文件如下:更具之前imu标定的结果更改

#Accelerometers

accelerometer_noise_density: 3.39e-02   #Noise density (continuous-time)

accelerometer_random_walk:   2.07e-04   #Bias random walk



#Gyroscopes

gyroscope_noise_density:     1.53e-03   #Noise density (continuous-time)

gyroscope_random_walk:       1.04e-05   #Bias random walk



rostopic:                    /IMU_data   #the IMU ROS topic

update_rate:                 200.0      #Hz (for discretization of the values above)

之后录制你的bag,

rosbag record -O ../imu_camer.bag 相机话题 imu话题

3、录制的bag放入工作空间下

source一下之后输入,等待一段时间

rosrun kalibr kalibr_calibrate_imu_camera --target ./april_6x6_80x80cm.yaml --cam ./realsense_camer.yaml --imu ./realsense_imu.yaml --bag ./D455.bag 

标定D455

rosrun kalibr kalibr_calibrate_imu_camera --target ./april_6x6_80x80cm.yaml --cam ./runcamer-camchain.yaml --imu ./imu.yaml --bag ./imu_camer.bag 

4.realsenseD455配置

教程:https://ispacesoft.com/61979.html

  1. ubuntu安装sdk2.0库
    1. https://github.com/IntelRealSense/librealsense/blob/master/doc/distribution_linux.md
  2. realsense-ros的安装编译
    1. https://github.com/IntelRealSense/realsense-ros/tree/ros1-legacy
    2. roslaunch realsense2_camer lett...(自己重新写了个launch文件)
  3. 更改imu话题并且合并加速度和陀螺仪话题
    1. Realsense-D455的IMU在ubuntu18.04使用_王不偏的博客-CSDN博客_d455链接后没有imu数据
  4. 设置结构光(双目才需要)
rosrun rqt_reconfigure rqt_reconfigure

点击stereo_model,emitted_enabled下拉关闭。

/camera/infra1/image_rect_raw为左相机

/camera/infra2/image_rect_raw为右相机

猜你喜欢

转载自blog.csdn.net/HHB791829200/article/details/128230574