Open osrf-migration opened 4 years ago
Original comment by Diego Ferigo (Bitbucket: dgferigo).
Waiting a reply from the maintainers of the simulator, I can tell you that as far as I know setting the state of the links (position, velocity, …) is not possible.
What’s more common is, instead, setting the state of the joints. You can reset the initial joint position and velocity of the joints with the new components introduced in this PR, and then actuating it either applying a raw joint force through the JointForceCmd
component or using a PID controller.
In more complex robots, sometimes is not straightforward calculating the joint configuration corresponding of the desired link position. If this is your use case, you could calculate the joint configuration by solving an inverse kinematics problem. Note that not all the IK libraries allow the definition of link orientations, but just the position and orientation of a single link (typically the end effector).
Original comment by waytry (Bitbucket: waytry).
Hi Diego Ferigo (dgferigo) , thanks for the reply. Appreciate it!
I noticed that in one of an earlier PR you mentioned that using the WorldPoseCmd
component to set a new model pose. If I understand correctly, this is only able to set pose for a model, not for link/joint. Can you tell me a little more on how to use WorldPoseCmd
to set the pose for a model?
Thanks.
Original comment by Michael Grey (Bitbucket: mxgrey, GitHub: mxgrey).
Diego’s reply is completely correct: link poses and link velocities cannot generally be set directly, because those properties are constrained by joints. If you were able to set them directly, there’s a good chance that the system would be put into an invalid state, and your simulation might “explode” (historically this has been a leading cause of simulation bugs among Gazebo users). Because of this it’s best to set joint states directly, since arbitrary joint state values aren’t as likely to violate simulation constraints.
I think the JointVelocityCmd component should be able to help with setting the joint velocities. However, that gets treated as a command rather than setting the joint state directly, so something like a ResetJointVelocity
component would be better, if such a thing existed.
It doesn’t look like there’s a component for setting joint positions directly. These are features that could (and should) be added to ignition-gazebo. I would recommend the adding the following components to ignition-gazebo:
ResetJointPosition[s]
: Use this to directly set the joint position state, with no regard for physical constraintsResetJointVelocit[y|ies]
: Use this directly set the joint velocity state, with no regard for physical constraintsMaybe there’s a better word that could be used besides Reset
, but I don’t want to use Cmd
because Cmd
implies that it is acceptable to use as controller input into a live simulation, which is very much not the case for these features. I also don’t want to use Set
because I think that’s too easily interpreted as a feature that can be used casually without significant side-effects. I hope that Reset
can express the sense that using the component will break the flow of the simulation and create a physical discontinuity. But if anyone can think of an alternative word that expresses that better, please do share.
Original comment by Diego Ferigo (Bitbucket: dgferigo).
so something like a
ResetJointVelocity
component would be better, if such a thing existed
I’m not sure if I got your point correctly, Reset*
components have been added in ignitionrobotics/ign-gazebo#437.
Original comment by Michael Grey (Bitbucket: mxgrey, GitHub: mxgrey).
Oh wow, that’s literally exactly what I had in mind. I didn’t realize that already existed, because I was looking at the default
branch of ignition-gazebo
, and it seems those changes haven’t been merged to there yet.
Thanks for already contributing that!
Is this feature (JointPositionReset
, JointVelocityReset
) exposed anywhere? Something similar to the infamous -J
option in classic gazebo or the /gazebo/set_model_configuration
ROS service call?
Original report (archived issue) by waytry (Bitbucket: waytry).
Hi,
I am trying to develop reinforcement learning algorithm based on the ignition gazebo. One functionality I need to implement is manually setting the states of the links in a model. For example, for a cartpole model, I need to routinely set the position/velocity of the cart and the angle/rate of the pole during the simulation is running. I looked at the functions provided by the ECM. I got to know how to obtain the states of a link by using the function
Component
. But I didn’t see a function used to set the states of a link.
Can anybody give me some instructions on this? Thanks!