You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -278,4 +278,75 @@ for c in rdata.result.contacts:
278
278
print'\tO1: {}, O2: {}'.format(c.o1, c.o2)
279
279
```
280
280
281
+
### Extracting Which Objects Are In Collision
282
+
283
+
To determine which objects are actually in collision, you'll need parse the collision data's contacts and use an additional external data structure.
284
+
285
+
Specifically, the `fcl.CollisionData` object that is passed into any `collide()` call has an internal set of contacts, stored in `cdata.result.contacts`.
286
+
This object is a simple list of `Contact` objects, each of which represents a contact point between two objects.
287
+
Each contact object has two attributes, `o1` and `o2`, that store references to the original `fcl.CollisionGeometry` objects were created for the two `fcl.CollisionObject` objects that are in collision.
288
+
This is a bit wonky, but it's part of the FCL API.
289
+
290
+
Therefore, all you have to do is make a map from the `id` of each `fcl.CollisionGeometry` object to either the actual `fcl.CollisionObject` it corresponds to or to some string identifier for each object.
291
+
Then, you can iterate over `cdata.result.contacts`, extract `o1` and `o2`, apply the built-in `id()` function to each, and find the corresponding data you want in your map.
0 commit comments