Action System

The action system handles different control input types and optional normalization.

Source: gymkhana/envs/action.py

Action space

Actions are an ndarray of shape (num_agents, 2) where each row is [longitudinal, steering]. The meaning of each column depends on the control_input config.

Control input types

control_input is a list of two strings: [longitudinal_type, steering_type].

Longitudinal (first element):

"speed"

Target velocity. Internally converted to acceleration via a P controller. Action space: [v_min, v_max].

"accl"

Direct acceleration command. Action space: [-a_max, a_max]. Recommended for RL drift training for smooth control.

Steering (second element):

"steering_angle"

Target steering angle. Internally converted to steering velocity via a bang-bang controller. Action space: [s_min, s_max].

"steering_speed"

Direct steering velocity command. Action space: [sv_min, sv_max].

Common combinations:

  • ['speed', 'steering_angle'] — default, suitable for general use and classical controllers

  • ['accl', 'steering_angle'] — recommended for RL tasks

Configuration

config = {
    'control_input': ['accl', 'steering_angle'],
    'normalize_act': True,   # Normalize action space to [-1, 1]
}

Normalization

When normalize_act is True, the action space is normalized to [-1, 1] for each dimension. The mapping depends on the action type:

  • accl: [-1, 1] maps to [-a_max, a_max]

  • speed: [-1, 1] maps to [v_min, v_max]

  • steering_angle: [-1, 1] maps to [s_min, s_max]

  • steering_speed: [-1, 1] maps to [sv_min, sv_max]

Normalization is supported for all action types and is generally recommended for RL training.

API reference

class gymkhana.envs.action.LongitudinalActionEnum(value)
Accl = 1
Speed = 2
static from_string(action: str)
class gymkhana.envs.action.LongitudinalAction(normalize: bool)
abstractmethod act(longitudinal_action: Any, **kwargs) float
property type: str
property space: Space
class gymkhana.envs.action.AcclAction(params: Dict, normalize: bool)
act(action: float, state, params) float
class gymkhana.envs.action.SpeedAction(params: Dict, normalize: bool)
act(action: float, state: ndarray, params: Dict) float
class gymkhana.envs.action.SteerAction(normalize: bool)
abstractmethod act(steer_action: Any, **kwargs) float
property type: str
property space: Space
class gymkhana.envs.action.SteeringAngleAction(params: Dict, normalize: bool)
act(action: float, state: ndarray, params: Dict) float
class gymkhana.envs.action.SteeringSpeedAction(params: Dict, normalize: bool)
act(action: float, state: ndarray, params: Dict) float
class gymkhana.envs.action.SteerActionEnum(value)
Steering_Angle = 1
Steering_Speed = 2
static from_string(action: str)
class gymkhana.envs.action.CarAction(control_mode: list[str, str], params: Dict, normalize: bool)
abstractmethod act(action: Any, **kwargs) Tuple[float, float]
property type: Tuple[str, str]
property space: Space
gymkhana.envs.action.from_single_to_multi_action_space(single_agent_action_space: Box, num_agents: int) Box