-
Jeongseok Lee authoredJeongseok Lee authored
FCL is a library for performing three types of proximity queries on a pair of geometric models composed of triangles.
- Collision detection: detecting whether the two models overlap, and optionally, all of the triangles that overlap.
- Distance computation: computing the minimum distance between a pair of models, i.e., the distance between the closest pair of points.
- Tolerance verification: determining whether two models are closer or farther than a tolerance distance.
- Continuous collision detection: detecting whether the two moving models overlap during the movement, and optionally, the time of contact.
- Contact information: for collision detection and continuous collision detection, the contact information (including contact normals and contact points) can be returned optionally.
FCL has the following features
- C++ interface, heavily use the boost
- Compilable for either linux or win32 (both makefiles and Microsoft Visual projects can be generated using cmake)
- No special topological constraints or adjacency information required for input models – all that is necessary is a list of the model's triangles
- Supported different object shapes:
- sphere
- box
- cone
- cylinder
- mesh
- octree (optional, octrees are represented using the octomap library http://octomap.github.com)
Installation
Before compiling FCL, please make sure boost and libccd (for collision checking between convex objects and is available here https://github.com/danfis/libccd) are installed. For libccd, make sure to compile from github version instead of the zip file from the webpage, because one bug fixing is not included in the zipped version.
Some optional libraries need to be installed for some optional capability of FCL. For octree collision, please install the octomap library from http://octomap.github.com. For global penetration depth, please install FLANN from https://github.com/mariusmuja/flann. For global penetration depth test, please install tinyxml.
CMakeLists.txt is used to generate makefiles in Linux or Visual studio projects in windows. In command line, run
mkdir build
cd build
cmake ..
Next, in linux, use make to compile the code.
In windows, there will generate a visual studio project and then you can compile the code.
Interfaces
Before starting the proximity computation, we need first to set the geometry and transform for the objects involving in computation. The geometry of an object is represented as a mesh soup, which can be set as follows:
// set mesh triangles and vertice indices
std::vector<Vec3f> vertices;
std::vector<Triangle> triangles;
// code to set the vertices and triangles
...
// BVHModel is a template class for mesh geometry, for default OBBRSS template is used
typedef BVHModel<OBBRSS> Model;
Model* model = new Model();
// add the mesh data into the BVHModel structure
model->beginModel();
model->addSubModel(vertices, triangles);
model->endModel();
The transform of an object includes the rotation and translation:
// R and T are the rotation matrix and translation vector
Matrix3f R;
Vec3f T;
// code for setting R and T
...
// transform is configured according to R and T
Transform3f pose(R, T);
Given the geometry and the transform, we can also combine them together to obtain a collision object instance and here is an example:
//geom and tf are the geometry and the transform of the object
BVHModel<OBBRSS>* geom = ...
Transform3f tf = ...
//Combine them together
CollisionObject* obj = new CollisionObject(geom, tf);