Skip to content

fix for collision detection, if the polygons do not collide at T=0, but shortly afterwards

We had some trouble with the collision detection: under some particular edge cases,

  • CollisionDetector::CalculateCrash() would be called, because a collision had been detected between the bounding boxes of two cars
  • however, subsequently CollisionDetectionPostCrash::GetFirstContact() could not determine the first contact between the two polygons
  • subsequently, CollisionDetectionPostCrash::CreatePostCrashDynamics() could not fill in the correct values (speed, etc.) for the collision.

This is probably related to #247 (closed) - at least that is where we encountered the bug.

The reason for this bug appears to be: sometimes CalculateCrash() is called for a time T that is a few milliseconds before the actual collision of the polygons.

This fix extends the logic in GetFirstContact() The old logic was:

  • starting with T1=0, search backwards in 100ms steps, until a time T2 where both shapes do not collide
  • then search for the exact time of first contact between T1 and T2

The new behaviour adds another step before that:

  • if the polygons do not collide at T=0, search forwards and backwards to find a time T1 where both shapes do collide
  • then, as before, starting with T1, search backwards in 100ms steps, until a time T2 where both shapes do not collide
  • then, as before search for the exact time of first contact between T1 and T2

This fix also includes some log warnings and errors when the collision detection fails, and some debug log messages in the normal case. To allow logging, FrameworkModuleContainer now passes the CallbackInterface to the CollisionDetector.

Benjamin Hohl, on behalf of Mercedes-Benz Tech Innovation GmbH, Provider Information

Merge request reports

Loading