Pendulum¶
A simple inverted pendulum environment.
-
class
jax_agents.environments.pendulum.PendulumEnv(seed=1996)¶ Bases:
objectThe pendulum starts almost upright, the goal is to prevent falling down.
- States:
- Type: Box(4) Num State Min Max 0 Pendulum Angle 0(downward) 2 pi 2 Pendulum Angular Velocity -Inf Inf
- Actions:
- Type: Box(1) Num Action Min Max 0 Torque -4.0 4.0
- Orientation:
- angle: pi/2 -> to the right angular velocity: positive -> counterclockwise
- Reward:
- Reward is 1 for every step in the upright position, -0.1 otherwise
- Starting State:
- Angle = pi + (-10, +10) (i.e. pointing upwards) Velocity = 0.0
- Episode Length:
- 10 seconds, i.e. 200 steps at 20 Hz
-
check_if_done(state)¶ Check if episode needs to restart.
-
initialize_rendering(log, fig)¶ Initialize Matplotlib axes for rendering.
-
norm_state(state)¶ Norm the state to have zero mean and unit variance.
-
pendulum_dynamics(state, action)¶ Environment’s dynamics. Return the derivative of the state.
-
render(log)¶ Render the given timestep.
-
rescale_action(scaled_action)¶ Rescale the action from the policy (which are between -1 and 1).
-
reset()¶ Reset the state to start a new episode.
-
reward_func(state, action, next_state)¶ Return the reward for the given transition.
-
step(state, action)¶ Integrate the dynamics on step forward.