How to get ContainPlugin to publish to /contain topic?

asked 2018-09-24 10:11:40 -0500

kump gravatar image

updated 2018-09-25 02:10:25 -0500

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 tutorial, 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

list of rostopics when I launch the world:

/clock
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/robot/joint_rear_left_wheel_controller/command
/robot/joint_rear_right_wheel_controller/command
/robot/joint_states
/rosout
/rosout_agg
/tf
/tf_static

I launch a ros_controller for the robot, so that is the /robot topics.

edit retag flag offensive close merge delete

Comments

1

Because of the namespace you defined, have you checked for the topic /gazebo/robot/contain ?

Delb gravatar image Delb  ( 2018-09-24 10:34:21 -0500 )edit

@Delb What do you mean by "check for the topic"? When I run $ rostopic list then every existing topic is printed in the terminal, right? If I do that, no topic ending with /contain shows up. Not even /gazebo/robot/contain. Is that what you meant?

kump gravatar image kump  ( 2018-09-24 10:50:52 -0500 )edit

Yes that's a common mistake I had to be sure My second guess is about the entity tag, try another value like one of your links in the urdf

Delb gravatar image Delb  ( 2018-09-24 11:40:40 -0500 )edit

I tried also robot::base_link as I saw in some tutorials. This didn't make any difference. However if I leave <namespace> tag empty, there is an error after the launch that says '//' is an invalid namespace. From which I conclude it sees the plugin tag and tries to load it.

kump gravatar image kump  ( 2018-09-24 11:47:22 -0500 )edit

From your link : In gazebo 9 and beyond the gazebo topics are removed; only the ignition transport topics are available. It's actually normal then but do you have those ignitions topics available ?

Delb gravatar image Delb  ( 2018-09-24 12:10:20 -0500 )edit

@Delb How can I find out? Is there a file to find or a command to run?

kump gravatar image kump  ( 2018-09-24 12:19:29 -0500 )edit

Can you add the output of rostopic list in your question ?

Delb gravatar image Delb  ( 2018-09-24 12:51:15 -0500 )edit

@Delb I have eddited the question and added the list of rostopics.

kump gravatar image kump  ( 2018-09-25 02:11:11 -0500 )edit