ROS学习笔记之——使用带有ROS的Gazebo插件

Gazebo插件为您的URDF模型提供了更强大的功能,可以连接ROS消息和传感器输出和电机输入的服务调用。

对于gazebo模型,如果不加入ROS的插件,是没法发布消息跟ROS进行通信的。

目录

Gzebo中插件类型

Adding a ModelPlugin

Adding a SensorPlugin

参考资料


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:

扫描二维码关注公众号,回复: 10241124 查看本文章
  1. ModelPlugins, to provide access to the physics::Model API
  2. SensorPlugins, to provide access to the sensors::Sensor API
  3. 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

发布了237 篇原创文章 · 获赞 254 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/gwplovekimi/article/details/104335190