ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Which parameter I should use to check for collision detection

asked 2015-02-18 01:40:11 -0600

RSA_kustar gravatar image

Hi,

I am using the fcl library to detect collisions between two objects I used the following code:

    bool flag = false ; 
    collisionObject co0(Shpere0, tf0);
    std::vector<CollisionObject*> boxes;
    generateBoxesFromOctomap(boxes, *st_tree);


           for(size_t i = 0; i < boxes.size(); ++i)
           {

               bool res2 = solver.shapeIntersect(*Shpere0, tf0, *boxes[i], tf1, &contact_points, &penetration_depth, &normal);
              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);
    //       flag = fcl::collide(&co0, &co1, request, result);
    //            OR 
    //       flag = res1 ;

      }

Which value is the right one ? I want if flag = true then there is a collision and if flag == false then there is no collision .. so which one is the write one ????

    //       flag = fcl::collide(&co0, &co1, request, result);
    //            OR 
    //       flag = res1
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-02-18 02:40:42 -0600

Morgane gravatar image

I am very new and I am answering with every doubt, but following fcl:


// Given two objects o1 and o2

CollisionObject* o1 = ...

CollisionObject* o2 = ...

// set the collision request structure, here we just use the default setting

CollisionRequest request;

// result will be returned via the collision result structure

CollisionResult result;

// perform collision test

collide(o1, o2, request, result);

By setting the collision request, the user can easily choose whether to return contact information (which is slower) or just return binary collision results (which is faster).


I have come to understand that flag is necessary only to validate that collision test was performed successfully. What you are looking for (the outcome of collision) is the result variable.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-18 01:40:11 -0600

Seen: 367 times

Last updated: Feb 18 '15