How to get ContainPlugin to publish to /contain topic?
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.
- ContainPlugin
- 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.
Because of the namespace you defined, have you checked for the topic
/gazebo/robot/contain
?@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?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 urdfI 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.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 How can I find out? Is there a file to find or a command to run?
Can you add the output of
rostopic list
in your question ?@Delb I have eddited the question and added the list of rostopics.