ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Once in a while moveit! ignores collision objects

asked 2021-12-15 02:16:53 -0500

Foxman gravatar image

updated 2021-12-21 09:13:45 -0500

Hello,

I have created some collision objects with the moveit::planning_interface::PlanningSceneInterface object like this: image description

Usually, moveit noticeably refers to the collision object, but once in a while it's not and the arm actually enters the collision object. Moveit doesn't detect the collision and in real life the robot actually collides with its environment.

Do you have any suggestions for what I did wrong? Currently I don't have the values which caused that collision but any idea will be welcomed.

Planning and executing:

mMoveGroup.setJointValueTarget(targetJointValues);
mMoveGroup.setStartStateToCurrentState();
moveit::planning_interface::MoveItErrorCode result = mMoveGroup.plan(plan);
mMoveGroup.execute(plan);

Here is the code for creating the collision object:

moveit::planning_interface::PlanningSceneInterface planning_scene_interface("/right");
std::vector<moveit_msgs::CollisionObject> collision_objects;
moveit_msgs::CollisionObject collision_object;

collision_object = createCollisionObject("rover",
    0.9, 1.4, 1.0,
    -0.15, 0.4, -0.45,
    0.966, 0, 0, -0.259);
collision_objects.push_back(collision_object);  
collision_object = createCollisionObject("tomato-box",
    0.4, 0.4, 0.15,
    -0.35, 0.1, 0.01,
    0.966, 0, 0, -0.259);
collision_objects.push_back(collision_object);
collision_object = createCollisionObject("camera-mast",
    0.15, 0.15, 0.50,
    -0.77, 0.08, 0.25,
    0.966, 0, 0, -0.259);
collision_objects.push_back(collision_object);  
collision_object = createCollisionObject("arm-wall",
    2.0, 0.02, 3.0,
    0.22, 0.22, 0,
    0.966, 0, 0, -0.259);
collision_objects.push_back(collision_object);

while (!planning_scene_interface.applyCollisionObjects(collision_objects)){
    ROS_WARN("Planning scene not ready, sleeping");
    ros::Duration(0.5).sleep();
}

The function that returns a collision object:

moveit_msgs::CollisionObject createCollisionObject(std::string id, float d0,
    float d1, float d2, float x, float y, float z, float ow, float ox, float oy, float oz)
   {
    moveit_msgs::CollisionObject collision_object;
    collision_object.header.frame_id = "world";
    collision_object.id = id;

    shape_msgs::SolidPrimitive primitive;
    primitive.type = primitive.BOX;
    primitive.dimensions.resize(3);
    primitive.dimensions[0] = d0;
    primitive.dimensions[1] = d1;
    primitive.dimensions[2] = d2;

    geometry_msgs::Pose box_pose;
    box_pose.orientation.w = ow;
    box_pose.orientation.x = ox;
    box_pose.orientation.y = oy;
    box_pose.orientation.z = oz;

    box_pose.position.x = x; 
    box_pose.position.y = y;
    box_pose.position.z = z;

    collision_object.primitives.push_back(primitive);
    collision_object.primitive_poses.push_back(box_pose);
    collision_object.operation = collision_object.ADD;

    return collision_object;
}

Thanks in advance, Nadav

edit retag flag offensive close merge delete

Comments

Which planner are you using? In moveit, are you using "joint trajectory mode" or "cartesian mode"?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-12-16 09:25:35 -0500 )edit

Hey, I'm using both. For picking up the target I'm using cartesian planner and RRTConnect and for returning the joint trajectory one.

Foxman gravatar image Foxman  ( 2021-12-19 01:52:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-12-19 07:36:32 -0500

Mike Scheutzow gravatar image

updated 2021-12-20 09:43:48 -0500

I could find almost no information about when moveit does collision checking, and when it does not. While running tests using moveit_commander (mc), I made these observations:

  1. mc.set_joint_value_target(joint_goal); mc.go() - no collision checking during planning or execution
  2. generate a plan, then call mc.execute(plan, wait=True) - no collision checking during execution
  3. mc.set_pose_target(pose); mc.go() - collision checking during both planning and execution

If you are using (1) or (2) in your code, I advise you to do some tests to understand exactly how your system behaves.

If you find the same thing that I did, and you want to implement collision checking, moveit appears to have a c++ routine to do the heavy work, but you'll have to call it from your own code.

nb: this answer has been updated after a discussion in the comments.

edit flag offensive delete link more

Comments

Oh I didn't know that. Thanks a lot!

Foxman gravatar image Foxman  ( 2021-12-19 07:54:51 -0500 )edit

What do you mean exactly by this @Mike Scheutzow ?

Are you referring to the ExecuteTrajectory action MoveIt exposes? Or just planning to joint / pose goals using OMPL / another planner?

gvdhoorn gravatar image gvdhoorn  ( 2021-12-19 08:09:51 -0500 )edit

How do you recommend to check that?

Foxman gravatar image Foxman  ( 2021-12-19 08:17:30 -0500 )edit

@gvdhoorn As far as I know, when planning or executing a joint trajectory, moveit does not do any collision checking (neither self-collision or external scene collision.) I learned this the hard way.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-12-19 08:25:18 -0500 )edit
1

As far as I know, when planning [..] a joint trajectory, moveit does not do any collision checking

No, that's not accurate, and if that's what you experienced, you either ran into a bug, or configured something incorrectly. Planning with collision checking is one of the major features of MoveIt. What would be the point of the planning scene (ie: collision scene) otherwise?

I would recommend to report this, as it's not what should happen.

Executing a pre-planned (via MoveIt or some other planner framework) trajectory would be something else -- as in most cases IIRC it's forwarded verbatim to the trajectory execution monitor (or even the configured 'controller' (ie: driver)).

re: "cartesian mode": this is not a mode. If you are referring to the checkbox in the MoveIt RViz plugin, this just requests MoveIt to use its computeCartesianPath(..) functionality which essentially linearly interpolates between poses. Any failure ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2021-12-19 08:34:29 -0500 )edit

@Foxman like I said, there is a function you can call to check if a specific set of joint values results in collision - I don't recall the name of it. But it's up to your code when to call it, and to stop the arm if the function reports collision.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-12-19 08:35:44 -0500 )edit

Note also that the only difference between planning to a joint pose or a Cartesian pose is the involvement of IK. After running IK to get a joint pose, the planning pipeline used is identical. This is also the reason why sometimes joint goals work 'perfectly', but 'pose goals' do not: many times, the IK solver doesn't work for the robot's kinematics, and so there is no joint goal for OMPL to work with.

As to the OPs problem: there are ways for MoveIt to apparently "ignore" collision objects, but that's often caused by a user either not, or inadvertently using the "planning scene diff" part of planning requests incorrectly.

Perhaps @v4hn could comment here. But the OP would have to provide code samples for anyone to be able to provide a possible cause of what's going on.

gvdhoorn gravatar image gvdhoorn  ( 2021-12-19 08:38:34 -0500 )edit

@gvdhoorn re: "planning". I understand your point. It was an error for me to type that. But I disagree when you imply that joint-movement and cartesian-movement are not fundamentally different modes in moveit.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-12-19 08:50:48 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-12-15 02:15:12 -0500

Seen: 401 times

Last updated: Dec 21 '21