Skip to content

Commit

Permalink
Apply the loaded joint state
Browse files Browse the repository at this point in the history
Use the commented code and update it to the new API.
Also extend it for more than one joint axis.
  • Loading branch information
stefanbuettner committed Jan 8, 2021
1 parent b9d93b1 commit 0b903d6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions gazebo/physics/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1350,14 +1350,14 @@ void Model::SetState(const ModelState &_state)
gzerr << "Unable to find model[" << ms.first << "]\n";
}

// For now we don't use the joint state values to set the state of
// simulation.
// for (unsigned int i = 0; i < _state.GetJointStateCount(); ++i)
// {
// JointState jointState = _state.GetJointState(i);
// this->SetJointPosition(this->GetName() + "::" + jointState.GetName(),
// jointState.GetAngle(0).Radian());
// }
for (unsigned int i = 0; i < _state.GetJointStateCount(); ++i)
{
JointState const jointState = _state.GetJointState(i);
for (unsigned int k = 0; k < jointState.GetAngleCount(); ++k) {
this->SetJointPosition(this->GetName() + "::" + jointState.GetName(),
jointState.Position(k), k);
}
}
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 0b903d6

Please sign in to comment.