Link Search Menu Expand Document

envs.EvoGymBase

Extend this class for creating gym-like environments (inherits from gym.Env).

Quicklinks:   EvoWorld,   EvoSim,   EvoViewer,   WorldObject,   envs.EvoGymBase,   helper functions and metadata


Page Outline

  1. class EvoGymBase
    1. function __init__
      1. property default_viewer
      2. property sim
      3. property unwrapped
    2. function close
    3. function get_actuator_indices
    4. function get_ceil_obs
    5. function get_dim_action_space
    6. function get_floor_obs
    7. function get_ort_obs
    8. function get_pos_com_obs
    9. function get_relative_pos_obs
    10. function get_time
    11. function get_vel_com_obs
    12. function object_orientation_at_time
    13. function object_pos_at_time
    14. function object_vel_at_time
    15. function pos_at_time
    16. function render
    17. function reset
    18. function step
    19. function vel_at_time

class EvoGymBase

Base class for all Evolution Gym environments.

Args:

  • world (EvoWorld): object specifying the voxel layout of the environment.

function __init__

__init__(world: EvoWorld) → None

property default_viewer

Returns the environment’s default viewer.

Returns:

  • EvoSim: viewer object to return.

property sim

Returns the environment’s simulation.

Returns:

  • EvoSim: simulation object to return.

property unwrapped

Completely unwrap this env.

Returns:

  • gym.Env: The base non-wrapped gym.Env instance

function close

close() → None

Close the simulation.


function get_actuator_indices

get_actuator_indices(robot_name: str) → ndarray

Returns the voxel indices a target robot’s actuators in the environment’s simulation.

Args:

  • robot_name (str): name of robot.

Returns:

  • np.ndarray: (n,) array of actuator indices, where n is the number of actuators.

function get_ceil_obs

get_ceil_obs(
    object_name: str,
    terrain_list: list,
    sight_dist: int,
    sight_range: float = 5
) → ndarray

Observation helper-function. Computes an observation describing the shape of the terrain above the target object. Specifically, for each voxel to the left and right of the target object’s center of mass (along with the voxel containing the center of mass), the following observation is computed: min(y-distance in voxels to the nearest terrain object above the target object’s center of mass, sight_range). Results are returned in a 1D numpy array.

Args:

  • object_name (str): name of target object.
  • terrain_list (list[str]): names of objects to be considered terrain in the computation.
  • sight_dist (int): number of voxels to the left and right of the target object’s center of mass for which an observation should be returned.
  • sight_range (float): the max number of voxels above the object that can be seen. (default = 5)

Returns:

  • np.ndarray: (2 * sight_range + 1, ) array of distance observations.

function get_dim_action_space

get_dim_action_space(robot_name: str) → int

Returns the number of actuators for a target robot in the environment’s simulation.

Args:

  • robot_name (str): name of robot.

Returns:

  • int: number of actuators.

function get_floor_obs

get_floor_obs(
    object_name: str,
    terrain_list: list,
    sight_dist: int,
    sight_range: float = 5
) → ndarray

Observation helper-function. Computes an observation describing the shape of the terrain below the target object. Specifically, for each voxel to the left and right of the target object’s center of mass (along with the voxel containing the center of mass), the following observation is computed: min(y-distance in voxels to the nearest terrain object below the target object’s center of mass, sight_range). Results are returned in a 1D numpy array.

Args:

  • object_name (str): name of target object.
  • terrain_list (list[str]): names of objects to be considered terrain in the computation.
  • sight_dist (int): number of voxels to the left and right of the target object’s center of mass for which an observation should be returned.
  • sight_range (float): the max number of voxels below the object that can be seen. (default = 5)

Returns:

  • np.ndarray: (2 * sight_range + 1, ) array of distance observations.

function get_ort_obs

get_ort_obs(object_name: str)

Observation helper-function. Returns the orientation of a target object.

Args:

  • object_name (str): name of object

Returns:

  • np.ndarray: (1,) array of the object’s orientation.

function get_pos_com_obs

get_pos_com_obs(object_name: str) → ndarray

