pNeuma_simulator.gang.collision module

pNeuma_simulator.gang.collision.collisions(ego: Particle, speed: float, theta: float, neighbors: list[Particle])[source]

Returns time to collision in seconds if defined.

Parameters:
  • ego (Particle) – ego vehicle.

  • speed (float) – check for collision at this speed

  • theta (float) – check for collision in this direction

  • neighbors (list[Particle]) – list of potentially colliding vehicles

Returns:

time to collision (or None if not defined).

Return type:

float

pNeuma_simulator.gang.collision.newton_iteration(l_j: float, w_j: float, l_i: float, w_i: float, x_j: float, y_j: float, x_i: float, y_i: float, theta_j: float, theta_i: float, vx_j: float, vy_j: float, vx_i: float, vy_i: float, max_iterations: int = 1000, tolerance: float = 0.001, delta: float = 1e-09)[source]

Perform Newton’s iteration to find the time-to-collision (TTC) between two objects.

Parameters:
  • l_j (float) – Length of object j.

  • w_j (float) – Width of object j.

  • l_i (float) – Length of object i.

  • w_i (float) – Width of object i.

  • x_j (float) – x-coordinate of object j.

  • y_j (float) – y-coordinate of object j.

  • x_i (float) – x-coordinate of object i.

  • y_i (float) – y-coordinate of object i.

  • theta_j (float) – Orientation angle of object j.

  • theta_i (float) – Orientation angle of object i.

  • vx_j (float) – x-component of velocity of object j.

  • vy_j (float) – y-component of velocity of object j.

  • vx_i (float) – x-component of velocity of object i.

  • vy_i (float) – y-component of velocity of object i.

  • max_iterations (int, optional) – Maximum number of iterations. Default is 1000.

  • tolerance (float, optional) – Desired tolerance. Default is 0.001.

  • delta (float, optional) – Small value to avoid division by zero. Default is 1e-9.

Returns:

A tuple containing:
  • float: Time-to-collision value within the desired tolerance and maximum number of iterations, or None if

    no solution is found.

  • int: Number of iterations performed, or None if no solution is found.

Return type:

tuple