Go to the documentation of this file.
   38 #define BOOST_TEST_MODULE COAL_OCTREE 
   40 #include <boost/test/included/unit_test.hpp> 
   41 #include <boost/filesystem.hpp> 
   52 #include "fcl_resources/config.h" 
   54 namespace utf = boost::unit_test::framework;
 
   58 void makeMesh(
const std::vector<Vec3s>& vertices,
 
   79   for (
CoalScalar x = resolution * floor(
m[0] / resolution); 
x <= 
M[0];
 
   81     for (
CoalScalar y = resolution * floor(
m[1] / resolution); 
y <= 
M[1];
 
   83       for (
CoalScalar z = resolution * floor(
m[2] / resolution); z <= 
M[2];
 
   85         Vec3s center(
x + .5 * resolution, 
y + .5 * resolution,
 
   90           octomap::point3d p((
float)center[0], (
float)center[1],
 
   92           octree->updateNode(p, 
true);
 
   99   octree->updateInnerOccupancy();
 
  100   octree->writeBinary(
"./env.octree");
 
  105   Eigen::IOFormat tuple(Eigen::FullPrecision, Eigen::DontAlignCols, 
"", 
", ",
 
  108   std::vector<Vec3s> pRob, pEnv;
 
  109   std::vector<Triangle> tRob, tEnv;
 
  122       coal::loadOctreeFile((
path / 
"env.octree").
string(), resolution));
 
  124   std::cout << 
"Finished loading octree." << std::endl;
 
  128     BOOST_CHECK(envOctree == envOctree);
 
  129     BOOST_CHECK(envOctree == 
OcTree(envOctree));
 
  132     BOOST_CHECK(envOctree == envOctree_from_tree);
 
  137     const std::vector<uint8_t> bytes = envOctree.
tobytes();
 
  138     BOOST_CHECK(bytes.size() > 0 && bytes.size() <= envOctree.
toBoxes().size() *
 
  142   std::vector<Transform3s> transforms;
 
  144 #ifndef NDEBUG  // if debug mode 
  147   std::size_t N = 10000;
 
  150                      utf::master_test_suite().argv, N);
 
  155   for (std::size_t i = 0; i < N; ++i) {
 
  167     BOOST_CHECK(!resMesh || resOctree);
 
  168     if (!resMesh && resOctree) {
 
  172       std::cout << 
"distance mesh mesh: " << dres.
min_distance << std::endl;
 
  179   Eigen::IOFormat tuple(Eigen::FullPrecision, Eigen::DontAlignCols, 
"", 
", ",
 
  182   std::vector<Vec3s> pEnv;
 
  183   std::vector<Triangle> tEnv;
 
  194       coal::loadOctreeFile((
path / 
"env.octree").
string(), resolution));
 
  196   std::cout << 
"Finished loading octree." << std::endl;
 
  200   const int nx = 100, ny = 100;
 
  201   const CoalScalar max_altitude = 1., min_altitude = 0.;
 
  202   const MatrixXs heights = MatrixXs::Constant(ny, nx, max_altitude);
 
  207   std::vector<Transform3s> transforms;
 
  209 #ifndef NDEBUG  // if debug mode 
  210   std::size_t N = 1000;
 
  212   std::size_t N = 100000;
 
  215                      utf::master_test_suite().argv, N);
 
  220   for (std::size_t i = 0; i < N; ++i) {
 
  238     BOOST_CHECK(resBox == resHfield);
 
  240     if (!resBox && resHfield) {
 
  244       std::cout << 
"distance mesh box: " << dres.
min_distance << std::endl;
 
  
int beginModel(unsigned int num_tris=0, unsigned int num_vertices=0)
Begin a new BVH model.
std::vector< Vec6s > toBoxes() const
transform the octree into a bunch of boxes; uncertainty information is kept in the boxes....
Eigen::Matrix< CoalScalar, 3, 1 > Vec3s
SplitMethodType
Three types of split algorithms are provided in FCL as default.
int endModel()
End BVH model construction, will build the bounding volume hierarchy.
void makeMesh(const std::vector< Vec3s > &vertices, const std::vector< Triangle > &triangles, BVHModel< OBBRSS > &model)
bool isCollision() const
return binary collision result
std::vector< uint8_t > tobytes() const
Returns a byte description of *this.
COAL_DLLAPI OcTreePtr_t makeOctree(const Eigen::Matrix< CoalScalar, Eigen::Dynamic, 3 > &point_cloud, const CoalScalar resolution)
Build an OcTree from a point cloud and a given resolution.
COAL_DLLAPI CoalScalar distance(const Matrix3s &R0, const Vec3s &T0, const kIOS &b1, const kIOS &b2, Vec3s *P=NULL, Vec3s *Q=NULL)
Approximate distance between two kIOS bounding volumes.
A class describing the split rule that splits each BV node.
int addSubModel(const std::vector< Vec3s > &ps, const std::vector< Triangle > &ts)
Add a set of triangles in the new BVH model.
void computeLocalAABB()
Compute the AABB for the HeightField, used for broad-phase collision.
Center at zero point, axis aligned box.
Vec3s max_
The max point in the AABB.
COAL_DLLAPI void constructBox(const AABB &bv, Box &box, Transform3s &tf)
construct a box shape (with a configuration) from a given bounding volume
CoalScalar min_distance
minimum distance between two objects. If two objects are in collision and DistanceRequest::enable_sig...
request to the distance computation
void clear()
clear the results obtained
AABB aabb_local
AABB in local coordinate, used for tight AABB when only translation transform.
request to the collision algorithm
BOOST_AUTO_TEST_CASE(octree_mesh)
void computeLocalAABB()
Compute the AABB for the BVH, used for broad-phase collision.
shared_ptr< BVSplitter< BV > > bv_splitter
Split rule to split one BV node into two children.
void generateRandomTransforms(CoalScalar extents[6], std::vector< Transform3s > &transforms, std::size_t n)
Generate n random transforms whose translations are constrained by extents.
Data structure depicting a height field given by the base grid dimensions and the elevation along the...
Eigen::Matrix< CoalScalar, Eigen::Dynamic, Eigen::Dynamic > MatrixXs
Vec3s min_
The min point in the AABB.
shared_ptr< OcTree > OcTreePtr_t
A class describing the bounding hierarchy of a mesh model or a point cloud model (which is viewed as ...
Octree is one type of collision geometry which can encode uncertainty information in the sensor data.
shared_ptr< const octomap::OcTree > getTree() const
Returns the tree associated to the underlying octomap OcTree.
COAL_DLLAPI std::size_t collide(const CollisionObject *o1, const CollisionObject *o2, const CollisionRequest &request, CollisionResult &result)
Main collision interface: given two collision objects, and the requirements for contacts,...
std::size_t getNbRun(const int &argc, char const *const *argv, std::size_t defaultValue)
Get the argument –nb-run from argv.
void loadOBJFile(const char *filename, std::vector< Vec3s > &points, std::vector< Triangle > &triangles)
Load an obj mesh file.
hpp-fcl
Author(s): 
autogenerated on Fri Feb 14 2025 03:45:51