If agents collided before in a simulation, no new collision event is created when they collide again
While testing the changes of MR !187, I detected a wrong behavior of the collision detection. The following happened when I ran the highway scenario with Dynamics_CollisionPCM
component:
- Yellow agent crashed into the back of the orange agent.
- Yellow agent "bounced" lightly off orange agent and both agents started to brake while the distance in between the agents increased.
- After some time, the blue agent crashed into the yellow agent (Up to this point the simulation has reproduced the expected behavior).
- The impact of this crash pushed the yellow agent through the orange agent.
- In this simulation only two collision were detected (yellow crashing in orange & blue crashing into yellow), but three occurred (the previous two & yellow crashing again into orange).
- The yellow agent penetrating and passing through the orange agent did not affect the later one (no impulse on orange, acc & vel = 0, ...).
The reason for not detecting a collision after agents already collided before, comes from the following code snippet found in collisionDetector.cpp
:
bool CollisionDetector::DetectCollision(const WorldObjectInterface *other, AgentInterface *agent)
{
if (IsInVector(agent->GetCollisionPartners(), std::make_pair(other->GetType(), other->GetId())))
{
return false;
}
...
}
Here, the DetectCollision
method always return false if the two agents (agent
and other
) already collided in the past (the id of other
agent is in the CollisionPartners
vector of agent
). Because of this no collision event is created when yellow gets pushed into orange and can eventually pass through it.
A fix to this can probably be quite tricky. A new logic is required to remove agents from the CollisionsPartners vector after the crash is over and vehicles are not intersected anymore. But if the agents are still intersected and another impulse is given to one agent, this impulse should have an effect on all intersected agents.
Paul Romahn, on behalf of Mercedes-Benz Tech Innovation GmbH, Provider Information