I want to try to learn use fcl library, but when i try to make a distance query, there was a stack overflow problem. I follow the web readme tutorial interface to program. https://github.com/flexible-collision-library/fcl#interfaces
Here is my code.
#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;
}
when i run distance(obj0, obj1, request, result);
Problem occured 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x0000002DD6403F70)。
I also find a github code, it's similar to mine. I can't find anything different.
I checked out call stack, there are lots of distanceRecurse, but I can not understand why so many distanceRecurse were run, my model is just a cubic(222).here are the screen picture of CallStack. lots of distanceRecurse in stack
This is the Recurse function:
Thank you so much to anyone who give me advice to solve my problem.
FCL 0.6.1 The version 0.6.1 can deal with this problem. It may be a bug now.