andreasBihlmaier / gazebo2rviz

Automatically import all entities simulated in ROS-enabled Gazebo or described in a set of SDF files into rviz through the TF and Marker plugin. Furthermore add objects from a SDF as MoveIt collision objects.
http://wiki.ros.org/gazebo2rviz
65 stars 43 forks source link

Can't use <name> tag in ros launch file #13

Closed raabuchanan closed 4 years ago

raabuchanan commented 5 years ago

I want to spawn multiple copies of a model from a launch file so I am using name tag like so:

<include>
        <uri>model://ros_package/models/my_model</uri>
        <name>UniqueName1</name>
        <pose>3.0 0.0 -0.3 0.0 0.0 0.0</pose>
</include>

But if I use the name tag then gazebo2rviz doesn't work and the model isn't visible in rviz. gazebo2marker doesn't publish anything. Removing the tag fixes the issues but then I can only have one copy of the model in a world at a time.

andreasBihlmaier commented 4 years ago

gazebo used to automatically name included models without an explicit <name> tag to model_1, model_2, etc. This seems to be no longer the case. One must explicitly set unique names now. gazebo2rviz relies on included model names being identical to the model name (as specified in the uri) except the _n suffix above.

Thus the following works:

<?xml version="1.0" ?>
<sdf version="1.5">
  <world name="default">
    <!-- A global light source -->
    <include>
      <uri>model://sun</uri>
    </include>
    <!-- A ground plane -->
    <include>
      <uri>model://ground_plane</uri>
    </include>

    <include>
      <uri>model://beer</uri>
      <pose>0 0 0  0 0 0</pose>
      <name>beer_1</name>
    </include>

    <include>
      <uri>model://beer</uri>
      <pose>1 0 0  0 0 0</pose>
      <name>beer_2</name>
    </include>

    <include>
      <uri>model://beer</uri>
      <pose>0 2 0  0 0 0</pose>
      <name>beer_3</name>
    </include>
  </world>
</sdf>

Screenshot_20200512_142129

Background: The topic /gazebo/model_states only provides the instantiated model name, but no information about the model origin (e.g. uri), thus gazebo2rviz has to rely on such naming conventions to work.