Closed 2b-t closed 9 months ago
This issue is being labeled as stale because it has been open 45 days with no activity. It will be automatically closed after another 45 days without follow-ups.
This should try use the current state instead of falling back to zero. Will take a look.
OK I just took a look and I think your initial question has it right -- so it appears to be expected behavior, but I agree that it is confusing when you haven't initialized all the joints to the current state. Namely:
Joint variables in the group that are missing from variable_values remain unchanged (to reset all target variables to their current values in the robot use setJointValueTarget(getCurrentJointValues())).
So I think your code can follow this recommendation:
move_group_interface->setJointValueTarget(move_group_interface->getCurrentJointValues());
move_group_interface->setNamedTarget("my_named_state");
Does this work?
Also, I have to say that Galactic is no longer supported, so if you'd like to try this on Humble/Rolling to see if the issue still persists, might be worth a shot. However, I don't know if this part of the code has really changed all that much in the last decade :)
Hi @sea-bass Thanks for your response. That is quite similar to what I ended up doing. Wrote this issue some month ago when Galactic was still supported. We are using Humble now. Feel free to close this issue if you think this default behavior should/will not be changed anytime soon. Many thanks
Yeah, I think because users will probably want to control exactly what to do with those other joints, I'm inclined to close this issue.
Either way, this will serve as a good reference for others running into similar problems, so thank you for posting this detailed writeup!
Description
When commanding a robot to a named target that does not specify all the joint values either with:
MoveGroupInterface::setNamedTarget(const std::string&)
orMoveGroupInterface::getNamedTargetValues(const std::string&)
followed byMoveGroupInterface::setJointValueTarget(const std::map<std::string, double>&)
the robot seems to use
0.0
for the unspecified joints and as a result might fail to plan the motion. My main question is, is this a bug or expected behavior (and if yes, what is the reasoning behind it)? After all the doc-string states:Does unchanged in this context mean default initialized?
Your environment
galactic
, commit1255936
0.8.0-focal.20221203.084342
Steps to reproduce
I have encountered an unexpected error when working with the mobile manipulator Hello-Robot Stretch. The particularity of this robot is that its linear axis
joint_lift
at position0.0
is in collision with its base, meaning that moving the arm to0.0
is in general not possible (see images below). When commanding the robot to a named target that does not specify all the joint values for all of its joints in thesrdf
, which is the case for most of the named targets defined instretch_description.srdf
(e.g. thestretch_arm
group defines 7 jointswhile the group state
wrist_in
only defines a single joint, thejoint_wrist_yaw
:) the robot fails to plan the motion complaining about a collision between the arm and the mobile base while the two are clearly not in collision. When using RViz for planning on the other hand this works just fine!
A code snippet that is able to replicate this on the Hello-Robot stretch is the following:
replicating this might be hard as Hello-Robot is currently not offering a simulation package for the robot but one should be able to replicate this on any robot by specifying a named target only for some joints of a group inside the
srdf
, making sure that there is a collision if all joints are set to0.0
(I assume could also be with an artificially inserted obstacle or one from an octomap from the depth camera) and then command the robot to move to that named target withsetNamedTarget
.Expected behaviour
The robot should move to the given pose either:
So when commanding the robot to
wrist-in
, corresponding to settingjoint_wrist_yaw
to3.1415 rad
or180 deg
I would expect the robot to do the following (shadow indicates the current pose while the solid robot the desired one):Actual behaviour
Moveit detects a collision between
base_link
andlink_gripper
. From the debugging it seems as if it would assume0.0
for all the unspecified joints and therefore plans for a configuration like below, which results in the collisions (again the shadow indicating its current pose and the solid robot depicting what seems to be happening with the end-effector colliding with the base).The reason this works from RViz is that it does not use
MoveGroupInterface::setNamedTarget
to move to named targets and therefore has values for all the joints. Clearly if I read out the joints withgetJointNames
and the current joint values withgetCurrentJointValues
and combine them in anstd::map<std::string, double>
together with the values fromgetNamedTargetValues
and call the corresponding overload ofsetJointValueTarget
, everything works as expected. So something like:Similarly when de-activating collisions between the involved links inside the
srdf
the planning and execution succeeds.Backtrace or Console output
When starting the stack MoveGroup already gives a warning:
When commanding the motion the output from the two involved nodes
stretch_moveit_server
(the one containing theMoveGroupInterface
) andmove_group
is the following: