Table of Contents

Class InvertedDoublePendulumEnvV4

Namespace
Gym.Environments.Envs.MuJoCo
Assembly
Gym.Environments.dll

InvertedDoublePendulum-v4: the double pendulum of InvertedDoublePendulumEnvV5 with v4's fixed model, frame skip and noise, an alive bonus of 10 on every step (the falling one included), every constraint force in the observation and an empty info. Byte for byte what Gymnasium's InvertedDoublePendulum-v4 computes on MuJoCo 4.0.0 (DR-61, DR-64).

[PyName("InvertedDoublePendulumEnv")]
public class InvertedDoublePendulumEnvV4 : MujocoEnv, IEnv, IDisposable, IDynamicAttributes
Inheritance
InvertedDoublePendulumEnvV4
Implements
Inherited Members
Extension Methods

Remarks

Observation (float64, 11 values): the cart's position, the sines and cosines of the two angles, the velocities and the constraint forces, both clipped to ±10. Reward: 10 - (0.01 * x**2 + (y - 2)**2) - (1e-3 * v1**2 + 5e-3 * v2**2). make warns that the id is out of date.

Not thread-safe. Reference: gymnasium/envs/mujoco/inverted_double_pendulum_v4.py.

Its info is always {}, as Gymnasium's, so it has no typed info record (DR-95).

Constructors

InvertedDoublePendulumEnvV4(InvertedDoublePendulumEnvV4Options)

Builds the instance from its options record: the properties set, the constructor's defaults for the rest.

public InvertedDoublePendulumEnvV4(InvertedDoublePendulumEnvV4Options options)

Parameters

options InvertedDoublePendulumEnvV4Options

The options.

Exceptions

ArgumentNullException

Thrown when options is null.

InvertedDoublePendulumEnvV4(RenderMode, 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 InvertedDoublePendulumEnvV4(string?, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?) builds it from the mode's string: new InvertedDoublePendulumEnvV4(RenderMode.RgbArray) builds what new InvertedDoublePendulumEnvV4(renderMode: "rgb_array") builds, the member reaching the env as Gymnasium's string (Name(RenderMode)), which its RenderMode property then holds.

public InvertedDoublePendulumEnvV4(RenderMode renderMode, int width = 480, int height = 480, int? cameraId = null, string? cameraName = null, int maxGeom = 1000, IReadOnlyDictionary<int, bool>? visualOptions = null, EnvViewerFactory? viewerFactory = null)

Parameters

renderMode RenderMode

The 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.

width int

The rendered frame's width (width).

height int

The rendered frame's height (height).

cameraId int?

The camera to render from (camera_id).

cameraName string

The camera to render from by name (camera_name).

maxGeom int

The most geoms a frame draws (max_geom).

visualOptions IReadOnlyDictionary<int, bool>

MuJoCo visual flags to switch (visual_options).

viewerFactory EnvViewerFactory

Gym.NET's viewer_factory (DR-20) for human mode.

Remarks

The mode is required and comes first, so new InvertedDoublePendulumEnvV4() 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).

ValueError

Both a camera id and a camera name.

InvertedDoublePendulumEnvV4(string?, int, int, int?, string?, int, IReadOnlyDictionary<int, bool>?, EnvViewerFactory?)

Creates the env (Gymnasium's InvertedDoublePendulumEnv.init): inverted_double_pendulum.xml with a frame skip of 5.

public InvertedDoublePendulumEnvV4(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

renderMode string

Gymnasium's render_mode: human, rgb_array, depth_array, rgbd_tuple or null.

width int

The rendered frame's width (width).

height int

The rendered frame's height (height).

cameraId int?

The camera to render from (camera_id).

cameraName string

The camera to render from by name (camera_name).

maxGeom int

The most geoms a frame draws (max_geom).

visualOptions IReadOnlyDictionary<int, bool>

MuJoCo visual flags to switch (visual_options).

viewerFactory EnvViewerFactory

Gym.NET's viewer_factory (DR-20) for human mode.

Exceptions

ValueError

Both a camera id and a camera name.

Properties

ClassMetadata

Gymnasium's class attribute metadata: the four render modes at 20 frames per second. A new dict on every read.

public static Metadata ClassMetadata { get; }

Property Value

Metadata

Methods

ResetModel()

The episode's start (reset_model): positions init_qpos + uniform(-0.1, 0.1, nq), then velocities init_qvel + standard_normal(nv) * 0.1, drawn in that order.

protected override NDArray ResetModel()

Returns

NDArray

The first observation.

Step(NDArray)

Applies action for 5 physics steps and reports the transition (step).

public override StepResult<NDArray> Step(NDArray action)

Parameters

action NDArray

The 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=False and an empty info.

Exceptions

ArgumentNullException

action is null.

ValueError

The action is not of shape (1,), with Gymnasium's message.