How to get ContainPlugin to publish to /contain topic?

asked 2018-09-21 05:58:12 -0600

kumpakri gravatar image

I need to get an information about robot entering certain area (or leaving the inverted selection of the area). I found two Gazebo plugins, who looks like they could do the job.

  1. ContainPlugin
  2. SimEventsPlugin with OccupiedEvent

Both of them are world plugins. I added the ContainPlugin into my .world file as shown below:

<sdf version='1.6'>
  <world name='garden'>

    <light name='sun' type='directional'>
      <cast_shadows>1</cast_shadows>
      <pose frame=''>0 0 10 0 -0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
    </light>

    <include>
      <uri>model://ground_plane</uri>
    </include>

    <state world_name='garden'>
      <sim_time>1824 398000000</sim_time>
      <real_time>249 951103745</real_time>
      <wall_time>1537343867 753122405</wall_time>
      <iterations>244417</iterations>

      <model name='ground_plane'>
        <pose frame=''>0 0 0 0 -0 0</pose>
        <scale>1 1 1</scale>
        <link name='link'>
          <pose frame=''>0 0 0 0 -0 0</pose>
          <velocity>0 0 0 0 -0 0</velocity>
          <acceleration>0 0 0 0 -0 0</acceleration>
          <wrench>0 0 0 0 -0 0</wrench>
        </link>
      </model>

      <light name='sun'>
        <pose frame=''>0 0 10 0 -0 0</pose>
      </light>
    </state>

    <plugin name="ContainPlugin" filename="libContainPlugin.so">
      <enabled>true</enabled>
      <entity>robot</entity>
      <namespace>gazebo/robot</namespace>
      <pose>15.4 0 2 0 0 0</pose>
      <geometry>
        <box>
          <size>15 4 6</size>
        </box>
      </geometry>
    </plugin>

  </world>
</sdf>

I import the world from a launch file. I also spawn the robot from a launch file. How I understand the http://gazebosim.org/tutorials?tut=co...link text, after launching the world, a new topic /contain should be created and I should see it when using rostopic list command.

However, no such thing happens. The world launches without error or anything missing, just the topic doesn't exist. How can I make it work?

edit retag flag offensive close merge delete