2015-02-12 71 views
0

我有两个对象。第一个对象是我的机器人,我想将它表示为一个shpere,第二个对象是具有未知形状的障碍物。我想用八叉树来表示障碍物的形状。使用fcl和ros维基碰撞检测八叉树和普通物体

如何使用fcl的api来检查这两个对象(true或false)之间的碰撞,使用fcl库使用ROS wiki的api?让机器人在移动。

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

如果我创建像

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

一个s这里对象我怎样才能spacify这个球体的中心是机器人的中心?

编辑:

我写了下面的代码,但我不知道怎么填八叉树

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); 

因此,任何建议???

回答