Skip to main content

CartPole

superdex_gym/CartPole-v0 · superdex.lab.gym.envs.benchmarks.cartpole_env.CartPoleEnv

CartPole

Description​

CartPole balances a pole on a cart moving along a linear rail. It is the smallest SuperDex Gym environment and the best smoke test: it needs only the benchmark scene assets (assets/benchmarks/cart_pole/) and no bot asset.

Action Space​

The action is a (1,) Box. The single element control is bounded [-3.0, 3.0], scaled by 100, and applied as a linear force on the prismatic cart DOF. When actuate_on_pole=True it is applied as a torque on the revolute pole DOF instead.

Observation Space​

The observation is a (4,) Box, flattened in alphabetical key order:

IndexKeyMeaning
0angular_velAngular velocity of the pole [rad/s]
1linear_velLinear velocity of the cart [m/s]
2positionCart position along the rail [m]
3vertical_angVertical angle of the pole [rad]

Rewards​

A single term upright_reward of 1.0 is given for every step while the pole is upright (abs(vertical_ang) <= 0.2), and 0.0 otherwise.

Starting State​

The scene is restored to its captured initial state, then uniform reset noise scaled by reset_noise_scale (default 0.1) is added to the cart and pole pose and velocity.

Episode End​

The episode terminates (terminated_reason = "Pole angle exceeded threshold") once the pole leaves the upright band. It truncates at steps_per_episode.

Arguments​

In addition to the shared MochiEnvCfg fields (see the Authoring guide's base configuration section), CartPoleEnvCfg accepts:

FieldDefaultMeaning
control_frequency25Control frequency [Hz]
simulation_frequency50Simulation frequency [Hz]; 2 substeps per control step
steps_per_episode1000Truncation limit
reset_noise_scale0.1Scale of the uniform reset noise
render_controlTrueStored on the environment but currently unused
actuate_on_poleFalseApply the control force to the pole instead of the cart
use_dampingTrueApply joint viscous friction
use_gravityTrueApply gravity
free_poleFalseRemove the pole's joint limits

Scene identity​

uid_fields = (use_damping, use_gravity, free_pole). When use_shared_scenes=True, environments in the same process with matching values share one physics scene.

Variants​

CartPoleActuateOnPole​

superdex_gym/CartPoleActuateOnPole-v0

FieldValue
actuate_on_poleTrue