0
$\begingroup$

Gazebo Answers logo

I'm using gazebo 2.1. Is it possible to load a standalone SDF model file that doesn't sit in a directory with model.config and model.sdf

For example, how to fix this code from the examples directory (factory.cc):

public: void Load(physics::WorldPtr _parent, sdf::ElementPtr /*_sdf*/)
{
_parent->InsertModelFile("file:///absolutepath/to/box.model");
...

Closely related question: This works in an sdf file, with a deprecation warning:

<include filename="/path/to/robot.model" model_pose="0 0 0 0 0 0"/>

But I can't figure out a working replacement for it, since if I use model:///path/to/robot.model, gazebo wants the argument to be a directory with model.sdf and model.config.

Edit: it seems like gazebo isn't distinguishing between uri arguments with file:// and model://


Originally posted by John on Gazebo Answers with karma: 3 on 2014-01-25

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

Hi here is a short answer for you first Question:

you can use one of the following methods of an physics::World object to load your model at runtime(World API):

void InsertModelFile (const std::string &_sdfFilename)

void InsertModelSDF (const sdf::SDF &_sdf)

void InsertModelString (const std::string &_sdfString)

So the easiest way to implement this would be to write a world plugin(or access the wolrd object from an existing plugin). And use one of those methods. I'm not sure if InsertModelFile needs an .sdf or .model file. But the API says its sdf... If you can't load the sdf directly read it from file an just put in the String content... I haven't used the first one yet but but in doupt use the later one's if you need to much time to figure out the correct behaviour of the first...

For your second question

a valid include now looks like this:

<include>
  <uri>model://gas_station</uri>
  <name>gas_station</name>
  <pose>-2.0 7.0 0 0 0 0</pose>
</include>

This assumes that you model in the defined GAZEBO_MODEL_PATH if not gazebo will search for it in the web(default path for models is .gazebo/models)

What is your problem with model.config files? There is not much code in it...

BTW if you use ros you can directly spawn models via the command line/or kaunch scripts...


Originally posted by evilBiber with karma: 881 on 2014-01-27

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by John on 2014-01-29:
Thanks. I'm happy to use the new format with model.config files but I was wondering if there's some bug, or if the authors made a change to the API to make the old method of including files invalid.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.