我想尝试学习使用fcl库,但是当我尝试进行距离查询时,出现了堆栈溢出问题。 我按照网络自述教程界面进行编程。 https://github.com/flexible-collision-library/fcl#interfaces
这是我的代码。
#include <iostream>
#include "fcl/math/bv/utility.h"
#include "fcl/narrowphase/collision.h"
#include "fcl/narrowphase/detail/gjk_solver_indep.h"
#include "fcl/narrowphase/detail/gjk_solver_libccd.h"
#include "fcl/narrowphase/detail/traversal/collision_node.h"
#include "fcl/narrowphase/continuous_collision.h"
#include "corecrt_math_defines.h"
#include "test_fcl_utility.h"
#include "fcl_resources/config.h"
using namespace std;
using namespace fcl;
using namespace Eigen;
int main()
{
std::vector<fcl::Vector3f> p1, p2;
std::vector<Triangle> t1, t2;
fcl::test::loadOBJFile("OBJModel/cubic1.obj", p1, t1);
fcl::test::loadOBJFile("OBJModel/cubic1.obj", p2, t2);
typedef BVHModel<OBBRSSf> Model;
shared_ptr<Model> arm0 = make_shared<Model>();
shared_ptr<Model> arm1 = make_shared<Model>();
arm0->beginModel();
arm0->addSubModel(p1, t1);
arm0->endModel();
arm1->beginModel();
arm1->addSubModel(p2, t2);
arm1->endModel();
Vector3f T0 = Vector3f(3.,3,3);
Vector3f T1;
T1 << 3., 0, 0;
Transform3f tf0 = Transform3f::Identity();
tf0.translation() = T0;
Transform3f tf1 = Transform3f::Identity();
tf1.translation() = T1;
CollisionObjectf* obj0 = new CollisionObjectf(arm0, tf0);
CollisionObjectf* obj1 = new CollisionObjectf(arm1, tf1);
// set the distance request structure, here we just use the default setting
DistanceRequestf request;
// result will be returned via the collision result structure
DistanceResultf result;
// perform distance test
distance(obj0, obj1, request, result);
cout << result.min_distance << endl;
}
当我运行 distance(obj0, obj1, request, result);
Problem occured 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x0000002DD6403F70)。
我还找到了一个github代码,和我的类似。我找不到任何不同的地方。
我检查了调用堆栈,有很多distanceRecurse,但我不明白为什么运行了这么多distanceRecurse,我的模型只是一个立方体(222)。这是CallStack的屏幕图片。
这是递归函数:
非常感谢任何为我解决问题提供建议的人。
整箱0.6.1 0.6.1版本可以处理这个问题。现在可能是一个错误。