Gazebo | Ignition | Community
Ask Your Question
0

Cannot add material when inserting from a plugin via InsertModelSDF().

asked 2013-02-05 09:27:37 -0600

AndreiHaidu gravatar image

Hi,

When I insert a model in the environment from a plugin with InsertModelSDF() and I try to give it a material, I get an error.

The code is something like this:

    std::stringstream xml;

    ...
    xml << "\t\t\t<visual name='sphere_visual_" << i << "'>\n";
    xml << "\t\t\t\t<geometry>\n";
    xml << "\t\t\t\t\t<sphere>\n";
    xml << "\t\t\t\t\t\t<radius>" << radius << "</radius>\n";
    xml << "\t\t\t\t\t</sphere>\n";
    xml << "\t\t\t\t</geometry>\n";
    //xml << "\t\t\t\t<material/>\n";
    //xml << "\t\t\t\t\t<script>\n";
    //xml << "\t\t\t\t\t\t<uri>file://media/materials/scripts/gazebo.material</uri>\n";
    //xml << "\t\t\t\t\t\t<name>Gazebo/Red</name>\n";
    //xml << "\t\t\t\t\t</script>\n";
    //xml << "\t\t\t\t</material>\n";
    xml << "\t\t\t</visual>\n";
    ...

    sdf::SDF sphereSDF;
    sphereSDF.SetFromString(xml.str());

    _parent->InsertModelSDF(sphereSDF);

If I uncomment the <material> tag I get an error and the whole model is not loaded.

Error [World.cc:1383] Unable to find a model, light, or actor in:
<sdf version='1.3'/>

Bug, or am I doing something wrong?

Thanks, Andrei

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-02-05 11:12:31 -0600

nkoenig gravatar image

I think your SDF is incorrect. Look at the start of your material XML element. It has an forward slash that shouldn't be there:

<material/>

should be

<material>
edit flag offensive delete link more

Comments

You are right, sorry for not noticing it.

AndreiHaidu gravatar imageAndreiHaidu ( 2013-02-05 16:21:19 -0600 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-02-05 09:27:37 -0600

Seen: 374 times

Last updated: Feb 05 '13