environment Package

class explauto.environment.environment.Environment(m_mins, m_maxs, s_mins, s_maxs)[source]

Bases: explauto.utils.observer.Observable

Abstract class to define environments.

When defining your sub-environment, you should specify whether they could be forked and run in different processes through the use_process class variable. By default, it is set to False to guarantee that the code will work.

Parameters:m_mins, m_maxs, s_mins, s_maxs (numpy.array) – bounds of the motor (m) and sensory (s) spaces
use_process = False
classmethod from_configuration(env_name, config_name='default')[source]

Environment factory from name and configuration strings.

Parameters:
  • env_name (str) – the name string of the environment
  • config_name (str) – the configuration string for env_name

Environment name strings are available using:

from explauto.environment import environments
print environments.keys()

This will return the available environment names, something like:

'['npendulum', 'pendulum', 'simple_arm']'

Once you have choose an environment, e.g. ‘simple_arm’, corresponding available configurations are available using:

env_cls, env_configs, _ = environments['simple_arm']
print env_configs.keys()

This will return the available configuration names for the ‘simple_arm’ environment, something like:

'['mid_dimensional', 'default', 'high_dim_high_s_range', 'low_dimensional', 'high_dimensional']'

Once you have choose a configuration, for example the ‘mid_dimensional’ one, you can contruct the environment using:

from explauto import Environment
my_environment = Environment.from_configuration('simple_arm', 'mid_dimensional')

Or, in an equivalent manner:

my_environment = env_cls(**env_configs['mid_dimensional'])
one_update(m_ag, log=True)[source]
update(m_ag, log=True)[source]

Computes sensorimotor values from motor orders.

Parameters:
  • m_ag (numpy.array) – a motor command with shape (self.conf.m_ndims, ) or a set of n motor commands of shape (n, self.conf.m_ndims)
  • log (bool) – emit the motor and sensory values for logging purpose (default: True).
Returns:

an array of shape (self.conf.ndims, ) or (n, self.conf.ndims) according to the shape of the m_ag parameter, containing the motor values (which can be different from m_ag, e.g. bounded according to self.conf.m_bounds) and the corresponding sensory values.

Note

self.conf.ndims = self.conf.m_ndims + self.conf.s_ndims is the dimensionality of the sensorimotor space (dim of the motor space + dim of the sensory space).

reset()[source]

reset environment before update

compute_motor_command(ag_state)[source]
compute_sensori_effect()[source]
random_motors(n=1)[source]
dataset(orders)[source]
uniform_sensor(n_cases=100)[source]
explauto.environment.simple_arm.simple_arm.forward(angles, lengths)[source]

Link object as defined by the standard DH representation.

Parameters:
  • angles (list) – angles of each joint
  • lengths (list) – length of each segment
Returns:

a tuple (x, y) of the end-effector position

Warning

angles and lengths should be the same size.

explauto.environment.simple_arm.simple_arm.joint_positions(angles, lengths)[source]

Link object as defined by the standard DH representation.

Parameters:
  • angles (list) – angles of each joint
  • lengths (list) – length of each segment
Returns:

x positions of each joint, y positions of each joints, except the first one wich is fixed at (0, 0)

Warning

angles and lengths should be the same size.

explauto.environment.simple_arm.simple_arm.lengths(n_dofs, ratio)[source]
class explauto.environment.simple_arm.simple_arm.SimpleArmEnvironment(m_mins, m_maxs, s_mins, s_maxs, length_ratio, noise)[source]

Bases: explauto.environment.environment.Environment

use_process = True
compute_motor_command(joint_pos_ag)[source]
compute_sensori_effect(joint_pos_env)[source]
plot_arm(ax, m_, **kwargs_plot)[source]
class explauto.environment.pendulum.pendulum.PendulumEnvironment(m_mins, m_maxs, s_mins, s_maxs, noise, torque_max=0.25, dt=0.25)[source]

Bases: explauto.environment.environment.Environment

compute_motor_command(ag_state)[source]
reset()[source]
apply_torque(u)[source]
compute_sensori_effect(m)[source]
plot_current_state(ax)[source]
class explauto.environment.pypot.pypot_robot.PypotEnvironment(robot_cls, robot_conf, motors, move_duration, tracked_obj, m_mins, m_maxs, s_mins, s_maxs)[source]

Bases: explauto.environment.environment.Environment

Environment based on dynamixel based robot using pypot.

This environment can be used to link explauto with pypot, a library allowing to control robot based on dynamixel motors. It uses an optitrack has the sensor. This could easily be changed by defining other pypot environments.

Parameters:
  • get_pypot_robot – function returning the pypot robot used as the environment
  • motors (list of DxlMotor) – list of motors used by the environment
  • move_duration (float) – duration (in sec.) of each primitive motion
  • tracker (Tracker) – tracker used as the sensor by the Agent
  • tracked_obj (string) – name of the object tracked by the optitrack
  • m_mins (numpy.array) – minimum motor dims
  • m_maxs (numpy.array) – maximum motor dims
  • s_mins (numpy.array) – minimum sensor dims
  • s_maxs (numpy.array) – maximum sensor dims
use_process = False
compute_motor_command(m_ag)[source]

Compute the motor command by restricting it to the bounds.

compute_sensori_effect(m_env)[source]

Make the robot moves and retrieve the tracked object position.

class explauto.environment.pypot.pypot_robot.VrepRobot(config_path, scene_path, host='127.0.0.1', port=19997, tracked_objects=['left_hand_tracker', 'right_hand_tracker'])[source]

Bases: object

get_position(tracked_object)[source]
class explauto.environment.pypot.pypot_robot.PoppyRobot(config_path)[source]

Bases: object

get_position(tracked_object)[source]
explauto.environment.pypot.pypot_robot.get_configuration(get_robot, tracker_cls, tracked_obj, m_mins=array([-0.26179939, 0., -1.57079633, -1.57079633]), m_maxs=array([ 1.57079633, 1.57079633, 1.57079633, 0. ]), s_mins=array([-0.2, -0.1, 0. ]), s_maxs=array([ 0.4, 0.5, 0.6]))[source]
explauto.environment.pypot.pypot_robot.environment

alias of PypotEnvironment

class explauto.environment.diva.diva.DivaSynth(diva_path, sample_rate=11025)[source]
execute(art)[source]
sound_wave(art)[source]
stop()[source]
class explauto.environment.diva.diva.DivaEnvironment(m_mins, m_maxs, s_mins, s_maxs, m_used=None, s_used=None, m_default=None)[source]

Bases: explauto.environment.environment.Environment

compute_motor_command(m_ag)[source]
compute_sensori_effect(m_env)[source]
sound_wave(art_traj)[source]