python-fcl icon indicating copy to clipboard operation
python-fcl copied to clipboard

How to use fcl.OcTree in python-fcl.

Open ryanreadbooks opened this issue 4 years ago • 11 comments

Hey everyone!

I am wondering is it possible to create an octree from point cloud using fcl.OcTree, then do the collision detection using fcl.OcTree. Issue #7 mentioned the similar question, but I can't find answers there. Could you guys offer some examples on how to use this.

Thanks a lot!

ryanreadbooks avatar Sep 28 '21 14:09 ryanreadbooks

I've made a quick change to python-fcl so I can use the insertPointCloud method of octomap.OcTree. See my fork (on a branch currently) + the source change: https://github.com/cedriclmenard/python-fcl-octomap/blob/ef7553eedc71fcd3f13a6717b7681b03f61f4418/src/fcl/fcl.pyx#L460

cedriclmenard avatar Jun 14 '22 18:06 cedriclmenard

Hi, Did you have problem with octomap configuration under windows? How I can access to the method octomap.OcTree? I've build everything but I don't understand how I can import it.

Sorry, I'm new with this stuff.

Thank you !

giacko93 avatar Jul 12 '22 09:07 giacko93

Once you create the fcl.OcTree object (without arguments), you can call insertPointCloud with a points list/array (n points x 3 dimension). The given OcTree will be compatible with all the python-fcl functions you call, just like a Box, BVH or any fcl geometry.

cedriclmenard avatar Jul 27 '22 20:07 cedriclmenard

Hi Cedric, I made the changes in the python-fcl to use the insertPointCloud but I get an error while creating the fcl.OcTree object. I tried passing a single argument for r but it says 2 positional arguments required.

goem = fcl.OcTree()
File "src/fcl/fcl.pyx", line 467, in fcl.fcl.OcTree.__cinit__
TypeError: __cinit__() takes exactly 2 positional arguments (0 given)

geekyp99 avatar Oct 21 '22 14:10 geekyp99

Once you create the fcl.OcTree object (without arguments), you can call insertPointCloud with a points list/array (n points x 3 dimension). The given OcTree will be compatible with all the python-fcl functions you call, just like a Box, BVH or any fcl geometry.

Hi! Can you give an example on how to use fcl.OcTree().insertPointCloud()?

With the following code snippet

    x = np.random.random([100, 3])

    object1 = fcl.OcTree(0.2).insertPointCloud(x)
    object2 = fcl.Box(1, 2, 3)

    o1 = fcl.CollisionObject(object1, fcl.Transform())
    o2 = fcl.CollisionObject(object2, fcl.Transform())

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

    req = fcl.collide(o2, o2, request, result)

    print(req)

, I will get the error like this

o1 = fcl.CollisionObject(object1, fcl.Transform())
  File "src/fcl/fcl.pyx", line 140, in fcl.fcl.CollisionObject.__cinit__
ValueError

Help would be greatly appreciated!

zichunxx avatar Oct 22 '22 11:10 zichunxx

Once you create the fcl.OcTree object (without arguments), you can call insertPointCloud with a points list/array (n points x 3 dimension). The given OcTree will be compatible with all the python-fcl functions you call, just like a Box, BVH or any fcl geometry.

Hi! Can you give an example on how to use fcl.OcTree().insertPointCloud()?

With the following code snippet

    x = np.random.random([100, 3])

    object1 = fcl.OcTree(0.2).insertPointCloud(x)
    object2 = fcl.Box(1, 2, 3)

    o1 = fcl.CollisionObject(object1, fcl.Transform())
    o2 = fcl.CollisionObject(object2, fcl.Transform())

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

    req = fcl.collide(o2, o2, request, result)

    print(req)

, I will get the error like this

o1 = fcl.CollisionObject(object1, fcl.Transform())
  File "src/fcl/fcl.pyx", line 140, in fcl.fcl.CollisionObject.__cinit__
ValueError

Help would be greatly appreciated!

You can simply use the following if you are using my branch.

o1 = fcl.CollisionObject(fcl.OcTree(resolution, points=points))

cedriclmenard avatar Nov 26 '22 19:11 cedriclmenard

Once you create the fcl.OcTree object (without arguments), you can call insertPointCloud with a points list/array (n points x 3 dimension). The given OcTree will be compatible with all the python-fcl functions you call, just like a Box, BVH or any fcl geometry.

Hi! Can you give an example on how to use fcl.OcTree().insertPointCloud()? With the following code snippet

    x = np.random.random([100, 3])

    object1 = fcl.OcTree(0.2).insertPointCloud(x)
    object2 = fcl.Box(1, 2, 3)

    o1 = fcl.CollisionObject(object1, fcl.Transform())
    o2 = fcl.CollisionObject(object2, fcl.Transform())

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

    req = fcl.collide(o2, o2, request, result)

    print(req)

, I will get the error like this

o1 = fcl.CollisionObject(object1, fcl.Transform())
  File "src/fcl/fcl.pyx", line 140, in fcl.fcl.CollisionObject.__cinit__
ValueError

Help would be greatly appreciated!

You can simply use the following if you are using my branch.

o1 = fcl.CollisionObject(fcl.OcTree(resolution, points=points))

@STAY-Melody @geekyp99 @ryanreadbooks @giacko93 Hi,everyone. I have build the wheel for linux to use the branch and can success to use the script blew

o1 = fcl.CollisionObject(fcl.OcTree(resolution, points=points))

you can get the wheel from https://drive.google.com/drive/folders/1YrZe-YWKL5of6LwkpNIKGk2TXgA2AJ5B?usp=drive_link But I failed to build wheels on Windows。 If you also have any good solutions, please kindly share with me. Thanks!

jacky-ch93 avatar Jul 26 '23 13:07 jacky-ch93

Hi, I'm giacko93 with another account. Did you solve your problem?

giacomogolluccio avatar Jan 31 '24 13:01 giacomogolluccio

@cedriclmenard @jacky-ch93 @ryanreadbooks @zichunxx I have this error File "src/fcl/fcl.pyx", line 467, in fcl.fcl.OcTree.cinit TypeError: cinit() takes exactly 2 positional arguments (1 given)

Could you help me?

giacomogolluccio avatar Feb 01 '24 22:02 giacomogolluccio

@giacomogolluccio the python-fcl-octomap from @cedriclmenard is now 40 commits behind BerkeleyAutomation/python-fcl you can find an up to date forked version here (https://github.com/automatika-robotics/python-fcl) that includes the PointCloud support.

mkabtoul avatar May 17 '24 13:05 mkabtoul