python-fcl icon indicating copy to clipboard operation
python-fcl copied to clipboard

Inconsistent results for continuous collision checking

Open clemense opened this issue 6 years ago • 3 comments

This program gives different results if run repeatedly:

from __future__ import print_function

import numpy as np
import fcl

def main():
    g1 = fcl.Box(1,2,3)
    t1 = fcl.Transform([-10.0, 0, 0])
    o1 = fcl.CollisionObject(g1, t1)
    t1_final = fcl.Transform(np.array([10.0, 0.0, 0.0]))

    g2 = fcl.Cone(1,3)
    t2 = fcl.Transform([0, 0, 0])
    o2 = fcl.CollisionObject(g2, t2)
    t2_final = fcl.Transform(np.array([0.0, 0.0, 0.0]))

    request = fcl.ContinuousCollisionRequest()
    result = fcl.ContinuousCollisionResult()

    ret = fcl.continuousCollide(o1, t1_final, o2, t2_final, request, result)

    return result
    
if __name__ == "__main__":
    print("FCL version: ", fcl.__version__)

    result = main()

    print("Time of contact: ", result.time_of_contact)
    print("Is colliding: ", result.is_collide)

Why?

clemense avatar Jan 19 '19 02:01 clemense

Thanks for the minimal working example. I'm not sure why this could be happening -- the Python code looks correct, so I'll need to run a CPP test and see if the issue is with FCL itself.

mmatl avatar Jan 19 '19 23:01 mmatl

Ok, I get consistent results if I use GST_INDEP as the narrow phase collision solver (request.gjk_solver_type = 1).

Just a wild guess: This might be related to this issue: https://github.com/flexible-collision-library/fcl/issues/243 (since the continuous collision check interface has a maximum number of iterations, 'hanging' might result in no detected collision)

clemense avatar Jan 23 '19 02:01 clemense

Good find. I can change the default solver to avoid that issue.

mmatl avatar Jan 23 '19 02:01 mmatl