python-fcl-fork


Namepython-fcl-fork JSON
Version 0.7.0.6 PyPI version JSON
download
home_pageNone
SummaryA fork of Python bindings for the Flexible Collision Library that adds support for pointcloud data.
upload_time2024-10-28 17:37:12
maintainerNone
docs_urlNone
authorMichael Dawson-Haggerty, See contributor list
requires_python<3.13,>=3.7
licenseBSD
keywords fcl collision distance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # python-fcl
### Python Interface for the Flexible Collision Library

Python-FCL is an (unofficial) Python interface for the [Flexible Collision Library (FCL)](https://github.com/flexible-collision-library/fcl),
an excellent C++ library for performing proximity and collision queries on pairs of geometric models.
Currently, this package is targeted for FCL 0.7.0.

This package supports three types of proximity queries for pairs of geometric models:
* __Collision Detection__: Detecting whether two models overlap (and optionally where).
* __Distance Computation__: Computing the minimum distance between a pair of models.
* __Continuous Collision Detection__: Detecting whether two models overlap during motion (and optionally the time of contact).

This package also supports most of FCL's object shapes, including:
* TriangleP
* Box
* Sphere
* Ellipsoid
* Capsule
* Cone
* Convex
* Cylinder
* Half-Space
* Plane
* Mesh
* OcTree

## Installation

First, install [octomap](https://github.com/OctoMap/octomap), which is necessary to use OcTree. For Ubuntu, use `sudo apt-get install liboctomap-dev`.
Second, install FCL using the instructions provided [here](https://github.com/flexible-collision-library/fcl).
If you're on Ubuntu 17.04 or newer, you can install FCL using `sudo apt-get install libfcl-dev`.
Otherwise, just compile FCL from source -- it's quick and easy, and its dependencies are all easily installed via `apt` or `brew`.
Note: the provided install scripts (under `build_dependencies`) can automate this process as well.

In order to install the Python wrappers for FCL, simply run
```shell
pip install python-fcl
```

## Objects

### Collision Objects
The primary construct in FCL is the `CollisionObject`, which forms the backbone of all collision and distance computations.
A `CollisionObject` consists of two components -- its geometry, defined by a `CollisionGeometry` object, and its pose, defined by a `Transform` object.

#### Collision Geometries
There are two main types of `CollisionGeometry` objects -- geometric primitives, such as boxes and spheres,
and arbitrary triangular meshes.
Here's some examples of how to instantiate geometric primitives.
Note that the box, sphere, ellipsoid, capsule, cone, and cylinder are all centered at the origin.

```python
import numpy as np
import fcl

v1 = np.array([1.0, 2.0, 3.0])
v2 = np.array([2.0, 1.0, 3.0])
v3 = np.array([3.0, 2.0, 1.0])
x, y, z = 1, 2, 3
rad, lz = 1.0, 3.0
n = np.array([1.0, 0.0, 0.0])
d = 5.0

t = fcl.TriangleP(v1, v2, v3) # Triangle defined by three points
b = fcl.Box(x, y, z)          # Axis-aligned box with given side lengths
s = fcl.Sphere(rad)           # Sphere with given radius
e = fcl.Ellipsoid(x, y, z)    # Axis-aligned ellipsoid with given radii
c = fcl.Capsule(rad, lz)      # Capsule with given radius and height along z-axis
c = fcl.Cone(rad, lz)         # Cone with given radius and cylinder height along z-axis
c = fcl.Cylinder(rad, lz)     # Cylinder with given radius and height along z-axis
h = fcl.Halfspace(n, d)       # Half-space defined by {x : <n, x> < d}
p = fcl.Plane(n, d)           # Plane defined by {x : <n, x> = d}
```

Triangular meshes are wrapped by the `BVHModel` class, and they are instantiated a bit differently.
```python
verts = np.array([[1.0, 1.0, 1.0],
                  [2.0, 1.0, 1.0],
                  [1.0, 2.0, 1.0],
                  [1.0, 1.0, 2.0]])
tris  = np.array([[0,2,1],
                  [0,3,2],
                  [0,1,3],
                  [1,2,3]])

m = fcl.BVHModel()
m.beginModel(len(verts), len(tris))
m.addSubModel(verts, tris)
m.endModel()
```

If the mesh is convex, such as the example above, you can also wrap it in the `Convex` class. Note that the instantiation is a bit different because the `Convex` class supports arbitrary polygons for each face of the convex object.
```python
verts = np.array([[1.0, 1.0, 1.0],
                  [2.0, 1.0, 1.0],
                  [1.0, 2.0, 1.0],
                  [1.0, 1.0, 2.0]])
tris  = np.array([[0,2,1],
                  [0,3,2],
                  [0,1,3],
                  [1,2,3]])
faces = np.concatenate((3 * np.ones((len(tris), 1), dtype=np.int64), tris), axis=1).flatten()
c = fcl.Convex(verts, len(tris), faces)
```

#### Transforms
In addition to a `CollisionGeometry`, a `CollisionObject` requires a `Transform`, which tells FCL where the `CollisionGeometry` is actually located in the world.
All `Transform` objects specify a rigid transformation (i.e. a rotation and a translation).
The translation is always a 3-entry vector, while the rotation can be specified by a 3x3 rotation matrix or a 4-entry quaternion.

Here are some examples of possible ways to instantiate and manipulate a `Transform`.

```python
R = np.array([[0.0, -1.0, 0.0],
              [1.0,  0.0, 0.0],
              [0.0,  0.0, 1.0]])
T = np.array([1.0, 2.0, 3.0])
q = np.array([0.707, 0.0, 0.0, 0.707])

tf = fcl.Transform()     # Default gives identity transform
tf = fcl.Transform(q)    # Quaternion rotation, zero translation
tf = fcl.Transform(R)    # Matrix rotation, zero translation
tf = fcl.Transform(T)    # Translation, identity rotation
tf = fcl.Transform(q, T) # Quaternion rotation and translation
tf = fcl.Transform(R, T) # Matrix rotation and translation
tf1 = fcl.Transform(tf)  # Can also initialize with another Transform
```

Now, given a `CollisionGeometry` and a `Transform`, we can create a `CollisionObject`:

```python
t = fcl.Transform(R, T)
b = fcl.Box(x, y, z)
obj = fcl.CollisionObject(b, t)
```

The transform of a collision object can be modified in-place:
```python
t1 = fcl.Transform(R1, T1)
obj.setTransform(t1)   # Using a transform
obj.setRotation(R2)    # Specifying components individually
obj.setTranslation(T2)
obj.setQuatRotation(q2)
```
## Commands

### Pairwise Operations

Given a pair of collision objects, this library supports three types of queries:
* __Collision Detection__
* __Distance Computation__
* __Continuous Collision Detection__

The interfaces for each of these operations follow a common pipeline.
First, a query request data structure is initialized and populated with parameters.
Then, an empty query response structure is initialized.
Finally, the query function is called with the two `CollisionObject` items, the request structure, and the response structure as arguments.
The query function returns a scalar result, and any additional information is stored in the query result data structure.
Examples of all three operations are shown below.

#### Collision Checking

```python
g1 = fcl.Box(1,2,3)
t1 = fcl.Transform()
o1 = fcl.CollisionObject(g1, t1)

g2 = fcl.Cone(1,3)
t2 = fcl.Transform()
o2 = fcl.CollisionObject(g2, t2)

request = fcl.CollisionRequest()
result = fcl.CollisionResult()

ret = fcl.collide(o1, o2, request, result)
```

After calling `fcl.collide()`, `ret` contains the number of contacts generated between the two objects,
and `result` contains information about the collision and contacts.
For more information about available parameters for collision requests and results,
see `fcl/collision_data.py`.

#### Distance Checking

```python
g1 = fcl.Box(1,2,3)
t1 = fcl.Transform()
o1 = fcl.CollisionObject(g1, t1)

g2 = fcl.Cone(1,3)
t2 = fcl.Transform()
o2 = fcl.CollisionObject(g2, t2)

request = fcl.DistanceRequest()
result = fcl.DistanceResult()

ret = fcl.distance(o1, o2, request, result)
```

After calling `fcl.distance()`, `ret` contains the minimum distance between the two objects
and `result` contains information about the closest points on the objects.
If `ret` is negative, the objects are in collision.
For more information about available parameters for distance requests and results,
see `fcl/collision_data.py`.

#### Continuous Collision Checking

```python
g1 = fcl.Box(1,2,3)
t1 = fcl.Transform()
o1 = fcl.CollisionObject(g1, t1)
t1_final = fcl.Transform(np.array([1.0, 0.0, 0.0]))

g2 = fcl.Cone(1,3)
t2 = fcl.Transform()
o2 = fcl.CollisionObject(g2, t2)
t2_final = fcl.Transform(np.array([-1.0, 0.0, 0.0]))

request = fcl.ContinuousCollisionRequest()
result = fcl.ContinuousCollisionResult()

ret = fcl.continuousCollide(o1, t1_final, o2, t2_final, request, result)
```

After calling `fcl.continuousCollide()`, `ret` contains the time of contact in (0,1), or 1.0 if the objects did not collide during movement from their initial poses to their final poses.
Additionally, `result` contains information about the collision time and status.
For more information about available parameters for continuous collision requests and results,
see `fcl/collision_data.py`.

### Broadphase Checking
In addition to pairwise checks, FCL supports broadphase collision/distance queries between groups of objects and can avoid n-squared complexity.
Specifically, `CollisionObject` items are registered with a `DynamicAABBTreeCollisionManager` before collision or distance checking is performed.

Three types of checks are possible:
* One-to-many: Collision/distance checking between a stand-alone `CollisionObject` and all objects managed by a manager.
* Internal many-to-many: Pairwise collision/distance checking between all pairs of objects managed by a manager.
* Group many-to-many: Pairwise collision/distance checking between items from two managers.

In general, the collision methods can return all contact pairs, while the distance methods will just return the single closest distance between any pair of objects.
Here are some examples of managed collision checking.
The methods take a callback function -- use the defaults from `python-fcl` unless you have a special use case -- and a wrapper object, either `CollisionData` or `DistanceData`, that wraps a request-response pair. This object also has a field, `done`, that tells the recursive collision checker when to quit.
Be sure to use a new `Data` object for each request or set the `done` attribute to `False` before reusing one.

```python
objs1 = [fcl.CollisionObject(box), fcl.CollisionObject(sphere)]
objs2 = [fcl.CollisionObject(cone), fcl.CollisionObject(mesh)]

manager1 = fcl.DynamicAABBTreeCollisionManager()
manager2 = fcl.DynamicAABBTreeCollisionManager()

manager1.registerObjects(objs1)
manager2.registerObjects(objs2)

manager1.setup()
manager2.setup()

#=====================================================================
# Managed internal (sub-n^2) collision checking
#=====================================================================
cdata = fcl.CollisionData()
manager1.collide(cdata, fcl.defaultCollisionCallback)
print 'Collision within manager 1?: {}'.format(cdata.result.is_collision)

##=====================================================================
## Managed internal (sub-n^2) distance checking
##=====================================================================
ddata = fcl.DistanceData()
manager1.distance(ddata, fcl.defaultDistanceCallback)
print 'Closest distance within manager 1?: {}'.format(ddata.result.min_distance)

#=====================================================================
# Managed one to many collision checking
#=====================================================================
req = fcl.CollisionRequest(num_max_contacts=100, enable_contact=True)
rdata = fcl.CollisionData(request = req)

manager1.collide(fcl.CollisionObject(mesh), rdata, fcl.defaultCollisionCallback)
print 'Collision between manager 1 and Mesh?: {}'.format(rdata.result.is_collision)
print 'Contacts:'
for c in rdata.result.contacts:
    print '\tO1: {}, O2: {}'.format(c.o1, c.o2)

#=====================================================================
# Managed many to many collision checking
#=====================================================================
rdata = fcl.CollisionData(request = req)
manager1.collide(manager2, rdata, fcl.defaultCollisionCallback)
print 'Collision between manager 1 and manager 2?: {}'.format(rdata.result.is_collision)
print 'Contacts:'
for c in rdata.result.contacts:
    print '\tO1: {}, O2: {}'.format(c.o1, c.o2)
```

### Extracting Which Objects Are In Collision

To determine which objects are actually in collision, you'll need parse the collision data's contacts and use an additional external data structure.

Specifically, the `fcl.CollisionData` object that is passed into any `collide()` call has an internal set of contacts, stored in `cdata.result.contacts`.
This object is a simple list of `Contact` objects, each of which represents a contact point between two objects.
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.
This is a bit wonky, but it's part of the FCL API.

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.
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.

Here's an example.

```python
import fcl
import numpy as np

# Create collision geometry and objects
geom1 = fcl.Cylinder(1.0, 1.0)
obj1 = fcl.CollisionObject(geom1)

geom2 = fcl.Cylinder(1.0, 1.0)
obj2 = fcl.CollisionObject(geom2, fcl.Transform(np.array([0.0, 0.0, 0.3])))

geom3 = fcl.Cylinder(1.0, 1.0)
obj3 = fcl.CollisionObject(geom3, fcl.Transform(np.array([0.0, 0.0, 3.0])))

geoms = [geom1, geom2, geom3]
objs = [obj1, obj2, obj3]
names = ['obj1', 'obj2', 'obj3']

# Create map from geometry IDs to objects
geom_id_to_obj = { id(geom) : obj for geom, obj in zip(geoms, objs) }

# Create map from geometry IDs to string names
geom_id_to_name = { id(geom) : name for geom, name in zip(geoms, names) }

# Create manager
manager = fcl.DynamicAABBTreeCollisionManager()
manager.registerObjects(objs)
manager.setup()

# Create collision request structure
crequest = fcl.CollisionRequest(num_max_contacts=100, enable_contact=True)
cdata = fcl.CollisionData(crequest, fcl.CollisionResult())

# Run collision request
manager.collide(cdata, fcl.defaultCollisionCallback)

# Extract collision data from contacts and use that to infer set of
# objects that are in collision
objs_in_collision = set()

for contact in cdata.result.contacts:
    # Extract collision geometries that are in contact
    coll_geom_0 = contact.o1
    coll_geom_1 = contact.o2

    # Get their names
    coll_names = [geom_id_to_name[id(coll_geom_0)], geom_id_to_name[id(coll_geom_1)]]
    coll_names = tuple(sorted(coll_names))
    objs_in_collision.add(coll_names)

for coll_pair in objs_in_collision:
    print('Object {} in collision with object {}!'.format(coll_pair[0], coll_pair[1]))
```

```
>>> Object obj1 in collision with object obj2!
```
For more examples, see `examples/example.py`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "python-fcl-fork",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.7",
    "maintainer_email": "Automatika Robotics <contact@automatikarobotics.com>",
    "keywords": "fcl collision distance",
    "author": "Michael Dawson-Haggerty, See contributor list",
    "author_email": "Jelle Feringa <jelleferinga@gmail.com>, Matthew Matl <mmatl@eecs.berkeley.edu>, Shirokuma <rootstock_acg@yahoo.co.jp>",
    "download_url": null,
    "platform": null,
    "description": "# python-fcl\n### Python Interface for the Flexible Collision Library\n\nPython-FCL is an (unofficial) Python interface for the [Flexible Collision Library (FCL)](https://github.com/flexible-collision-library/fcl),\nan excellent C++ library for performing proximity and collision queries on pairs of geometric models.\nCurrently, this package is targeted for FCL 0.7.0.\n\nThis package supports three types of proximity queries for pairs of geometric models:\n* __Collision Detection__: Detecting whether two models overlap (and optionally where).\n* __Distance Computation__: Computing the minimum distance between a pair of models.\n* __Continuous Collision Detection__: Detecting whether two models overlap during motion (and optionally the time of contact).\n\nThis package also supports most of FCL's object shapes, including:\n* TriangleP\n* Box\n* Sphere\n* Ellipsoid\n* Capsule\n* Cone\n* Convex\n* Cylinder\n* Half-Space\n* Plane\n* Mesh\n* OcTree\n\n## Installation\n\nFirst, install [octomap](https://github.com/OctoMap/octomap), which is necessary to use OcTree. For Ubuntu, use `sudo apt-get install liboctomap-dev`.\nSecond, install FCL using the instructions provided [here](https://github.com/flexible-collision-library/fcl).\nIf you're on Ubuntu 17.04 or newer, you can install FCL using `sudo apt-get install libfcl-dev`.\nOtherwise, just compile FCL from source -- it's quick and easy, and its dependencies are all easily installed via `apt` or `brew`.\nNote: the provided install scripts (under `build_dependencies`) can automate this process as well.\n\nIn order to install the Python wrappers for FCL, simply run\n```shell\npip install python-fcl\n```\n\n## Objects\n\n### Collision Objects\nThe primary construct in FCL is the `CollisionObject`, which forms the backbone of all collision and distance computations.\nA `CollisionObject` consists of two components -- its geometry, defined by a `CollisionGeometry` object, and its pose, defined by a `Transform` object.\n\n#### Collision Geometries\nThere are two main types of `CollisionGeometry` objects -- geometric primitives, such as boxes and spheres,\nand arbitrary triangular meshes.\nHere's some examples of how to instantiate geometric primitives.\nNote that the box, sphere, ellipsoid, capsule, cone, and cylinder are all centered at the origin.\n\n```python\nimport numpy as np\nimport fcl\n\nv1 = np.array([1.0, 2.0, 3.0])\nv2 = np.array([2.0, 1.0, 3.0])\nv3 = np.array([3.0, 2.0, 1.0])\nx, y, z = 1, 2, 3\nrad, lz = 1.0, 3.0\nn = np.array([1.0, 0.0, 0.0])\nd = 5.0\n\nt = fcl.TriangleP(v1, v2, v3) # Triangle defined by three points\nb = fcl.Box(x, y, z)          # Axis-aligned box with given side lengths\ns = fcl.Sphere(rad)           # Sphere with given radius\ne = fcl.Ellipsoid(x, y, z)    # Axis-aligned ellipsoid with given radii\nc = fcl.Capsule(rad, lz)      # Capsule with given radius and height along z-axis\nc = fcl.Cone(rad, lz)         # Cone with given radius and cylinder height along z-axis\nc = fcl.Cylinder(rad, lz)     # Cylinder with given radius and height along z-axis\nh = fcl.Halfspace(n, d)       # Half-space defined by {x : <n, x> < d}\np = fcl.Plane(n, d)           # Plane defined by {x : <n, x> = d}\n```\n\nTriangular meshes are wrapped by the `BVHModel` class, and they are instantiated a bit differently.\n```python\nverts = np.array([[1.0, 1.0, 1.0],\n                  [2.0, 1.0, 1.0],\n                  [1.0, 2.0, 1.0],\n                  [1.0, 1.0, 2.0]])\ntris  = np.array([[0,2,1],\n                  [0,3,2],\n                  [0,1,3],\n                  [1,2,3]])\n\nm = fcl.BVHModel()\nm.beginModel(len(verts), len(tris))\nm.addSubModel(verts, tris)\nm.endModel()\n```\n\nIf the mesh is convex, such as the example above, you can also wrap it in the `Convex` class. Note that the instantiation is a bit different because the `Convex` class supports arbitrary polygons for each face of the convex object.\n```python\nverts = np.array([[1.0, 1.0, 1.0],\n                  [2.0, 1.0, 1.0],\n                  [1.0, 2.0, 1.0],\n                  [1.0, 1.0, 2.0]])\ntris  = np.array([[0,2,1],\n                  [0,3,2],\n                  [0,1,3],\n                  [1,2,3]])\nfaces = np.concatenate((3 * np.ones((len(tris), 1), dtype=np.int64), tris), axis=1).flatten()\nc = fcl.Convex(verts, len(tris), faces)\n```\n\n#### Transforms\nIn addition to a `CollisionGeometry`, a `CollisionObject` requires a `Transform`, which tells FCL where the `CollisionGeometry` is actually located in the world.\nAll `Transform` objects specify a rigid transformation (i.e. a rotation and a translation).\nThe translation is always a 3-entry vector, while the rotation can be specified by a 3x3 rotation matrix or a 4-entry quaternion.\n\nHere are some examples of possible ways to instantiate and manipulate a `Transform`.\n\n```python\nR = np.array([[0.0, -1.0, 0.0],\n              [1.0,  0.0, 0.0],\n              [0.0,  0.0, 1.0]])\nT = np.array([1.0, 2.0, 3.0])\nq = np.array([0.707, 0.0, 0.0, 0.707])\n\ntf = fcl.Transform()     # Default gives identity transform\ntf = fcl.Transform(q)    # Quaternion rotation, zero translation\ntf = fcl.Transform(R)    # Matrix rotation, zero translation\ntf = fcl.Transform(T)    # Translation, identity rotation\ntf = fcl.Transform(q, T) # Quaternion rotation and translation\ntf = fcl.Transform(R, T) # Matrix rotation and translation\ntf1 = fcl.Transform(tf)  # Can also initialize with another Transform\n```\n\nNow, given a `CollisionGeometry` and a `Transform`, we can create a `CollisionObject`:\n\n```python\nt = fcl.Transform(R, T)\nb = fcl.Box(x, y, z)\nobj = fcl.CollisionObject(b, t)\n```\n\nThe transform of a collision object can be modified in-place:\n```python\nt1 = fcl.Transform(R1, T1)\nobj.setTransform(t1)   # Using a transform\nobj.setRotation(R2)    # Specifying components individually\nobj.setTranslation(T2)\nobj.setQuatRotation(q2)\n```\n## Commands\n\n### Pairwise Operations\n\nGiven a pair of collision objects, this library supports three types of queries:\n* __Collision Detection__\n* __Distance Computation__\n* __Continuous Collision Detection__\n\nThe interfaces for each of these operations follow a common pipeline.\nFirst, a query request data structure is initialized and populated with parameters.\nThen, an empty query response structure is initialized.\nFinally, the query function is called with the two `CollisionObject` items, the request structure, and the response structure as arguments.\nThe query function returns a scalar result, and any additional information is stored in the query result data structure.\nExamples of all three operations are shown below.\n\n#### Collision Checking\n\n```python\ng1 = fcl.Box(1,2,3)\nt1 = fcl.Transform()\no1 = fcl.CollisionObject(g1, t1)\n\ng2 = fcl.Cone(1,3)\nt2 = fcl.Transform()\no2 = fcl.CollisionObject(g2, t2)\n\nrequest = fcl.CollisionRequest()\nresult = fcl.CollisionResult()\n\nret = fcl.collide(o1, o2, request, result)\n```\n\nAfter calling `fcl.collide()`, `ret` contains the number of contacts generated between the two objects,\nand `result` contains information about the collision and contacts.\nFor more information about available parameters for collision requests and results,\nsee `fcl/collision_data.py`.\n\n#### Distance Checking\n\n```python\ng1 = fcl.Box(1,2,3)\nt1 = fcl.Transform()\no1 = fcl.CollisionObject(g1, t1)\n\ng2 = fcl.Cone(1,3)\nt2 = fcl.Transform()\no2 = fcl.CollisionObject(g2, t2)\n\nrequest = fcl.DistanceRequest()\nresult = fcl.DistanceResult()\n\nret = fcl.distance(o1, o2, request, result)\n```\n\nAfter calling `fcl.distance()`, `ret` contains the minimum distance between the two objects\nand `result` contains information about the closest points on the objects.\nIf `ret` is negative, the objects are in collision.\nFor more information about available parameters for distance requests and results,\nsee `fcl/collision_data.py`.\n\n#### Continuous Collision Checking\n\n```python\ng1 = fcl.Box(1,2,3)\nt1 = fcl.Transform()\no1 = fcl.CollisionObject(g1, t1)\nt1_final = fcl.Transform(np.array([1.0, 0.0, 0.0]))\n\ng2 = fcl.Cone(1,3)\nt2 = fcl.Transform()\no2 = fcl.CollisionObject(g2, t2)\nt2_final = fcl.Transform(np.array([-1.0, 0.0, 0.0]))\n\nrequest = fcl.ContinuousCollisionRequest()\nresult = fcl.ContinuousCollisionResult()\n\nret = fcl.continuousCollide(o1, t1_final, o2, t2_final, request, result)\n```\n\nAfter calling `fcl.continuousCollide()`, `ret` contains the time of contact in (0,1), or 1.0 if the objects did not collide during movement from their initial poses to their final poses.\nAdditionally, `result` contains information about the collision time and status.\nFor more information about available parameters for continuous collision requests and results,\nsee `fcl/collision_data.py`.\n\n### Broadphase Checking\nIn addition to pairwise checks, FCL supports broadphase collision/distance queries between groups of objects and can avoid n-squared complexity.\nSpecifically, `CollisionObject` items are registered with a `DynamicAABBTreeCollisionManager` before collision or distance checking is performed.\n\nThree types of checks are possible:\n* One-to-many: Collision/distance checking between a stand-alone `CollisionObject` and all objects managed by a manager.\n* Internal many-to-many: Pairwise collision/distance checking between all pairs of objects managed by a manager.\n* Group many-to-many: Pairwise collision/distance checking between items from two managers.\n\nIn general, the collision methods can return all contact pairs, while the distance methods will just return the single closest distance between any pair of objects.\nHere are some examples of managed collision checking.\nThe methods take a callback function -- use the defaults from `python-fcl` unless you have a special use case -- and a wrapper object, either `CollisionData` or `DistanceData`, that wraps a request-response pair. This object also has a field, `done`, that tells the recursive collision checker when to quit.\nBe sure to use a new `Data` object for each request or set the `done` attribute to `False` before reusing one.\n\n```python\nobjs1 = [fcl.CollisionObject(box), fcl.CollisionObject(sphere)]\nobjs2 = [fcl.CollisionObject(cone), fcl.CollisionObject(mesh)]\n\nmanager1 = fcl.DynamicAABBTreeCollisionManager()\nmanager2 = fcl.DynamicAABBTreeCollisionManager()\n\nmanager1.registerObjects(objs1)\nmanager2.registerObjects(objs2)\n\nmanager1.setup()\nmanager2.setup()\n\n#=====================================================================\n# Managed internal (sub-n^2) collision checking\n#=====================================================================\ncdata = fcl.CollisionData()\nmanager1.collide(cdata, fcl.defaultCollisionCallback)\nprint 'Collision within manager 1?: {}'.format(cdata.result.is_collision)\n\n##=====================================================================\n## Managed internal (sub-n^2) distance checking\n##=====================================================================\nddata = fcl.DistanceData()\nmanager1.distance(ddata, fcl.defaultDistanceCallback)\nprint 'Closest distance within manager 1?: {}'.format(ddata.result.min_distance)\n\n#=====================================================================\n# Managed one to many collision checking\n#=====================================================================\nreq = fcl.CollisionRequest(num_max_contacts=100, enable_contact=True)\nrdata = fcl.CollisionData(request = req)\n\nmanager1.collide(fcl.CollisionObject(mesh), rdata, fcl.defaultCollisionCallback)\nprint 'Collision between manager 1 and Mesh?: {}'.format(rdata.result.is_collision)\nprint 'Contacts:'\nfor c in rdata.result.contacts:\n    print '\\tO1: {}, O2: {}'.format(c.o1, c.o2)\n\n#=====================================================================\n# Managed many to many collision checking\n#=====================================================================\nrdata = fcl.CollisionData(request = req)\nmanager1.collide(manager2, rdata, fcl.defaultCollisionCallback)\nprint 'Collision between manager 1 and manager 2?: {}'.format(rdata.result.is_collision)\nprint 'Contacts:'\nfor c in rdata.result.contacts:\n    print '\\tO1: {}, O2: {}'.format(c.o1, c.o2)\n```\n\n### Extracting Which Objects Are In Collision\n\nTo determine which objects are actually in collision, you'll need parse the collision data's contacts and use an additional external data structure.\n\nSpecifically, the `fcl.CollisionData` object that is passed into any `collide()` call has an internal set of contacts, stored in `cdata.result.contacts`.\nThis object is a simple list of `Contact` objects, each of which represents a contact point between two objects.\nEach 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.\nThis is a bit wonky, but it's part of the FCL API.\n\nTherefore, 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.\nThen, 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.\n\nHere's an example.\n\n```python\nimport fcl\nimport numpy as np\n\n# Create collision geometry and objects\ngeom1 = fcl.Cylinder(1.0, 1.0)\nobj1 = fcl.CollisionObject(geom1)\n\ngeom2 = fcl.Cylinder(1.0, 1.0)\nobj2 = fcl.CollisionObject(geom2, fcl.Transform(np.array([0.0, 0.0, 0.3])))\n\ngeom3 = fcl.Cylinder(1.0, 1.0)\nobj3 = fcl.CollisionObject(geom3, fcl.Transform(np.array([0.0, 0.0, 3.0])))\n\ngeoms = [geom1, geom2, geom3]\nobjs = [obj1, obj2, obj3]\nnames = ['obj1', 'obj2', 'obj3']\n\n# Create map from geometry IDs to objects\ngeom_id_to_obj = { id(geom) : obj for geom, obj in zip(geoms, objs) }\n\n# Create map from geometry IDs to string names\ngeom_id_to_name = { id(geom) : name for geom, name in zip(geoms, names) }\n\n# Create manager\nmanager = fcl.DynamicAABBTreeCollisionManager()\nmanager.registerObjects(objs)\nmanager.setup()\n\n# Create collision request structure\ncrequest = fcl.CollisionRequest(num_max_contacts=100, enable_contact=True)\ncdata = fcl.CollisionData(crequest, fcl.CollisionResult())\n\n# Run collision request\nmanager.collide(cdata, fcl.defaultCollisionCallback)\n\n# Extract collision data from contacts and use that to infer set of\n# objects that are in collision\nobjs_in_collision = set()\n\nfor contact in cdata.result.contacts:\n    # Extract collision geometries that are in contact\n    coll_geom_0 = contact.o1\n    coll_geom_1 = contact.o2\n\n    # Get their names\n    coll_names = [geom_id_to_name[id(coll_geom_0)], geom_id_to_name[id(coll_geom_1)]]\n    coll_names = tuple(sorted(coll_names))\n    objs_in_collision.add(coll_names)\n\nfor coll_pair in objs_in_collision:\n    print('Object {} in collision with object {}!'.format(coll_pair[0], coll_pair[1]))\n```\n\n```\n>>> Object obj1 in collision with object obj2!\n```\nFor more examples, see `examples/example.py`.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A fork of Python bindings for the Flexible Collision Library that adds support for pointcloud data.",
    "version": "0.7.0.6",
    "project_urls": {
        "Homepage": "https://github.com/automatika-robotics/python-fcl"
    },
    "split_keywords": [
        "fcl",
        "collision",
        "distance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a80b0aa634b5a9c801c28aefeb89545566b6d7cb1931119abc6045d6413458a",
                "md5": "0ab848ad4e455e0c1d2ceb4f3d9f926f",
                "sha256": "58580bc36462fdb703a1422a16b834dbeedf6f2e371c9afc41ae7c5cb2fb83c8"
            },
            "downloads": -1,
            "filename": "python_fcl_fork-0.7.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "0ab848ad4e455e0c1d2ceb4f3d9f926f",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": "<3.13,>=3.7",
            "size": 4357519,
            "upload_time": "2024-10-28T17:37:12",
            "upload_time_iso_8601": "2024-10-28T17:37:12.825961Z",
            "url": "https://files.pythonhosted.org/packages/7a/80/b0aa634b5a9c801c28aefeb89545566b6d7cb1931119abc6045d6413458a/python_fcl_fork-0.7.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82ba4c70b9e65a500a33afe166f3ff4b0ca1b373bb64467dce811bbaf3bbbe4c",
                "md5": "627e9870604154d883841dcee62fe553",
                "sha256": "82db39e408976b33f0286ef0455145c58074f235cf380f814bf323dfea61af16"
            },
            "downloads": -1,
            "filename": "python_fcl_fork-0.7.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "627e9870604154d883841dcee62fe553",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": "<3.13,>=3.7",
            "size": 4420133,
            "upload_time": "2024-10-28T17:37:28",
            "upload_time_iso_8601": "2024-10-28T17:37:28.483507Z",
            "url": "https://files.pythonhosted.org/packages/82/ba/4c70b9e65a500a33afe166f3ff4b0ca1b373bb64467dce811bbaf3bbbe4c/python_fcl_fork-0.7.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53c96489ff5554a7ae45036efe75a0a174658b30ff03a093532a89e9ae125b21",
                "md5": "fa1666fc272f92f7ec7670960b318207",
                "sha256": "6e2f645ae63c4e9232b1f087f31f521f9529f0815307141faa394e1dd2ebf288"
            },
            "downloads": -1,
            "filename": "python_fcl_fork-0.7.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "fa1666fc272f92f7ec7670960b318207",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": "<3.13,>=3.7",
            "size": 4379528,
            "upload_time": "2024-10-28T17:37:30",
            "upload_time_iso_8601": "2024-10-28T17:37:30.346999Z",
            "url": "https://files.pythonhosted.org/packages/53/c9/6489ff5554a7ae45036efe75a0a174658b30ff03a093532a89e9ae125b21/python_fcl_fork-0.7.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68b1b42b22fe0885d49a16556a54970cfd7d110b66fe333c5b279367065e7bdf",
                "md5": "1a7c34fb6c69af32a2e25e9575cb2ede",
                "sha256": "d6785c93d4a3ff148dfb3525f4f2f8990068564074ccacfb56e9239db6f65df9"
            },
            "downloads": -1,
            "filename": "python_fcl_fork-0.7.0.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "1a7c34fb6c69af32a2e25e9575cb2ede",
            "packagetype": "bdist_wheel",
            "python_version": "cp37",
            "requires_python": "<3.13,>=3.7",
            "size": 4297295,
            "upload_time": "2024-10-28T17:37:32",
            "upload_time_iso_8601": "2024-10-28T17:37:32.307758Z",
            "url": "https://files.pythonhosted.org/packages/68/b1/b42b22fe0885d49a16556a54970cfd7d110b66fe333c5b279367065e7bdf/python_fcl_fork-0.7.0.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "472616b2ea96ec96608e2d5416b833027e1afdc079bbea3d45fa1c8ca2277bce",
                "md5": "176c1ad7dbad951ae522f5844de92695",
                "sha256": "05835e61884fb8362b12cdaa93727eb13c7b1dc7da319de389260395bc702219"
            },
            "downloads": -1,
            "filename": "python_fcl_fork-0.7.0.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "176c1ad7dbad951ae522f5844de92695",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": "<3.13,>=3.7",
            "size": 4366466,
            "upload_time": "2024-10-28T17:37:34",
            "upload_time_iso_8601": "2024-10-28T17:37:34.580477Z",
            "url": "https://files.pythonhosted.org/packages/47/26/16b2ea96ec96608e2d5416b833027e1afdc079bbea3d45fa1c8ca2277bce/python_fcl_fork-0.7.0.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "431a6b6dd949ae5a8bda4c0570635beb926621393f5fb8cb67be397533aba3f0",
                "md5": "cec116c28ab395f0719e7842b6065231",
                "sha256": "6d3ef97756a4d39b4f367e1526146d3170786cd95ee9249e6e9a0a541ff068fe"
            },
            "downloads": -1,
            "filename": "python_fcl_fork-0.7.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "cec116c28ab395f0719e7842b6065231",
            "packagetype": "bdist_wheel",
            "python_version": "cp39",
            "requires_python": "<3.13,>=3.7",
            "size": 4370081,
            "upload_time": "2024-10-28T17:37:36",
            "upload_time_iso_8601": "2024-10-28T17:37:36.421373Z",
            "url": "https://files.pythonhosted.org/packages/43/1a/6b6dd949ae5a8bda4c0570635beb926621393f5fb8cb67be397533aba3f0/python_fcl_fork-0.7.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 17:37:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "automatika-robotics",
    "github_project": "python-fcl",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "python-fcl-fork"
}
        
Elapsed time: 1.32229s