@@ -96,15 +96,16 @@ bool isTargetPoseColliding(const planning_scene::PlanningScenePtr& scene, Eigen:
9696
9797 // consider all rigidly connected parent links as well
9898 const robot_model::LinkModel* parent = robot_model::RobotModel::getRigidlyConnectedParentLinkModel (link);
99+ const auto & target_links = parent->getParentJointModel ()->getDescendantLinkModels ();
99100 if (parent != link) // transform pose into pose suitable to place parent
100101 pose = pose * robot_state.getGlobalLinkTransform (link).inverse () * robot_state.getGlobalLinkTransform (parent);
101102
102103 // place link at given pose
103104 robot_state.updateStateWithLinkAt (parent, pose);
104105 robot_state.updateCollisionBodyTransforms ();
105106
106- // disable collision checking for parent links (except links fixed to root)
107- auto & acm = scene->getAllowedCollisionMatrixNonConst ( );
107+ // disable collision checking for parent links in the kinematic chain (except links fixed to root)
108+ collision_detection::AllowedCollisionMatrix acm ( scene->getAllowedCollisionMatrix () );
108109 std::vector<const std::string*> pending_links; // parent link names that might be rigidly connected to root
109110 while (parent) {
110111 pending_links.push_back (&parent->getName ());
@@ -119,6 +120,16 @@ bool isTargetPoseColliding(const planning_scene::PlanningScenePtr& scene, Eigen:
119120 }
120121 }
121122
123+ // disable collision checking between collision objects and links not part of the rigid target group
124+ const auto & world_object_ids = scene->getWorld ()->getObjectIds ();
125+ for (const auto & robot_link : scene->getRobotModel ()->getLinkModelsWithCollisionGeometry ()) {
126+ if (std::find (target_links.begin (), target_links.end (), robot_link) == target_links.end ()) {
127+ for (const auto & object_id : world_object_ids) {
128+ acm.setEntry (object_id, robot_link->getName (), true );
129+ }
130+ }
131+ }
132+
122133 // check collision with the world using the padded version
123134 collision_detection::CollisionRequest req;
124135 collision_detection::CollisionResult result;
0 commit comments