Check collision between a mesh and a set of points.
ambitious-octopus opened this issue ยท 0 comments
Good job the package you are developing is very interesting, I appreciate your work. ๐
I am looking for a fast way to compute the collision between a mesh and a set of points. I am currently using the RaycastingScene() class from open3d. Unfortunately, the computation turns out to be quite slow for what I need. I was wondering if your package offers a more efficient system for the computation I need. I welcome suggestions on how to make this computation more efficient.
This is a minimal example with open3d:
import open3d as o3d
import numpy as np
mesh = o3d.geometry.TriangleMesh.create_sphere(0.2)
frame = o3d.geometry.TriangleMesh.create_coordinate_frame(0.3)
points = np.array([[-0.1, -0.1, -0.1],
[0.05, 0.05, 0.05],
[0.01, 0.01, 0.01],
[0.1, 0.1, 0.1],
[0.2, 0.2, 0.2]])
pcd = o3d.geometry.PointCloud(o3d.utility.Vector3dVector(points))
pcd.paint_uniform_color([1, 0, 0])
scene = o3d.t.geometry.RaycastingScene()
mesh_legacy = o3d.t.geometry.TriangleMesh.from_legacy(mesh)
_ = scene.add_triangles(mesh_legacy) # we do not need the geometry ID for mesh
query_points = points.astype(np.float32)
occupancy = scene.compute_occupancy(query_points, 16)
print(occupancy.numpy())
o3d.visualization.draw_geometries([mesh, frame, pcd])
I have seen this script before, but unfortunately I get an error (issue #118):
cupoch/examples/python/robotics/collision_voxelgrid.py
Lines 1 to 46 in 6f4290f
Thank you for your support.