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

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 close merge delete

Sort by » oldest newest most voted

Hi,

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;
sdf_model.SetFromString(xml.str());

//here _parent is a WorldPtr because the plugin was a world plugin
_parent->InsertModelSDF(sdf_model);


If you need more help let me know.

Cheers, Andrei

more