gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.18k stars 479 forks source link

NestedModels() doesn't find models in <include> tags #2139

Open osrf-migration opened 7 years ago

osrf-migration commented 7 years ago

Original report (archived issue) by Deanna Hood (Bitbucket: d_hood).


If I have an sdf with:

<!-- AGV1 -->
    <model name ="agv1">
      <pose>0.3 3.3 0 0 0 3.1415</pose>
      <include>
        <uri>model://warehouse_robot</uri>
      </include>
      <plugin name="agv_plugin" filename="libROSAGVPlugin.so">
        <submit_tray_service_name>/ariac/submit_tray</submit_tray_service_name>
        <index>1</index>
      </plugin>

      <!-- a tray for building kits -->
      <include>
        <uri>model://kit_tray</uri>
        <pose>0.0 0.15 0.75 0 0 0</pose>
      </include>

      <!-- join the tray and agv -->
      <joint name="agv_tray" type="fixed">
          <parent>warehouse_robot::link</parent>
          <child>kit_tray::tray</child>
      </joint>
    </model>

then NestedModels() on the agv1 model doesn't list kit_tray. It will only list the kit_tray model if I wrap the include in a tag. I think this is caused by this line, explicitly looking for tags

osrf-migration commented 7 years ago

Original comment by Deanna Hood (Bitbucket: d_hood).


osrf-migration commented 7 years ago

Original comment by Louise Poubel (Bitbucket: chapulina, GitHub: chapulina).


The tricky thing here is the meaning of the include tag, which is indeed confusing. As noted in the nested model tutorial, include tags, which existed before nested models, don't "nest" models. The include tag expands the contents of the given URI. So you technically, this:

<model name="A">
   <link name="modelAlink"/>
    <include>
      <uri>model://modelBuri>
    </include>
</model>

Is expanded like this:

<model name="A">
   <link name="modelAlink"/>
   <link name="modelABink"/>
</model>

As you noted, to have a nested model using the include tag, you must wrap the include in a new model tag.

I think it might be useful to add these examples to the tutorial.