Home | Tutorials | Wiki | Issues
Ask Your Question
0

How to Programmatically Create SDF models/files

asked 2014-01-16 11:23:06 -0500

isura gravatar image

I want to create SDF files programmatically. The sdformat code has some examples https://bitbucket.org/osrf/sdformat

What is the best way to do this? Is there an example of programmatically generating an SDF?

Is the following the only way to do this?

// Set up a simple sdf model file
std::ostringstream stream;
stream << "<sdf version='1.3'>"
       << "<model name='test_model'>"
       << "  <pose>0 1 2  0 0 0</pose>"
       << "  <static>false</static>"
       << "</model>"
       << "</sdf>";
sdf::SDF sdfParsed;
sdfParsed.SetFromString(stream.str());

I was thinking something like:

sdf::SDFPtr robot(new sdf::SDF());
sdf::init(robot);
robot->root->AddElement("model");
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-01-16 17:38:38 -0500

nkoenig gravatar image

Both of the examples you gave are valid.

Here is the API for SDF elements.

This function has many example uses.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

2 followers

Stats

Asked: 2014-01-16 11:23:06 -0500

Seen: 1,889 times

Last updated: Jan 16 '14