Initial joint position *without* ROS
Hi everyone, I know this has been asked a few times but I really can't find a working solution for my use case.
I simply want my model to start with nonzero angles, i.e. an initial angle. I cannot find any way of doing this. According to the SDF spec there should be an
<joint type="revolute" name="left_hip_axis_3_hip_axis_2_joint">
<pose> -0.145 0 0 0 -1.5707 0 </pose>
<parent>left_hip_axis_3</parent>
<child>left_hip_axis_2</child>
<axis>
<xyz> 0 0 1 </xyz>
<limit>
<lower>-1</lower>
<upper>1</upper>
</limit>
</axis>
</joint>
It simply ignores the value and launches with zero angle anyway... What am I supposed to do to fix this? I'm running gazebo 9.14 (for some reason the tagging didn't work....). It is essential for me to have this feature because I cannot test my controller code otherwise.
Asked by Please help me I'm desperate on 2020-10-20 13:56:17 UTC
Answers
initial_position
is probably not implemented.
You can write a model plugin, access the joints directly, and set your initial positions. The ROS interface works in an equivalent way.
This is all you would have to do:
void MyModelPlugin::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) {
std::map<std::string, double> positions;
// Parse positions from _sdf->Get<whatever>("initialPositions");
for (physics::JointPtr joint : _model->GetJoints()){
if (positions.count(joint->GetName()) == 0) continue;
joint->SetPosition(0, positions[joint->GetName()]);
}
}
Asked by nlamprian on 2020-10-20 20:39:27 UTC
Comments
I used this leftHip3Joint->SetPosition(0, 1);
as a dumbed-down version of your code and it does start at the position but then wants to continually move to this position if I disturb it, because the PID is trying to reach its goal. This is not ok if I want to test my controller since it will be excerting a constant force. Now that I think about it though, do you reckon a good way of doing this is to simply set all joint controller gains to 0 after having reached this position?
Asked by Please help me I'm desperate on 2020-10-21 08:32:02 UTC
This code shouldn't affect your simulation after the initialization. Did you maybe add the SetPosition call somewhere in your update method?
Asked by nlamprian on 2020-10-21 11:40:06 UTC
I thought once you set a desired position for the Joint, the Gazebo PID's always try to reach it, that's why my thought was to set the gains to 0.
Asked by Please help me I'm desperate on 2020-10-21 16:37:54 UTC
Comments
This has been a long requested feature that has had discussions on and off since 2012... see https://github.com/osrf/gazebo/issues/207 https://github.com/osrf/sdformat/issues/253 https://github.com/osrf/gazebo/issues/1072
Asked by wongrufus on 2020-10-25 21:54:07 UTC