Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use fcl.OcTree in python-fcl. #35

Open
ryanreadbooks opened this issue Sep 28, 2021 · 10 comments · May be fixed by #79
Open

How to use fcl.OcTree in python-fcl. #35

ryanreadbooks opened this issue Sep 28, 2021 · 10 comments · May be fixed by #79

Comments

@ryanreadbooks
Copy link

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!

@cedriclmenard
Copy link

cedriclmenard commented Jun 14, 2022

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

@giacko93
Copy link

giacko93 commented Jul 12, 2022

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 !

@cedriclmenard
Copy link

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.

@geekyp99
Copy link

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)

@zichunxx
Copy link

zichunxx commented Oct 22, 2022

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!

@cedriclmenard
Copy link

cedriclmenard commented Nov 26, 2022

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

@jacky-ch93
Copy link

jacky-ch93 commented Jul 26, 2023

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!

@giacomogolluccio
Copy link

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

@giacomogolluccio
Copy link

giacomogolluccio commented Feb 1, 2024

@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?

@mkabtoul
Copy link

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

@aleph-ra aleph-ra linked a pull request May 25, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants