前言
需要使用點雲信息,因此需要在gazebo中添加深度相機。
模型下載
這裏使用了kinect相機模型,也即主要使用openni_description
這個功能包。
下載地址:https://github.com/ros-drivers/openni_camera
下載解壓後,將openni_description
放到目標位置即可。
如果要使用kinect, 可以進一步查看https://wiki.ros.org/openni_camera,瞭解相關話題。
加載使用
可以看到,上面下載的功能包是indigo
版本的,因此需要進行適當的修改。
- 更改M_PI爲pi
在openni_description/model/kinect.urdf.xacro
及openni_description/model/kinect_gazebo.urdf.xacro
中,有些計算使用了${M_PI}
,在kinetic版本中,應當改爲${pi}
http://wiki.ros.org/urdf/Tutorials/Using%20Xacro%20to%20Clean%20Up%20a%20URDF%20File#Math - 修改xacro標籤
在openni_description/model/kinect.urdf.xacro
中使用了<sim_3dsensor_kinect/>
,將其改爲<xacro:sim_3dsensor_kinect/>
- 使用kinect
在目標URDF中添加相關include
及使用即可
<xacro:include filename="$(find openni_description)/model/kinect.urdf.xacro" />
<xacro:sensor_kinect parent="tool0"
cam_px="-0.2" cam_py="0" cam_pz="0"
cam_or="0" cam_op="${-pi/2}" cam_oy="0" />
其他
其他類型的深度相機,在仿真時也都可以使用kinect的openni_description/model/kinect_gazebo.urdf.xacro
這個文件
http://gazebosim.org/tutorials/?tut=ros_depth_camera#CreateaGazeboModelwithaDepthCameraPlugin
In this tutorial, you’ll be using the generic “Openni Kinect” plugin. You can (and should) use this plugin for other types of depth cameras besides the Kinect (it’s an older plugin, and so it retains its old name).
主要是注意<gazebo reference="camera_link">
,reference
修改成對應的相機link,參考
https://blog.csdn.net/qq_36122936/article/details/90916304
另外,相機插件參數標籤可以參見:
http://gazebosim.org/tutorials/?tut=ros_depth_camera#CreateaGazeboModelwithaDepthCameraPlugin
http://gazebosim.org/tutorials?tut=ros_gzplugins&cat=connect_ros#OpenniKinect