Install Dependencies
> sudo apt install build-essential libpcl-dev liboctomap-dev libeigen3-dev pybind11-dev libfcl-dev libccd-dev
Build the project using cmake
> mkdir build
> cd build
> cmake ..
> make -j
The compilation process produces file called pybind_collision_detector.*.so
. This file need to be copied to be within PYTHONPATH. Note this file is not portable. It is very specific to the machine architecture and python version.
To use the API from Python:
from nerfgym.pybind_collision_detector import (
CollisionDetector,
CollisionDetectorOptions,
)
To detect collision between a point cloud and bounding box:
opt = CollisionDetectorOptions()
# specify parameter of the bounding box
bbox_sides = 1
opt.x_max = bbox_sides / 2
opt.x_min = -bbox_sides / 2
opt.y_max = bbox_sides / 2
opt.y_min = -bbox_sides / 2
opt.z_max = 1
opt.z_min = -0.6
pcd_file = "..."
c = CollisionDetector(pcd_file, opt)
# detect collision specifying x, y, z, roll, pitch, yaw of the bounding box
r = c.detectCollision(x, y, z, roll, pitch, yaw)
if r:
print("collision detected")