Class InvertedDoublePendulumEnvV5
- Namespace
- Gym.Environments.Envs.MuJoCo
- Assembly
- Gym.Environments.dll
InvertedDoublePendulum-v5: two poles chained on a cart, kept upright by a force on the cart in [-1, 1]. Each step pays the healthy reward while the tip stays above 1 m and charges its distance from the top position and the poles' angular velocities; the tip falling to 1 m ends the episode. Byte for byte what Gymnasium's InvertedDoublePendulum-v5 computes on MuJoCo 4.0.0 (DR-61, DR-64).
[PyName("InvertedDoublePendulumEnv")]
public class InvertedDoublePendulumEnvV5 : MujocoEnv, IEnv, IDisposable, IDynamicAttributes
- Inheritance
-
InvertedDoublePendulumEnvV5
- Implements
- Inherited Members
- Extension Methods
Remarks
Observation (float64, 9 values): the cart's position, the sines and cosines of the two angles, the velocities
clipped to ±10, and the cart's constraint force clipped to ±10. Reward: healthy_reward * int(not terminated) -
(0.01 * x**2 + (y - 2)**2) - (1e-3 * v1**2 + 5e-3 * v2**2) with the tip at (x, y) and the angular velocities
v1, v2, each **2 NumPy's (the C runtime's pow, not a product). Info: reward_survive (a
Python float), distance_penalty, velocity_penalty; the reset's info is empty. Its default camera
configuration is none (Gymnasium's v5 passes None).
Not thread-safe. Reference: gymnasium/envs/mujoco/inverted_double_pendulum_v5.py.
Its info reads typed (DR-91): InvertedDoublePendulumInfoV5 info = step.Info; (InvertedDoublePendulumInfoV5), with the dict's own values still behind the indexer.
Constructors
InvertedDoublePendulumEnvV5(InvertedDoublePendulumEnvV5Options)
Builds the instance from its options record: the properties set, the constructor's defaults for the rest.
public InvertedDoublePendulumEnvV5(InvertedDoublePendulumEnvV5Options options)
Parameters
optionsInvertedDoublePendulumEnvV5OptionsThe options.
Exceptions
- ArgumentNullException
Thrown when
optionsis null.
InvertedDoublePendulumEnvV5(RenderMode, string, int, IReadOnlyDictionary<string, object?>?, double, double, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)
Builds the env with the render mode given as the RenderMode enum (DR-84, DR-93), as
InvertedDoublePendulumEnvV5(string, int, IReadOnlyDictionary<string, object?>?, double, double, string?, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)
builds it from the mode's string: new InvertedDoublePendulumEnvV5(RenderMode.RgbArray) builds what
new InvertedDoublePendulumEnvV5(renderMode: "rgb_array") builds, the member reaching the env as Gymnasium's string
(Name(RenderMode)), which its RenderMode property then holds.
public InvertedDoublePendulumEnvV5(RenderMode renderMode, string xmlFile = "inverted_double_pendulum.xml", int frameSkip = 5, IReadOnlyDictionary<string, object?>? defaultCameraConfig = null, double healthyReward = 10, double resetNoiseScale = 0.1, int width = 480, int height = 480, int? cameraId = null, string? cameraName = null, int maxGeom = 1000, IReadOnlyDictionary<int, bool>? visualOptions = null, EnvViewerFactory? viewerFactory = null)
Parameters
renderModeRenderModeThe render mode, which the env must list in its
metadata["render_modes"]as for the string; it behaves exactly as its Gymnasium string does in the other constructor.xmlFilestringThe model: a bundled file name (
xml_file, DR-63).frameSkipintPhysics steps per env step (
frame_skip).defaultCameraConfigIReadOnlyDictionary<string, object>The free camera's settings (
default_camera_config); none by default.healthyRewarddoubleThe reward for each step the tip stays up (
healthy_reward).resetNoiseScaledoubleThe scale of the reset's noise (
reset_noise_scale).widthintThe rendered frame's width (
width).heightintThe rendered frame's height (
height).cameraIdint?The camera to render from (
camera_id).cameraNamestringThe camera to render from by name (
camera_name).maxGeomintThe most geoms a frame draws (
max_geom).visualOptionsIReadOnlyDictionary<int, bool>MuJoCo visual flags to switch (
visual_options).viewerFactoryEnvViewerFactoryGym.NET's
viewer_factory(DR-20) forhumanmode.
Remarks
The mode is required and comes first, so new InvertedDoublePendulumEnvV5() keeps meaning the other constructor, without a
mode; leave the mode out there for no rendering. Every other parameter means what it means there.
Exceptions
- ArgumentOutOfRangeException
Thrown for a value RenderMode does not declare (a cast integer such as
(RenderMode)99).- NotSupportedException
xmlFileis not a bundled model.- OverflowError
A frame skip of 0 (Python's
OverflowErrorderiving the frame rate).- ValueError
Both a camera id and a camera name.
InvertedDoublePendulumEnvV5(string, int, IReadOnlyDictionary<string, object?>?, double, double, string?, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)
Creates the env (Gymnasium's InvertedDoublePendulumEnv.init): the model, its spaces and the frame rate the time step gives.
public InvertedDoublePendulumEnvV5(string xmlFile = "inverted_double_pendulum.xml", int frameSkip = 5, IReadOnlyDictionary<string, object?>? defaultCameraConfig = null, double healthyReward = 10, double resetNoiseScale = 0.1, string? renderMode = null, int width = 480, int height = 480, int? cameraId = null, string? cameraName = null, int maxGeom = 1000, IReadOnlyDictionary<int, bool>? visualOptions = null, EnvViewerFactory? viewerFactory = null)
Parameters
xmlFilestringThe model: a bundled file name (
xml_file, DR-63).frameSkipintPhysics steps per env step (
frame_skip).defaultCameraConfigIReadOnlyDictionary<string, object>The free camera's settings (
default_camera_config); none by default.healthyRewarddoubleThe reward for each step the tip stays up (
healthy_reward).resetNoiseScaledoubleThe scale of the reset's noise (
reset_noise_scale).renderModestringGymnasium's
render_mode:human,rgb_array,depth_array,rgbd_tupleor null.widthintThe rendered frame's width (
width).heightintThe rendered frame's height (
height).cameraIdint?The camera to render from (
camera_id).cameraNamestringThe camera to render from by name (
camera_name).maxGeomintThe most geoms a frame draws (
max_geom).visualOptionsIReadOnlyDictionary<int, bool>MuJoCo visual flags to switch (
visual_options).viewerFactoryEnvViewerFactoryGym.NET's
viewer_factory(DR-20) forhumanmode.
Exceptions
- NotSupportedException
xmlFileis not a bundled model.- OverflowError
A frame skip of 0 (Python's
OverflowErrorderiving the frame rate).- ValueError
Both a camera id and a camera name.
Properties
ClassMetadata
Gymnasium's class attribute metadata: the four render modes, the frame rate set per instance. A new dict on every read.
public static Metadata ClassMetadata { get; }
Property Value
HealthyReward
The reward for each step the tip stays up (_healthy_reward), read every step.
[PyName("_healthy_reward")]
public double HealthyReward { get; set; }
Property Value
ResetNoiseScale
The scale of the reset's noise (_reset_noise_scale), read every reset.
[PyName("_reset_noise_scale")]
public double ResetNoiseScale { get; set; }
Property Value
Methods
ResetModel()
The episode's start (reset_model): positions init_qpos + uniform(-scale, scale, nq), then
velocities init_qvel + standard_normal(nv) * scale, drawn in that order.
protected override NDArray ResetModel()
Returns
- NDArray
The first observation.
Step(NDArray)
Applies action for FrameSkip physics steps and reports the transition (step).
public override StepResult<NDArray> Step(NDArray action)
Parameters
actionNDArrayThe force on the cart, shape
(1,), any real dtype (stored as float64).
Returns
- StepResult<NDArray>
The observation, the float64 reward, whether the tip fell to 1 m,
truncated=Falseand the info.
Exceptions
- ArgumentNullException
actionis null.- ValueError
The action is not of shape
(1,), with Gymnasium's message.