前言
这是我的本科毕业设计相关
嗯。。。网上没找到开源的项目只有理论知识和论文,因此记录一下自己做的过程。
太懒了,一开始使用的zed2相机,融合已经成功了,但是后面才发现zed2相机是双目原理生成深度图像,在无光环境无法使用,紧急换了d435i 。使用只有相机话题改了一下,其余过程一样,所以懒得改过程记录了。
相机与二维激光雷达融合
ROS的depthimage_to_laserscan包挺好的
下载depthimage_to_laserscan
mkdir -p ~/depth2laser_ws/src
cd ~/depth2laser_ws/src
git clone https://github.com/ros-perception/depthimage_to_laserscan.git
cd ..
catkin_make
测试深度图转换
#运行相机 (需要相机驱动)
roslaunch zed_wrapper zed2.launch
#运行深度图转换
rosrun depthimage_to_laserscan depthimage_to_laserscan image:=/zed2/zed_node/depth/depth_registered
#打开rviz观察
rosrun rviz rviz
添加laserscan仍旧无法显示,rviz报错找不到[camera_depth_frame],那就给rviz一个tf
rosrun tf static_transform_publisher 0 0 0 0 0 0 1 map camera_depth_frame 10
可以正常显示
然后我添加了一个launch文件放在了deptn2laser_ws/src/depthimage_to_laserscan/launch文件夹下
zed2_depthimage_to_laserscan.launch文件内容
<launch>
<node pkg="depthimage_to_laserscan" type="depthimage_to_laserscan" name="depthimage_to_laserscan" output="screen">
<remap from="image" to="/camera/depth/image_rect_raw" />
<!--激光扫描的帧id。对于来自具有Z向前的“光学”帧的点云,该值应该被设置为具有X向前和Z向上的相应帧。-->
<param name="output_frame_id" value="/laser"/>
<!--用于生成激光扫描的像素行数。对于每一列,扫描将返回在图像中垂直居中的那些像素的最小值。-->
<param name="scan_height" value="220" />
<!--返回的最小范围(以米为单位)。小于该范围的输出将作为-Inf输出。-->
<param name="range_min" value="0.45" />
<!--返回的最大范围(以米为单位)。大于此范围将输出为+ Inf。-->
<param name="range_max" value="2.00" />
</node>
</launch>
后面可以直接运行
roslaunch depthimage_to_laserscan zed2_depthimage_to_laserscan.launch
相机+雷达
zed2相机见ubuntu18.04 ZED2相机标定
#打开相机
source ~/zed_ws/devel/setup.bash
roslaunch zed_wrapper zed2.launch
#打开d435i
source ~/realsense_ws/devel/setup.bash
roslaunch realsense2_camera rs_camera.launch
雷达和后面的运行cartographer见思岚A2 运行cartographer
#打开雷达
source ~/rplidar/devel/setup.bash
roslaunch rplidar_ros rplidar_lidar.launch
代码还是不放了,我就是个菜鸡本科生,虽然融合是我自己写的,但是就是简单的融合罢了,没有滤波之类的精细操作。
#运行修改后的depthimage_to_laserscan
source ~/fusion_camera_lidar/devel/setup.bash
roslaunch depthimage_to_laserscan zed2_depthimage_to_laserscan.launch
#运行cartographer
source ~/carto_ws/install_isolated/setup.bash
roslaunch cartographer_ros demo_revo_lds.launch
还有最后一个问题需要注意,为了方便后续代码调试,录制数据集需要将/tf /tf_static这两个话题也同时录制,否则最后建图结果可能会偏移。