ROS学习|ubuntu 18.04 下 D435i SDK安装 ros-wapper安装 绘制rosbag 运行vins-mono离线/在线

1、参考blog 1、D435i ----- Ubuntu18.04使用D435i运行VINS-Mono
2、RealSenseD435i (一):Ubuntu18.04 下的安装、使用和bag录制 ,且解决 undefined symbol 问题(最简单的方法)
3、ROS melodic kernel 4.18安装使用realsense D435i
4、RealSense D435i在Ubuntu18下配置过程
5、REALSENSE D435I数据录制 VINS离线运行
6、Ubuntu16.04使用D435i摄像头测试VINS-Mono上(基于ROS)
给相机刷固件
2、安装D435i需要的SDK启动配置文件和ROS下运行的功能包ros wapper 使用SDK和ros wapper的版本如下
两个版本要对应,不然出大问题
2.2.20 ros wapper 和 LibRealSense v2.40.0
2.1 安装SDK
在home路径下创建D435i的文件夹存储SDK 然后用Git下载到此文件
2.1.1 下载安装包

cd ~ mkdir D435i cd D435i git clone -b v2.40.0 https://github.com/IntelRealSense/librealsense.git

2.1.2 安装依赖
sudo apt-get install libudev-dev pkg-config libgtk-3-dev sudo apt-get install libusb-1.0-0-dev pkg-config sudo apt-get install libglfw3-dev sudo apt-get install libssl-dev

2.1.3 Install Intel Realsense permission scripts located in librealsense source directory:
sudo cp config/99-realsense-libusb.rules /etc/udev/rules.d/ sudo udevadm control --reload-rules && udevadm trigger

2.1.4 编译
cd librealsense mkdir build cd build cmake ../ -DBUILD_EXAMPLES=true make -j8 sudo make install

2.1.5 看看效果 进入/librealsense/build/examples/capture,试一下效果,或者另外打开一个窗口,输入realsense -reviewer
cd examples/capture ./rs-capture

ROS学习|ubuntu 18.04 下 D435i SDK安装 ros-wapper安装 绘制rosbag 运行vins-mono离线/在线
文章图片

2.1 安装Ros wapper
ros wapper for D435i 是一个基于ros的功能包,所以需要先配置一下 ros环境
2.1.1 创建ros环境
cd ~ mkdir-p realsense_ws/src catkin init

2.1.2 下载wapper资源 这里除了下载realsense_ros还需要下载一个DDynamic_reconfigure,因为缺少这个包的东西
cd realsense_ws/src git clone -b v2.2.20https://github.com/IntelRealSense/realsense-ros.git git clone https://github.com/pal-robotics/ddynamic_reconfigure.git

2.1.3 编译
cd .. catkin_make

不出意外这里应该没有坑,编译会成功
2.1.4 测试
roslaunch realsense2_camera rs_camera.launch

在另外一个窗口查看其话题输出
rostopic list

打开后,ROS将会接收到以下话题:
/camera/color/camera_info
/camera/color/image_raw
/camera/depth/camera_info
/camera/depth/image_rect_raw
/camera/extrinsics/depth_to_color
/camera/extrinsics/depth_to_infra1
/camera/extrinsics/depth_to_infra2
/camera/infra1/camera_info
/camera/infra1/image_rect_raw
/camera/infra2/camera_info
/camera/infra2/image_rect_raw
/camera/gyro/imu_info
/camera/gyro/sample
/camera/accel/imu_info
/camera/accel/sample
/diagnostics
说明安装成功~
3、录制rosbag方便后续程序调试 因为是D435i,不仅能采集RGB-D图像,而且内置了IMU,采集角速度和线加速度。所以我们使用rosbag来捕获其输出的rgb和IMU信息。
3.1 修改相机启动参数文件
  • 第一处,修改unite_imu_method为copy
  • 并将enable_gyro和enable_acce参数修改为true
  • 这样才能让IMU的角速度和加速度作为一个topic输出,输出的话题为/camera/imu


  • 第二处,修改enable_sync参数为true,这里是开相机和IMU的同步

