Skip to content

Commit 62b3ff1

Browse files
Aleksey Noginsjahr
andauthored
Support including the names of other attached objects in touch_link (#3276)
* Support including the names of other attached objects in `touch_link` Fixes #3275 * Add a comment; add {} for readability --------- Co-authored-by: Sebastian Jahr <sebastian.jahr@picknik.ai>
1 parent 0af5e0f commit 62b3ff1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

moveit_core/collision_detection_fcl/src/collision_common.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,30 @@ bool collisionCallback(fcl::CollisionObjectd* o1, fcl::CollisionObjectd* o2, voi
155155
}
156156
}
157157
}
158+
158159
// bodies attached to the same link should not collide
160+
// If one of the attached objects lists the other in touch links set, then collisions are also allowed
159161
if (cd1->type == BodyTypes::ROBOT_ATTACHED && cd2->type == BodyTypes::ROBOT_ATTACHED)
160162
{
161163
if (cd1->ptr.ab->getAttachedLink() == cd2->ptr.ab->getAttachedLink())
164+
{
162165
always_allow_collision = true;
166+
}
167+
else
168+
{
169+
const std::set<std::string>& tl1 = cd1->ptr.ab->getTouchLinks();
170+
const std::set<std::string>& tl2 = cd2->ptr.ab->getTouchLinks();
171+
if (tl1.find(cd2->getID()) != tl1.end() || tl2.find(cd1->getID()) != tl2.end())
172+
{
173+
always_allow_collision = true;
174+
}
175+
}
176+
if (always_allow_collision && cdata->req_->verbose)
177+
{
178+
RCLCPP_DEBUG(getLogger(),
179+
"Attached object '%s' is allowed to touch attached object '%s'. No contacts are computed.",
180+
cd2->getID().c_str(), cd1->getID().c_str());
181+
}
163182
}
164183

165184
// if collisions are always allowed, we are done

0 commit comments

Comments
 (0)