src.plangym.control.dm_control
==============================

.. py:module:: src.plangym.control.dm_control

.. autoapi-nested-parse::

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



Attributes
----------

.. autoapisummary::

   src.plangym.control.dm_control.novideo_mode


Classes
-------

.. autoapisummary::

   src.plangym.control.dm_control.DMControlEnv


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

.. py:data:: novideo_mode
   :value: False


.. py:class:: DMControlEnv(name = 'cartpole-balance', frameskip = 1, episodic_life = False, autoreset = True, wrappers = None, delay_setup = False, visualize_reward = True, domain_name=None, task_name=None, render_mode='rgb_array', obs_type = None, remove_time_limit=None, return_image = False)

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


   Wrap the `dm_control library, allowing its implementation in planning problems.

   The dm_control library is a DeepMind's software stack for physics-based
   simulation and Reinforcement Learning environments, using MuJoCo physics.

   For more information about the environment, please refer to
   https://github.com/deepmind/dm_control

   This class allows the implementation of dm_control in planning problems.
   It allows parallel and vectorized execution of the environments.


   .. py:attribute:: DEFAULT_OBS_TYPE
      :value: 'coords'



   .. py:attribute:: _visualize_reward


   .. py:attribute:: viewer
      :value: []



   .. py:attribute:: _viewer
      :value: None



   .. py:property:: physics
      Alias for gym_env.physics.


   .. py:property:: domain_name
      :type: str

      Return the name of the agent in the current simulation.


   .. py:property:: task_name
      :type: str

      Return the name of the task in the current simulation.


   .. py:method:: _parse_names(name, domain_name, task_name)
      :staticmethod:


      Return the name, domain name, and task name of the project.



   .. py:method:: init_gym_env()

      Initialize the environment instance (dm_control) that the current class is wrapping.



   .. py:method:: setup()

      Initialize the target :class:`gym.Env` instance.



   .. py:method:: _init_action_space()

      Define the action space of the environment.

      This method determines the spectrum of possible actions that the
      agent can perform. The action space consists in a grid representing
      the Cartesian product of the closed intervals defined by the user.



   .. py:method:: _init_obs_space_coords()

      Define the observation space of the environment.



   .. py:method:: action_spec()

      Alias for the environment's ``action_spec``.



   .. py:method:: get_image()

      Return a numpy array containing the rendered view of the environment.

      Square matrices are interpreted as a greyscale image. Three-dimensional arrays
      are interpreted as RGB images with channels (Height, Width, RGB).



   .. py:method:: render(mode=None)

      Render the environment.

      Store all the RGB images rendered to be shown when the `show_game`        function is called.

      :param mode: `rgb_array` return an RGB image stored in a numpy array. `human`
                   stores the rendered image in a viewer to be shown when `show_game`
                   is called.

      :returns: numpy.ndarray when mode == `rgb_array`. True when mode == `human`



   .. py:method:: show_game(sleep = 0.05)

      Render the collected RGB images.

      When 'human' option is selected as argument for the `render` method,
      it stores a collection of RGB images inside the ``self.viewer``
      attribute. This method calls the latter to visualize the collected
      images.



   .. py:method:: get_coords_obs(obs, **kwargs)

      Get the environment observation from a time_step object.

      :param obs: Time step object returned after stepping the environment.
      :param \*\*kwargs: Ignored

      :returns: Numpy array containing the environment observation.



   .. py:method:: set_state(state)

      Set the state of the simulator to the target State.

      :param state: numpy.ndarray containing the information about the state to be set.

      :returns: None



   .. py:method:: get_state()

      Return the state of the environment.

      Return a tuple containing the three arrays that characterize the state         of the system.

      Each tuple contains the position of the robot, its velocity
       and the control variables currently being applied.

      Returns
          Tuple of numpy arrays containing all the information needed to describe
          the current state of the simulation.




   .. py:method:: apply_action(action)

      Transform the returned time_step object to a compatible gym tuple.



   .. py:method:: _time_step_to_obs(time_step)
      :staticmethod:


      Stack observation values as a horizontal sequence.

      Concat observations in a single array, making easier calculating
      distances.



   .. py:method:: close()

      Tear down the environment and close rendering.



