# Revision history [back]

Yes, you describe the correct way of disabling collision checking between two bodies.

But this post contains the unspoken question "Why are collisions not detected for my newly added collision object?", which needs to be answered: I suspect that the PlanningScene object that you are calling checkCollision on is not the same as the one that RViz displays, and that is why you are not seeing the collision. You can use a PlanningSceneMonitor to get the newest scene, or use the /get_planning_scene service (this is probably easier). Here is some boilerplate code for the latter, which you can copy from.

Regarding a better way to enable/disable collisions: Internally I am using this extension of the planning_scene_interface that defines the functions allowCollisions and disallowCollisions and connects them to the Python interface as well, but we did not merge this upstream because the updating method is not strictly safe. If you are confident that it does not affect your application, you can use those changes as well.

 2 No.2 Revision gvdhoorn 80734 ●261 ●1246 ●980 http://cor.tudelft.nl/

Yes, you describe the correct way of disabling collision checking between two bodies.

But this post contains the unspoken question "Why are collisions not detected for my newly added collision object?", which needs to be answered: I suspect that the PlanningScene object that you are calling checkCollision on is not the same as the one that RViz displays, and that is why you are not seeing the collision. You can use a PlanningSceneMonitor to get the newest scene, or use the /get_planning_scene service (this is probably easier). Here is some boilerplate code for the latter, which you can copy from.

from:

bool SkillServer::updatePlanningScene()
{
moveit_msgs::GetPlanningScene srv;
// Request only the collision matrix
srv.request.components.components = moveit_msgs::PlanningSceneComponents::ALLOWED_COLLISION_MATRIX;
get_planning_scene_client.call(srv);
if (get_planning_scene_client.call(srv))
{
ROS_INFO("Got planning scene from move group.");
planning_scene_ = srv.response.scene;
return true;
}
else
{
ROS_ERROR("Failed to get planning scene from move group.");
return false;
}
}


Regarding a better way to enable/disable collisions: Internally I am using this extension of the planning_scene_interface that defines the functions allowCollisions and disallowCollisions and connects them to the Python interface as well, but we did not merge this upstream because the updating method is not strictly safe. If you are confident that it does not affect your application, you can use those changes as well.