src.plangym.control.box_2d
==========================

.. py:module:: src.plangym.control.box_2d

.. autoapi-nested-parse::

   Implement the ``plangym`` API for Box2D environments.



Classes
-------

.. autoapisummary::

   src.plangym.control.box_2d.Box2DState
   src.plangym.control.box_2d.Box2DEnv


Module Contents
---------------

.. py:class:: Box2DState

   Extract state information from Box2D environments.

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


   .. py:method:: get_body_attributes(body)
      :staticmethod:


      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.



   .. py:method:: serialize_body_attribute(value)
      :staticmethod:


      Copy one body attribute.



   .. py:method:: serialize_body_state(state_dict)
      :classmethod:


      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.



   .. py:method:: set_value_to_body(body, name, value)
      :staticmethod:


      Set the target value to a body attribute.



   .. py:method:: set_body_state(body, state)
      :classmethod:


      Set the state to the target body.

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



   .. py:method:: serialize_body(body)
      :classmethod:


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



   .. py:method:: serialize_world_state(world)
      :classmethod:


      Serialize the state of all the bodies in world.

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



   .. py:method:: set_world_state(world, state)
      :classmethod:


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

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



   .. py:method:: get_env_state(env)
      :classmethod:


      Get the serialized state of the target environment.



   .. py:method:: set_env_state(env, state)
      :classmethod:


      Set the serialized state to the target environment.



.. py:class:: Box2DEnv(name, frameskip = 1, autoreset = True, wrappers = None, delay_setup = False, remove_time_limit = True, render_mode = 'rgb_array', episodic_life=False, obs_type=None, return_image=False, **kwargs)

   Bases: :py:obj:`plangym.core.PlangymEnv`


   Common interface for working with Box2D environments released by `gym`.


   .. py:method:: get_state()

      Recover the internal state of the simulation.

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



   .. py:method:: set_state(state)

      Set the internal state of the simulation.

      :param state: Target state to be set in the environment.

      :returns: None



