Hi Ioan,
Thank you for your help. Setting the
start_state.attached_collision_objects in the MotionPlanRequest fixed
the problem!
I was under the impression that the start state was determined from the
PlanningScene (using the current state), but it seems not to be the
case. It seems, I am losing track of all the different robot and world
representations ;)
I will try to explain the problem with setFromIK and the attachedBody
from my point of view. The main issue is that the for position-only IK,
the solution it yields is different from what I would obtain with a
modified URDF.
As an example, imagine I attach a stick to a robot's arm (maybe a
billiard stick) and want the robot to hit a certain point (let's say a
ball) with the stick's tip but do not care about the angle at which the
ball is hit (ok, that's maybe a stupid idea for playing billiard..).
If I add the stick to the URDF and call setFromIK for the stick's tip, I
will get a solution with the gripper being placed somewhere on a sphere
around the ball with a radius of the stick's length (restricted by the
joint limits). So if I do not like the returned solution (as it might
collide with the environment), I can simply use a different seed state
and get a different solution.
On the other hand, if I use an attachedBody to add the stick to the
gripper and call setFromIK, it will compute a location for the gripper
first, that is determined deterministically by the inverse of the
transform from gripper to stick and the pose of the tip. Only after
that, it looks for a (position-only) IK solution for the gripper at that
specific location. So the solution space is strongly restricted.
There are two problems here a) The location of the gripper will always
be the same (but might collide with an other object or be unreachable).
Setting a different seed will result in the same position for the
gripper (which would still collide or be unreachable).
b) Using position-only IK for the EEF results in arbitrary positions for
the attachedBody, as the orientation of the EEF is ignored. So the stick
might not hit the ball at all.
These problem with the way setFromIK with an attachedBody works mainly
concern position-only IK. However even for full IK, any tolerance
specified is not with respect to the attachedBody but to the EEF, which
is also different from the URDF-based approach would do, and hence it is
counter-intuitive to me.
So concluding, I would like the attachedBody to behave as it was part of
the robot model :)
Daniel
On 02/04/2014 06:56 PM, Ioan Sucan wrote:
> Hello Daniel,
>
> I will add some answers (and some questions :) ) inline:
>
>
> On Tue, Feb 4, 2014 at 6:36 AM, Daniel Maier
> <
mai...@informatik.uni-freiburg.de
> robot_state->attachBody(__attachedBody);
> // ... set joints in robot_state, e.g. from current /joint_states
> goal_state = new RobotState(robot_model);
> // .. set joints in goal_state from IK solution
> goal_state->attachBody(__attachedBody); // not sure if this is
> necessary, // I tried leaving out this line but did not help
>
> planning_scene.reset(new planning_scene::PlanningScene(__robot_model));
> planning_scene->__setCurrentState(robot_state);
> MotionPlanRequest req;
> robot_model::JointModelGroup * group =
> robot_model->__getJointModelGroup( group_name);
> req.group_name = group->getName();
> req.goal_constraints.clear();
> moveit_msgs::Constraints joint_goal =
> kinematic_constraints::__constructGoalConstraints( goal_state, group);
> req.goal_constraints.push___back(joint_goal);
>
> MotionPlanResponse res;
> context = planner_instance->__getPlanningContext(planning___scene,
> res.trajectory_->__getFirstWayPoint();
> rs.getAttachedBodies(abs);
> ROS_INFO("response hasAttachedBody(): %zu", abs.size());
> shows me that there is no attachedBody in the response.
>
> Why doesn't this work as expected?
>
> Thanks for your help.
> Daniel
>
>
>
>
>
> On 01/30/2014 06:21 PM, Dave Hershberger wrote:
>
> Have you tried this with position-only IK enabled in
> kinematics.yaml?
>
>
http://docs.ros.org/api/pr2___moveit_tutorials/html/__kinematics/src/doc/kinematics___configuration.html#position-__only-ik
>
http://docs.ros.org/api/__moveit_core/html/classmoveit___1_1core_1_1RobotState.html#__a5969cc58a617a8c117cbb888e0034__b4b
> RobotState::clearAttachedBody(__).