Gazebo | Ignition | Community
Ask Your Question

Autofill for Pose for different links of a model, is it possible?

asked 2013-04-14 15:56:59 -0600

vedmathai gravatar image

I did not find any obvious answer anywhere for this, but is there any way we can just fill in equations instead of hard coded values into the sdf for the pose of different links on a model. As in there is a rod of length 5units and is tilted such that it makes 0.64 rads [arctan(3/4)] with the x axis. One end of the rod is at 0,0,0 and I want a globe to be created at the other end of the rod. Is it possible to do this by saying the globe should be positioned at (5cos(.64), 0, 5sin(.64)), instead of calculating and saying it should be (3,0,4) In this case it was easy as I took an example with number which could be handled at the back of an envelope but it does become little confusing when I have made this whole model with so many different links and suddenly after hard coding values in, I suddenly decide I need to change the height of one component. Then it becomes cumbersome to figure out all the values again. It seems to me that the entering of values in the sdf is quite brute force. Unless there is someother way to do it and I don't know. Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-04-15 01:30:58 -0600

AndreiHaidu gravatar image

updated 2013-04-15 01:33:07 -0600


You can resolve this by creating your model in a plugin, you write the sdf file in a stringstream and then load it in the simulation, I will write a short example below:

    std::stringstream xml;

    xml << "<sdf version ='1.3'>\n";
    xml << "<model name ='example'>\n";
    xml << "\t<static>false</static>\n";
    xml << "\t<pose>" << init_pos.x << " " << init_pos.y << " " << init_pos.z << " 0 0 0 </pose>\n";
    . . .

    sdf::SDF sdf_model;

    //here _parent is a WorldPtr because the plugin was a world plugin

If you need more help let me know.

Cheers, Andrei

edit flag offensive delete link more


yup it worked, thanks a lot.

vedmathai gravatar imagevedmathai ( 2013-04-17 13:00:42 -0600 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-04-14 15:56:59 -0600

Seen: 164 times

Last updated: Apr 15 '13