Skip to content

Commit 5368191

Browse files
feat(planning): allow the link pairs that touch at a reference pose (#51)
SelfCollision::AllowTouching(reference, margin) allows every pair not yet allowed whose capsules are closer than the margin at a reference configuration known to be clear, such as the home pose. Pairs that the coarse capsule model makes overlap by construction are then found from the model instead of being listed by hand. Claude-Session: https://claude.ai/code/session_014WUWh8Fw5EhcfvNuXz3jjU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1125b3f commit 5368191

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

‎doc/planning/SelfCollision.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ where the **allowed set** $\mathcal{A}$ excludes pairs that need no check.
3434
Adjacent links share a joint, so their capsules always touch, and they are allowed by default. Further pairs belong in $\mathcal{A}$ when joint limits keep them permanently apart, or when the coarse model makes them permanently overlap (a housing over its neighbour).
3535
A permanent false positive would otherwise hide every real collision behind it. The allowed set is a symmetric bit matrix, so membership is a single test.
3636

37+
The pairs that overlap by construction can be found from the model itself: evaluate every pair not yet allowed at a reference configuration where the arm is known to be clear, such as its home pose, and allow those closer than the margin there. Whatever touches in a pose that is safe by definition touches because of the coarse geometry, not because of a collision.
38+
3739
### Margin
3840

3941
The configuration is flagged as colliding when $d_{\min} < m$. A positive margin $m$ absorbs model error, sensor latency and the motion between checks. At tool speed $v$ and control period $\Delta t$, use at least $m \ge v\,\Delta t$.
@@ -56,6 +58,7 @@ A planar four-link arm has link lengths $(0.4, 0.8, 0.7, 0.5)$ m and radii $(0.1
5658

5759
## Pitfalls & Edge Cases
5860

61+
- **Reference pose that is not clear**: allowing the pairs that touch at a reference configuration trusts that configuration. A reference pose with a genuine overlap hides that collision for good.
5962
- **Coarse geometry**: joint-to-joint capsules miss offset parts such as elbow housings, cables and tools. Enlarge the radius, or add extra frames that model those parts as separate capsules.
6063
- **Over-allowing**: every allowed pair is a blind spot. Justify each one with joint limits or permanent overlap, never just to silence a warning.
6164
- **Crossing cores**: once two core segments intersect, the penetration depth is only a lower bound and the closest points are arbitrary. Treat any negative value as a collision rather than trusting its magnitude.

‎robotics/planning/SelfCollision.hpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace planning
3636
void Allow(std::size_t i, std::size_t j);
3737
void Disallow(std::size_t i, std::size_t j);
3838
bool IsAllowed(std::size_t i, std::size_t j) const;
39+
void AllowTouching(const Frames& reference, T margin);
3940

4041
OPTIMIZE_FOR_SPEED SelfCollisionResult<T> Check(const Frames& frames, T margin) const;
4142
Capsule<T> LinkCapsule(const Frames& frames, std::size_t link) const;
@@ -75,6 +76,15 @@ namespace planning
7576
return (allowed[i] & Bit(j)) != 0;
7677
}
7778

79+
template<typename T, std::size_t NumLinks>
80+
void SelfCollision<T, NumLinks>::AllowTouching(const Frames& reference, T margin)
81+
{
82+
for (std::size_t i = 0; i < NumLinks; ++i)
83+
for (std::size_t j = i + 1; j < NumLinks; ++j)
84+
if (!IsAllowed(i, j) && PrimitiveDistance<T>::CapsuleCapsule(LinkCapsule(reference, i), LinkCapsule(reference, j)).distance < margin)
85+
Allow(i, j);
86+
}
87+
7888
template<typename T, std::size_t NumLinks>
7989
OPTIMIZE_FOR_SPEED SelfCollisionResult<T> SelfCollision<T, NumLinks>::Check(const Frames& frames, T margin) const
8090
{

‎robotics/planning/test/TestSelfCollision.cpp‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,12 @@ TEST_F(TestSelfCollision, adjacent_pairs_are_allowed_by_default)
104104

105105
EXPECT_EQ(model.Check(Planar(0.0f, 0.0f, 0.0f, 0.0f), 0.0f).checkedPairs, 4u);
106106
}
107+
108+
TEST_F(TestSelfCollision, allow_touching_allows_only_the_pairs_within_the_margin_at_the_reference_pose)
109+
{
110+
model.AllowTouching(Planar(0.0f, 2.4f, 2.4f, 0.5f), 0.0f);
111+
112+
EXPECT_TRUE(model.IsAllowed(0, 2));
113+
EXPECT_FALSE(model.IsAllowed(0, 3));
114+
EXPECT_FALSE(model.IsAllowed(1, 3));
115+
}

0 commit comments

Comments
 (0)