Collision Models

JAX-compatible functions for vehicle-vehicle and vehicle-map collision checks.

Prototype of Utility functions and GJK algorithm / Separating Axis Theorem for Collision checks between vehicles Originally from https://github.com/kroitor/gjk.c Author: Hongrui Zheng

f1tenth_gym_jax.envs.collision_models.sa(normal, vertices1, vertices2)

Check whether two body projections are separated along a normal axis.

Parameters:
  • normal (chex.Array) – Axis normal used for the projection.

  • vertices1 (chex.Array, shape (n, 2)) – Vertices of the first body.

  • vertices2 (chex.Array, shape (n, 2)) – Vertices of the second body.

Returns:

True when this axis separates the two projected bodies.

Return type:

bool

f1tenth_gym_jax.envs.collision_models.collision(vertices)

Check whether two rectangular bodies overlap with SAT.

Parameters:

vertices (chex.Array, shape (4, 4)) – Concatenated vertices for two rectangular bodies. Columns 0:2 are the first body and columns 2:4 are the second body.

Returns:

True if the bodies collide.

Return type:

bool

f1tenth_gym_jax.envs.collision_models.collision_map(vertices, pixel_centers)

Check vehicle polygons against occupied map pixels.

Parameters:
  • vertices (chex.Array, shape (num_bodies, 4, 2)) – Agent rectangle vertices in counter-clockwise winding order.

  • pixel_centers (chex.Array, shape (num_pixels, 2)) – x and y positions of occupied map pixel centers.

Returns:

Boolean collision flag for each body.

Return type:

chex.Array, shape (num_bodies,)

f1tenth_gym_jax.envs.collision_models.get_trmtx(pose)

Compute the transform from vehicle frame to global frame.

Parameters:

pose (chex.Array, shape (3,)) – Vehicle pose [x, y, yaw] in world coordinates.

Returns:

Homogeneous transformation matrix.

Return type:

chex.Array, shape (4, 4)

f1tenth_gym_jax.envs.collision_models.get_vertices(pose, length, width)

Compute vehicle rectangle vertices from pose and body size.

Parameters:
  • pose (chex.Array, shape (3,)) – Vehicle pose [x, y, yaw] in world coordinates.

  • length (float) – Vehicle body length.

  • width (float) – Vehicle body width.

Returns:

Corner vertices of the vehicle body.

Return type:

chex.Array, shape (4, 2)