Mecanum Car
- class rlforge.environments.mecanum_car.MecanumCar(x_range=(-2, 2), y_range=(-2, 2), initial_state=(0, 0, 0), target=(1, 1, 0.1), dt=0.01)
Simplified environment simulating a mecanum-wheeled car.
The MecanumCar environment models a robot with mecanum wheels that can move forward, rotate, and adjust heading. The agent’s objective is to reach a target position within a bounded workspace while minimizing positional and heading error.
Features
State space: five-dimensional vector
[x, y, theta, error, heading_error]. *x, y: car position in the plane. *theta: car orientation (wrapped to [-π, π]). *error: Euclidean distance to the target. *heading_error: difference between car orientation and target heading.Action space: discrete set of velocity commands. * Default actions: forward motion, rotate clockwise, rotate counterclockwise.
Reward: negative distance and heading error, encouraging the agent to approach the target with correct orientation.
Terminal condition: reaching the target within a tolerance radius.
Penalty: large negative reward if the car leaves the workspace bounds.
Notes
The environment uses simple kinematic equations with Euler integration.
This environment is useful for testing control policies for mobile robots.
- reset()
Reset the car to its initial state.
Returns
- observationtuple
A 5-element tuple
(state, reward, terminated, truncated, info): - state (numpy.ndarray): [x, y, theta, error, heading_error]. - reward (float): negative distance and heading error at reset. - terminated (bool): always False. - truncated (bool): always False. - info (dict or None): unused, set to None.
- step(action)
Advance the car dynamics by one time step.
Parameters
- actionint
Index of the chosen action: - 0: forward motion - 1: rotate counterclockwise - 2: rotate clockwise
Returns
- observationtuple
A 5-element tuple
(state, reward, terminated, truncated, info): - state (numpy.ndarray): [x, y, theta, error, heading_error]. - reward (float): negative distance and heading error. - terminated (bool): True if the target is reached. - truncated (bool): always False (no time limit). - info (dict or None): unused, set to None.
Notes
Position is updated using simple kinematics with orientation.
Orientation is wrapped to [-π, π].
If the car leaves the workspace bounds, it receives a large penalty and is reset to the previous state.
Reaching the target within the tolerance radius ends the episode.