Gazebo插件为您的URDF模型提供了更强大的功能,可以连接ROS消息和传感器输出和电机输入的服务调用。
对于gazebo模型,如果不加入ROS的插件,是没法发布消息跟ROS进行通信的。
目录
Gzebo中插件类型
(http://gazebosim.org/tutorials?tut=plugins_hello_world&cat=write_plugin)
Gazebo supports several plugin types, and all of them can be connected to ROS, but only a few types can be referenced through a URDF file:
- ModelPlugins, to provide access to the physics::Model API
- SensorPlugins, to provide access to the sensors::Sensor API
- VisualPlugins, to provide access to the rendering::Visual API
Adding a ModelPlugin
In short, the ModelPlugin
is inserted in the URDF inside the <robot>
element. It is wrapped with the <gazebo>
pill, to indicate information passed to Gazebo. For example:
<robot>
... robot description ...
<gazebo>
<plugin name="differential_drive_controller" filename="libdiffdrive_plugin.so">
... plugin parameters ...
</plugin>
</gazebo>
... robot description ...
</robot>
在RRBot中的位置如下图所示
在Gazebo中加载机器人模型时,diffdrive_plugin代码将被赋予对模型本身的引用,允许它对模型进行操作。此外,它还将引用自身的SDF元素,以便读取传递给它的插件参数。
Adding a SensorPlugin
Specifying sensor plugins is slightly different. Sensors in Gazebo are meant to be attached (被链接到) to links, so the <gazebo>
element describing that sensor must be given a reference to that link. For example:
<robot>
... robot description ...
<link name="sensor_link">
... link description ...
</link>
<gazebo reference="sensor_link">
<sensor type="camera" name="camera1">
... sensor parameters ...
<plugin name="camera_controller" filename="libgazebo_ros_camera.so">
... plugin parameters ..
</plugin>
</sensor>
</gazebo>
</robot>
在Gazebo内加载机器人模型时,摄像机控制器代码将作为传感器的参考,提供对其API的访问。此外,它还将引用自身的SDF元素,以便读取传递给它的插件参数。
参考资料
http://gazebosim.org/tutorials?cat=connect_ros
http://gazebosim.org/tutorials?tut=ros_gzplugins&cat=connect_ros