检验输出话题是否含有/camera/imu
roslaunch realsense2_camera rs_camera.launch rostopic list

话题如下:
/camera/accel/imu_info
/camera/color/camera_info
/camera/color/image_raw
/camera/depth/camera_info
/camera/depth/image_rect_raw
/camera/extrinsics/depth_to_color
/camera/gyro/imu_info
/camera/imu
/camera/motion_module/parameter_descriptions
/camera/motion_module/parameter_updates
/camera/realsense2_camera_manager/bond
/camera/rgb_camera/auto_exposure_roi/parameter_descriptions
/camera/rgb_camera/auto_exposure_roi/parameter_updates
/camera/rgb_camera/parameter_descriptions
/camera/rgb_camera/parameter_updates
/camera/stereo_module/auto_exposure_roi/parameter_descriptions
/camera/stereo_module/auto_exposure_roi/parameter_updates
/camera/stereo_module/parameter_descriptions
/camera/stereo_module/parameter_updates
/diagnostics
/rosout
/rosout_agg
/tf
/tf_static
3.2 rosbag录制
一方面连接相机、发布数据:
roslaunch realsense2_camera rs_camera.launch

另一方面录制想要的topic,正好还可以将不需要的数据剔除:
rosbag record /camera/imu /camera/color/image_raw -o ~/camImu.bag

停止录制 按ctrl c,文件会保存在home目录下,使用 rosbag info ~/camImu.bag可以解析bag文件信息
4、D435i运行vins-mono在线 4.1 修改VINS相关参数 在realsense_color_config.yaml基础上修改订阅的topic:
#common parameters
imu_topic: “/camera/imu”
image_topic: “/camera/color/image_raw”
修改相机内参,IMU到相机的外参标定选择2,让程序自己在线标定吧:
# Extrinsic parameter between IMU and Camera. estimate_extrinsic: 0# 0Have an accurate extrinsic parameters. We will trust the following imu^R_cam, imu^T_cam, don't change it. # 1Have an initial guess about extrinsic parameters. We will optimize around your initial guess. # 2Don't know anything about extrinsic parameters. You don't need to give R,T. We will try to calibrate it. Do some rotation movement at beginning. #If you choose 0 or 1, you should write down the following matrix.

IMU参数,这里全都使用默认值
#imu parametersThe more accurate parameters you provide, the better performance acc_n: 0.2# accelerometer measurement noise standard deviation. #0.2 gyr_n: 0.05# gyroscope measurement noise standard deviation.#0.05 acc_w: 0.02# accelerometer bias random work noise standard deviation.#0.02 gyr_w: 4.0e-5# gyroscope bias random work noise standard deviation.#4.0e-5 g_norm: 9.81# gravity magnitude

realsense d435i说是已经做好了硬件同步所以不需要在线估计同步时差(但是用kalibr标定出来和在线估计出来都存在大概-0.06的时间差):
#unsynchronization parameters estimate_td: 0# online estimate time offset between camera and imu td: 0.000# initial value of time offset. unit: s. readed image clock + td = real image clock (IMU clock)

相机曝光方式应为全局曝光:
#rolling shutter parameters rolling_shutter: 0# 0: global shutter camera, 1: rolling shutter camera rolling_shutter_tr: 0# unit: s. rolling shutter read out time per frame (from data sheet).

然后就可以运行了:
roslaunch realsense2_camera rs_camera.launch roslaunch vins_estimator realsense_color.launch roslaunch vins_estimator vins_rviz.launch

来一张效果图:
5、离线运行vins 由于在3中录制了rosbag,其中包含imu和image信息,所以可以直接拿来用
直接运行了:
roslaunch vins_estimator realsense_color.launch roslaunch vins_estimator vins_rviz.launch rosbag play~/camImu.bag

【ROS学习|ubuntu 18.04 下 D435i SDK安装 ros-wapper安装 绘制rosbag 运行vins-mono离线/在线】over

    推荐阅读