61
社区成员




https://classic.gazebosim.org/tutorials?tut=ros_gzplugins
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>
Upon loading the robot model within Gazebo, the diffdrive_plugin
code will be given a reference to the model itself, allowing it to manipulate it. Also, it will be give a reference to the SDF element of itself, in order to read the plugin parameters passed to it.
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>
Upon loading the robot model within Gazebo, the camera_controller
code will be given a reference to the sensor, providing access to its API. Also, it will be give a reference to the SDF element of itself, in order to read the plugin parameters passed to it.