0

我有两个对象。第一个对象是我的机器人,我想将它表示为一个球体,第二个对象是具有未知形状的障碍物。我想用八叉树来表示障碍物的形状。

如何使用 fcl 的 api 使用 ROS wiki 中的 api 使用 fcl 库检查这两个对象之间的冲突(真或假)?假设机器人正在移动。

此外,使用激光扫描数据检测障碍物??如何将它填充到八叉树对象中?

如果我创建了一个像

   boost::shared_ptr<Sphere> Shpere0(new Sphere(1));

我怎样才能确定这个球体的中心是机器人的中心?

编辑:

我写了以下代码,但我不知道如何填充八叉树

boost::shared_ptr<Sphere> Shpere0(new Sphere(1));
OcTree* tree = new OcTree(boost::shared_ptr<const octomap::OcTree>(generateOcTree()));
 // GJKSolver_indep solver;
GJKSolver_libccd solver;
Vec3f contact_points;
FCL_REAL penetration_depth;
Vec3f normal;
Transform3f tf0, tf1;
tf0.setIdentity();
// is this the postion in x,y and x
tf0.setTranslation(Vec3f(robotpose(0),robotpose(1),robotpose(2)));
tf0.setQuatRotation(Quaternion3f(0, 0, 0, 0));

// HOW TO FILL the OCTREE HERE with point cloud data ???  
   tf1.setIdentity();
  bool res = solver.shapeIntersect(*Shpere0, tf0, *box1, tf1, &contact_points, &penetration_depth, &normal);
 cout << "contact points: " << contact_points << endl;
 cout << "pen depth: " << penetration_depth << endl;
 cout << "normal: " << normal << endl;
 cout << "result: " << res << endl;
 static const int num_max_contacts = std::numeric_limits<int>::max();
 static const bool enable_contact = true;
 fcl::CollisionResult result;
 fcl::CollisionRequest request(num_max_contacts, enable_contact);
 CollisionObject co0(Shpere0, tf0);
 CollisionObject co1(tree, tf1);
 bool res_1 =   fcl::collide(&co0, &co1, request, result);

那么,有什么建议吗???

4

1 回答 1

0

检查这个:https ://github.com/kuri-kustar/laser_collision_detection/blob/master/src/laser_obstacle_detect.cpp#L135-L228 这个代码可以指导你。

于 2015-05-12T13:04:53.203 回答