Fork me on GitHub

bolero.environment.OptimumTrajectory

class bolero.environment.OptimumTrajectory(x0=array([ 0., 0.]), g=array([ 1., 1.]), execution_time=1.0, dt=0.01, obstacles=None, obstacle_dist=0.1, penalty_start_dist=0.0, penalty_goal_dist=0.0, penalty_vel=0.0, penalty_acc=0.0, penalty_obstacle=0.0, log_to_file=False, log_to_stdout=False)[source]

Optimize a trajectory according to some criteria.

Parameters:
x0 : array-like, shape = (n_task_dims,), optional (default: [0, 0])

Initial position.

g : array-like, shape = (n_task_dims,), optional (default: [1, 1])

Goal position.

execution_time : float, optional (default: 1.0)

Execution time in seconds

dt : float, optional (default: 0.01)

Time between successive steps in seconds.

obstacles : array-like, shape (n_obstacles, n_task_dims) (default: None)

List of obstacles.

obstacle_dist : float, optional (default: 0.1)

Distance that should be kept to the obstacles (penalty is zero outside of this area)

penalty_start_dist : float, optional (default: 0)

Penalty weight for distance to start at the beginning

penalty_goal_dist : float, optional (default: 0)

Penalty weight for distance to goal at the end

penalty_vel : float, optional (default: 0)

Penalty weight for velocities

penalty_acc : float, optional (default: 0)

Penalty weight for accelerations

penalty_obstacle : float, optional (default: 0)

Penalty weight for obstacle avoidance

log_to_file: optional, boolean or string (default: False)

Log results to given file, it will be located in the $BL_LOG_PATH

log_to_stdout: optional, boolean (default: False)

Log to standard output

__init__(x0=array([ 0., 0.]), g=array([ 1., 1.]), execution_time=1.0, dt=0.01, obstacles=None, obstacle_dist=0.1, penalty_start_dist=0.0, penalty_goal_dist=0.0, penalty_vel=0.0, penalty_acc=0.0, penalty_obstacle=0.0, log_to_file=False, log_to_stdout=False)[source]
get_acceleration()[source]

Get acceleration values during the performed movement.

Returns:
acceleration : array-like, shape (n_steps,)

the total acceleration (scalar) at all previous timestamps

get_args()

Get parameters for this estimator.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

get_collision(obstacle_filter=None)[source]

Get list of collisions with obstacles during the performed movement.

Parameters:
obstacle_filter : array-like, shape (n_desired_obstacles, 1)

specify which obstacles cause collisions, e.g. set (0, 2) to exclude the second of three obstacles

Returns
——-
collisions : array-like, shape (n_steps,)

vector of values in range [0, 1] where distances above self.obstacle_dist result in 0 (no collision), and distance below are scaled linearly, so that 1 corresponds to an intersection.

get_feedback()[source]

Get reward per timestamp based on weighted criteria (penalties)

Returns:
rewards : array-like, shape (n_steps,)

reward for every timestamp; non-positive values

get_goal_dist()[source]

Get distance of trajectory end and desired goal location.

Returns:
goal_dist : float

goal distance

get_maximum_feedback()[source]

Returns the maximum sum of feedbacks obtainable.

get_num_inputs()[source]

Get number of environment inputs.

Returns:
n : int

number of environment inputs

get_num_obstacles()[source]

Get number of obstacles in environment.

Returns:
n : int

number of obstacles

get_num_outputs()[source]

Get number of environment outputs.

Returns:
n : int

number of environment outputs

get_outputs(values)[source]

Get environment outputs.

Parameters:
values : array

Outputs of the environment: positions, velocities and accelerations in that order, e.g. for n_task_dims=2 the order would be xxvvaa

get_speed()[source]

Get speed values during the performed movement.

Returns:
speed : array-like, shape (n_steps,)

the speed (scalar) at all previous timestamps

get_start_dist()[source]

Get distance of trajectory start and desired start location.

Returns:
start_dist : float

start distance

init()[source]

Initialize environment.

is_behavior_learning_done()[source]

Check if the behavior learning is finished.

Returns:
finished : bool

Always false

is_evaluation_done()[source]

Check if the time is over.

Returns:
finished : bool

Is the episode finished?

plot(ax)[source]

Plot a two-dimensional environment.

Parameters:
ax : Axis

Matplotlib axis

reset()[source]

Reset state of the environment.

set_inputs(values)[source]

Set environment inputs, e.g. next action.

Parameters:
values : array,

Inputs for the environment: positions, velocities and accelerations in that order, e.g. for n_task_dims=2 the order would be xxvvaa

step_action()[source]

Execute step perfectly.