Dynamic Models

JAX-compatible vehicle dynamics and low-level action conversion helpers.

Prototype of vehicle dynamics functions and classes for simulating 2D Single Track dynamic model Following the implementation of CommonRoad’s Single Track Dynamics model Original implementation: https://gitlab.lrz.de/tum-cps/commonroad-vehicle-models/ Author: Hongrui Zheng, Renukanandan Tumu

f1tenth_gym_jax.envs.dynamic_models.upper_accel_limit(vel, a_max, v_switch)

Compute the positive longitudinal acceleration limit.

Parameters:
  • vel (float) – Current vehicle speed.

  • a_max (float) – Maximum allowed acceleration magnitude.

  • v_switch (float) – Speed above which the acceleration limit decays to avoid wheel slip.

Returns:

Positive acceleration limit at the current speed.

Return type:

float

f1tenth_gym_jax.envs.dynamic_models.accl_constraints(vel, a_long_d, v_switch, a_max, v_min, v_max)

Apply velocity and acceleration bounds to desired acceleration.

Parameters:
  • vel (float) – Current vehicle speed.

  • a_long_d (float) – Unconstrained desired longitudinal acceleration.

  • v_switch (float) – Speed above which the positive acceleration limit decays.

  • a_max (float) – Maximum acceleration magnitude.

  • v_min (float) – Minimum allowed velocity.

  • v_max (float) – Maximum allowed velocity.

Returns:

Bounded longitudinal acceleration.

Return type:

float

f1tenth_gym_jax.envs.dynamic_models.steering_constraint(steering_angle, steering_velocity, s_min, s_max, sv_min, sv_max)

Apply steering angle and steering-rate bounds.

Parameters:
  • steering_angle (float) – Current front-wheel steering angle.

  • steering_velocity (float) – Unconstrained desired steering velocity.

  • s_min (float) – Minimum steering angle.

  • s_max (float) – Maximum steering angle.

  • sv_min (float) – Minimum steering velocity.

  • sv_max (float) – Maximum steering velocity.

Returns:

Bounded steering velocity.

Return type:

float

f1tenth_gym_jax.envs.dynamic_models.vehicle_dynamics_ks(x_and_u, params)

Evaluate the kinematic single-track model.

The implementation follows section 5 of the CommonRoad vehicle models reference.

Parameters:
  • x_and_u (chex.Array, shape (7,)) – State and control vector [x, y, delta, v, psi, steering_command, longitudinal_command].

  • params (Param) – Jittable simulation parameters, including geometry, control limits, action modes, and timestep.

Returns:

Right-hand side of the kinematic differential equations with two dummy control dimensions appended.

Return type:

chex.Array, shape (7,)

f1tenth_gym_jax.envs.dynamic_models.vehicle_dynamics_st_switching(x_and_u, params)

Evaluate the switching dynamic single-track model.

The implementation follows section 7 of the CommonRoad vehicle models reference and switches to a kinematic branch at low speed.

Parameters:
  • x_and_u (chex.Array, shape (9,)) – State and control vector [x, y, delta, v, psi, psi_dot, beta, steering_command, longitudinal_command].

  • params (Param) – Jittable simulation parameters, including geometry, tire coefficients, control limits, action modes, and timestep.

Returns:

Right-hand side of the single-track differential equations with two dummy control dimensions appended.

Return type:

chex.Array, shape (9,)

f1tenth_gym_jax.envs.dynamic_models.vehicle_dynamics_st_smooth(x_and_u, params)

Evaluate the smoothly blended dynamic single-track model.

The implementation follows section 7 of the CommonRoad vehicle models reference and blends the dynamic and low-speed kinematic branches.

Parameters:
  • x_and_u (chex.Array, shape (9,)) – State and control vector [x, y, delta, v, psi, psi_dot, beta, steering_command, longitudinal_command].

  • params (Param) – Jittable simulation parameters, including geometry, tire coefficients, control limits, action modes, and timestep.

Returns:

Right-hand side of the blended single-track differential equations with two dummy control dimensions appended.

Return type:

chex.Array, shape (9,)

f1tenth_gym_jax.envs.dynamic_models.sigmoid_interp(x, shift=0.55, scale=100.0)
f1tenth_gym_jax.envs.dynamic_models.pid_steer(steer, current_steer, max_sv)
f1tenth_gym_jax.envs.dynamic_models.pid_accl(speed, current_speed, max_a, max_v, min_v)

Convert desired speed to longitudinal acceleration.

Parameters:
  • speed (float) – Desired vehicle speed.

  • current_speed (float) – Current vehicle speed.

  • max_a (float) – Maximum acceleration magnitude.

  • max_v (float) – Maximum allowed velocity.

  • min_v (float) – Minimum allowed velocity.

Returns:

Desired longitudinal acceleration.

Return type:

float