plangym.control.box_2d

Implement the plangym API for Box2D environments.

Module Contents

Classes

Box2DState

Extract state information from Box2D environments.

Box2DEnv

Common interface for working with Box2D environments released by gym.

class plangym.control.box_2d.Box2DState[source]

Extract state information from Box2D environments.

This class implements basic functionalities to get the necessary elements to construct a Box2D state.

static get_body_attributes(body)[source]

Return a dictionary containing the attributes of a given body.

Given a Env.world.body element, this method constructs a dictionary whose entries describe all body attributes.

Return type

dict

static serialize_body_attribute(value)[source]

Copy one body attribute.

classmethod serialize_body_state(cls, state_dict)[source]

Serialize the state of the target body data.

This method takes as argument the result given by the method self.get_body_attributes, the latter consisting in a dictionary containing all attribute elements of a body. The method returns a dictionary whose values are the serialized attributes of the body.

static set_value_to_body(body, name, value)[source]

Set the target value to a body attribute.

classmethod set_body_state(cls, body, state)[source]

Set the state to the target body.

The method defines the corresponding body attribute to the value selected by the user.

classmethod serialize_body(cls, body)[source]

Serialize the data of the target Env.world.body instance.

classmethod serialize_world_state(cls, world)[source]

Serialize the state of all the bodies in world.

The method serializes all body elements contained within the given Env.world object.

classmethod set_world_state(cls, world, state)[source]

Set the state of the world environment to the provided state.

The method states the current environment by defining its world bodies’ attributes.

classmethod get_env_state(cls, env)[source]

Get the serialized state of the target environment.

classmethod set_env_state(cls, env, state)[source]

Set the serialized state to the target environment.

class plangym.control.box_2d.Box2DEnv(name, frameskip=1, autoreset=True, wrappers=None, delay_setup=False, remove_time_limit=True, render_mode=None, episodic_life=False, obs_type=None, return_image=False, **kwargs)[source]

Bases: plangym.core.PlangymEnv

Common interface for working with Box2D environments released by gym.

Parameters
  • name (str) –

  • frameskip (int) –

  • autoreset (bool) –

  • wrappers (Iterable[wrap_callable]) –

  • delay_setup (bool) –

  • render_mode (Optional[str]) –

get_state(self)[source]

Recover the internal state of the simulation.

A state must completely describe the Environment at a given moment.

Return type

numpy.array

set_state(self, state)[source]

Set the internal state of the simulation.

Parameters

state (numpy.ndarray) – Target state to be set in the environment.

Returns

None

Return type

None