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

Give parameters into included models in a SDF #1009

Open osrf-migration opened 10 years ago

osrf-migration commented 10 years ago

Original report (archived issue) by Martí Morta (Bitbucket: martimorta).


Hi, After walking around answers.gazebosim.org and google I couldn't find a way to pass parameters to an included model that modify a plugin.

I wanted to create a robot sdf including the platform and sensors, so I could reuse code. At the end I copied-pasted the sensors sdf file into the robot's sdf.

This is an example of what i wanted to do:

robot.sdf

#!xml

  <model name="robot">
    <static>0</static>
    <!-- platform -->
    <include>
      <uri>model://platform</uri>
    </include>
    <!-- laser 1 -->
    <include>
      <uri>model://laser</uri>
      <param>value 1</param>
    </include>
    <!-- laser 2 -->
    <include>
      <uri>model://laser</uri>
      <param>value 2</param>
    </include>
  </model>

I hope there's a way to do it,

Thanks!

osrf-migration commented 10 years ago

Original comment by Martí Morta (Bitbucket: martimorta).


BTW, I am using SDF 1.4, Gazebo 1.9 with ROS and the code for the model is in:

http://devel.iri.upc.edu/pub/labrobotica/ros/iri-ros-pkg/stacks/teo_robot/trunk/teo_sim/models/teo/

osrf-migration commented 10 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


The drc_vehicle model in drcsim does something similar. Will that work for you?

If so, then we should document this functionality.

osrf-migration commented 10 years ago

Original comment by Martí Morta (Bitbucket: martimorta).


Hi,

Thanks, it works well for the platform, so I get rid of the in the platform model and then I include this model and add the plugin after the tag.

It's not possible though, to do it with the laser plugin (and I suppose any sensor) since the needs to be inside and this inside as the following error suggests:

#!bash

Error [parser.cc:697] XML Element[sensor], child of element[model] not defined in SDF. Ignoring.[model]

I suppose to solve this a change in the SDF would be required..

osrf-migration commented 10 years ago

Original comment by Martí Morta (Bitbucket: martimorta).


I've just seen the imu plugin gazebo_ros_imu can be used outside the (or ), so maybe the fix should be done in the gazebo_ros_laser plugin really.

osrf-migration commented 10 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


We'd have to modify SDF to support changing plugin parameters using an . The easiest solution may be to use ERB.

osrf-migration commented 10 years ago

Original comment by Martí Morta (Bitbucket: martimorta).


Thanks for your answer Nathan, but excuse my ignorance, can you tell me what does ERB mean? Thanks

osrf-migration commented 10 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


ERB is a ruby templating system. Here is a description, and here is the API

osrf-migration commented 9 years ago

Original comment by Benjamin Blumer (Bitbucket: Benjamin_Blumer).


Did this get documented somewhere? Should this work the same for libgazebo_ros_joint_pose_trajectory.so? I was trying to use a similar method to the one Steven mentioned for the polaris model, but it didn't seem to work. There was a /set_joint_trajectory rostopic available, but it didn't seem to control the model.

osrf-migration commented 9 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


You'll have to check the source code of libgazebo_ros_joint_pose_trajectory.so to see what parameters (if any) it reads from SDF. There is no standard set of parameters that a plugin loads, so we leave documentation about parameters to the plugin itself. In this case, you'll have to look at the code of the plugin, see what parameters it loads, and how data is passed to and read from /set_joint_trajectory.

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 4 years ago

Original comment by sina (Bitbucket: sina).


Hi All,

I was looking for the same feature in SDF and, apart from the ERB-Ruby solution, I couldn't not find I couldn't find a way to pass parameters to a SDF model.

I was wondering if feature has been added to SDF fomatting?

Thx a lot