Observation helper-function. Computes the position of the center of mass of a target object by averaging the positions of the object’s point masses.

Args:

  • object_name (str): name of object

Returns:

  • np.ndarray: (2,) array of the position of the center of mass.

function get_relative_pos_obs

get_relative_pos_obs(object_name: str)

Observation helper-function. Computes the positions of a target object’s point masses relative to their center of mass.

Args:

  • object_name (str): name of object

Returns:

  • np.ndarray: (2n,) array of positions, where n is the number of point masses.

function get_time

get_time() → int

Returns the current time as defined in the environment’s simulator. Time starts at 0 and is incremented each time the environment steps. Time resets to 0 when the environment is reset.

Returns:

  • int: the current time.

function get_vel_com_obs

get_vel_com_obs(object_name: str) → ndarray

Observation helper-function. Computes the velocity of the center of mass of a target object by averaging the velocities of the object’s point masses.

Args:

  • object_name (str): name of object

Returns:

  • np.ndarray: (2,) array of the velocity of the center of mass.

function object_orientation_at_time

object_orientation_at_time(time: int, object_name: str) → float

Returns an estimate of the orientation of an object at time time. Use EvoGymBase.get_time() to get current measurements.

Args:

  • time (int): time at which to return measurement.
  • object_name (str): name of object

Returns:

  • float: orientation with respect to x-axis in radians (increasing counter-clockwise) from the range [0, 2π].

function object_pos_at_time

object_pos_at_time(time: int, object_name: str) → ndarray

Returns positions of all point-masses in a target object at time time. Use EvoGymBase.get_time() to get current measurements.

Args:

  • time (int): time at which to return measurements.
  • object_name (str): name of object

Returns:

  • np.ndarray: (2, n) array of measurements, where n is the number of point-masses in the target object.

function object_vel_at_time

object_vel_at_time(time: int, object_name: str) → ndarray

Returns velocities of all point-masses in a target object at time time. Use EvoGymBase.get_time() to get current measurements.

Args:

  • time (int): time at which to return measurements.
  • object_name (str): name of object

Returns:

  • np.ndarray: (2, n) array of measurements, where n is the number of point-masses in the target object.

function pos_at_time

pos_at_time(time: int) → ndarray

Returns positions of all point-masses in the environment’s simulation at time time. Use EvoGymBase.get_time() to get current measurements.

Args:

  • time (int): time at which to return measurements.

Returns:

  • np.ndarray: (2, n) array of measurements, where n is the number of points in the environment’s simulation.

function render

render(
    mode: str = 'screen',
    verbose: bool = False,
    hide_background: bool = False,
    hide_grid: bool = False,
    hide_edges: bool = False,
    hide_voxels: bool = False
) → Optional[ndarray]

Render the simulation.

Args:

  • mode (str): values of ‘screen’ and ‘human’ will render to a debug window. If set to ‘img’ will return an image array.
  • verbose (bool): whether or not to print the rendering speed (rps) every second.
  • hide_background (bool): whether or not to render the cream-colored background. If shut off background will be white.
  • hide_grid (bool): whether or not to render the grid.
  • hide_edges (bool): whether or not to render edges around all objects.
  • hide_voxels (bool): whether or not to render voxels.

Returns:

  • Optional[np.ndarray]: if mode is set to img, will return an image array.

function reset

reset() → None

Reset the simulation to the initial state.


function step

step(action: Dict[str, ndarray]) → bool

Step the environment by running physcis computations.

Args:

  • action (Dict[str, np.ndarray]): dictionary mapping robot names to actions. Actions are (n,) arrays, where n is the number of actuators in the target robot.

Returns:

  • bool: whether or not the simulation has reached an unstable state and cannot be recovered (True = unstable).

function vel_at_time

vel_at_time(time: int) → ndarray

Returns velocities of all point-masses in the environment’s simulation at time time. Use EvoGymBase.get_time() to get current measurements.

Args:

  • time (int): time at which to return measurements.

Returns:

  • np.ndarray: (2, n) array of measurements, where n is the number of points in the environment’s simulation.

This file was automatically generated via lazydocs.