本文环境是ROS-Melodic,参考https://www.ncnynl.com/archives/201610/1045.html
https://blog.csdn.net/qintianhaohao/article/details/104286927
1. YAML配置文件(pointcloud)
在pr2包config目录下新建sensor_realsense_pointcloud.yaml文件,输入
sensors:
- sensor_plugin: occupancy_map_monitor/PointCloudOctomapUpdater
point_cloud_topic: /camera/depth_registered/points
max_range: 5.0
point_subsample: 1
padding_offset: 0.1
padding_scale: 1.0
filtered_cloud_topic: filtered_cloud
深度图形式的yaml文件可根据链接1创建
2. 修改launch文件
修改launch目录下的sensor_manager.launch.xml文件(建议作一下备份)
<launch>
<!-- This file makes it easy to include the settings for sensor managers -->
<!-- Params for 3D sensors config -->
<rosparam command="load" file="$(find pr2_moveit_config_new)/config/sensors_realsense_points.yaml" />
<!-- Params for the octomap monitor -->
<!-- <param name="octomap_frame" type="string" value="some frame in which the robot moves" /> -->
<param name="octomap_resolution" type="double" value="0.025" />
<param name="max_range" type="double" value="5.0" />
<!-- Load the robot specific sensor manager; this sets the moveit_sensor_manager ROS parameter -->
<arg name="moveit_sensor_manager" default="pr2" />
<include file="$(dirname)/$(arg moveit_sensor_manager)_moveit_sensor_manager.launch.xml" />
<node pkg="tf2_ros" type="static_transform_publisher" name="camera_broadcaster_0" args="0 0 0 0 0 0 odom_combined camera_link" />
</launch>
记得将$(find pr2_moveit_config_new)中pr2_moveit_config_new换成你自己的pr2包名。
3. 运行与结果
首先启动相机
roslaunch realsense2_camera rs_rgbd.launch
再启动机器人仿真环境
roslaunch pr2_moveit_config_new demo.launch
效果如图
其中tf坐标系变换可以修改一下