Robotics StackExchange | Archived questions

Adding collision objects with moveitCpp API

Hello,

I am testing the MoveitCpp API in ROS melodic, and as I understand from the tutorials in the Moveit website (MoveitCpp tutorial), this API allows to get rid of the internal topic subscriptions and rosservices of move_group, but it is not clear to me how it can be used along the other moveit components explained in the other tutorials. My question is: If you use this API, from where does it get the planning scene information? How can the collision objects and attached objects be added to the plannings? Is there an example available?

Thanks


Edit: I managed to publish the planning scene information to moveit_cpp by creating a moveit_msgs::PlanningScene and sending it with:

moveitcppptr->getPlanningSceneMonitor()->newPlanningSceneMessage(planningscenemessage);

but I had to manually initiallize the message with an initial joint state and the allowedcollisionmatrix in order to get a plan (after sending the message, the adjacent links caused a collision if the allowedcollisionmatrix was empty). My new question, related to this is: How can I get the allowedcollisionmatrix using moveit_cpp? Can it be read from the robot.srdf ?

Asked by joang on 2020-11-06 08:54:01 UTC

Comments

Answers

The PlanningSceneMonitor inside MoveItCpp already contains a planning scene. It can be accessed directly, but needs to be locked to avoid race conditions. There are convenience classes to do this LockedPlanningSceneRO (readonly) LockedPlanningSceneRW (read/write). With these classes, the PlanningScene can be accessed directly.

To answer your other questions, here are a few examples.

Examples

Adding a collision object:

planning_scene_monitor::LockedPlanningSceneRW scene{moveitCpp->getPlanningSceneMonitor()};
scene->processCollisionObjectMsg(collisionObject);

Adding an attached object:

planning_scene_monitor::LockedPlanningSceneRW scene{moveitCpp->getPlanningSceneMonitor()};
scene->processAttachedCollisionObjectMsg(attachedObject);

Asked by pvl on 2021-06-23 06:19:39 UTC

Comments