Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Advice on Speeding up AddGeometry Method

#1
I have an application where I call the `AddGeometry` method an extremely large number of times (ballpark 100 million). I have tried doing this both from the Python API and the C API and the speeds are still very slow.

The AddGeometry method is being called for a small STL (20 vertices // 36 faces), being attached to a much larger object (8.5kvertices // 16k faces).

I have some options for reducing the resolution of each object, but that is not my preference unless it may achieve dramatic results.

If it is helpful, I have the ability to cache the results that I am using to determine the objects to attach and locations/orientations to attach them into potentially very large batches. Ex: instead of `AddGeometry(fromitem, pose)`, I could store up a large cache and do `AddGeometry(fromitem, list_of_1e5_poses)`.

Any advice on how I may speed things up?
#2
Did you see any improvement with the speed when using the C API over the Python API?

Did you try using STL or PLY files instead? For example, you could save to a binary STL or PLY and the load it with RoboDK using AddFile. 

You can find some examples here:
https://robodk.com/doc/en/PythonAPI/exam...nstruction

Example code using Open3D:
Code:
# Import the mesh into RoboDK
with TemporaryDirectory(prefix='robodk_') as td:
    tf = td + '/mesh.ply'
    o3d.io.write_triangle_mesh(tf, mesh_poisson, write_ascii=True)
    mesh_item = RDK.AddFile(tf)
#3
Another hint, if you are adding shapes in 3D (meshes), the AddShape is much faster with the latest version of RoboDK compared to previous versions.

You can find more information about the AddShape function here:
https://robodk.com/doc/en/PythonAPI/robo...k.AddShape
#4
Thanks for the advice, Albert.

I saw some improvement with the C API, but my guess is that the operation of adding the shapes takes longer than the API call, so the C API can only help up to a point.

I've got a couple ideas that I need to play around with. .ply files may work, but there are some limitations there that I would have to get around. Specifically, color of the displayed objects is important for my application.

To this end, I would like to request that AddShape be made available in the C API.
#5
Hi Albert,

I implemented a solution using AddShape. Unfortunately, it looks like I am running into timeouts. I increased the timeout to 300 seconds, but even then it failed to finish before the timeout. I am passing a Mat of size (3, 4961844) to AddShape. I assume that's just way beyond the size that this function was designed for. Is that consistent with what you would expect?

I also tried writing the open3d mesh to a .ply file then added that .ply file to RoboDK. That worked a lot better, taking only about 30 seconds for the same data.

I have a few more knobs to turn with multiprocessing, so I think I will be able to get it down into an acceptable range with more work.
#6
Can you send us an example to replicate these issues using AddShape and/or AddGeometry? We can investigate further and try to improve speed.

One quick workaround would be to increase the timeout of AddShape.
#7
Hi Albert, thanks for getting back to me. I will generate a minimum example, probably later this week. What I send will probably be a pickled numpy array. I will have to send it over email since it contains proprietary geometry.
  




Users browsing this thread:
1 Guest(s)