movement_primitives.dmp.CartesianDMP

class movement_primitives.dmp.CartesianDMP(execution_time=1.0, dt=0.01, n_weights_per_dim=10, int_dt=0.001, smooth_scaling=False)

Bases: DMPBase

Cartesian dynamical movement primitive.

The Cartesian DMP handles orientation and position separately. The orientation is represented by a quaternion.

While the dimension of the state space is 7, the dimension of the velocity, acceleration, and forcing term is 6.

Equation of transformation system for the orientation (according to [1], Eq. 16):

\[\ddot{y} = (\alpha_y (\beta_y (g - y) - \tau \dot{y}) + f(z) + C_t) / \tau^2\]

Note that in this case \(y\) is a quaternion in this case, \(g - y\) the quaternion difference (expressed as rotation vector), \(\dot{y}\) is the angular velocity, and \(\ddot{y}\) the angular acceleration.

With smooth scaling (according to [2]):

\[\ddot{y} = (\alpha_y (\beta_y (g - y) - \tau \dot{y} - \underline{\beta_y (g - y_0) z}) + f(z) + C_t) / \tau^2\]

The position is handled in the same way, just like in the original DMP.

Parameters:
execution_timefloat, optional (default: 1)

Execution time of the DMP.

dtfloat, optional (default: 0.01)

Time difference between DMP steps.

n_weights_per_dimint, optional (default: 10)

Number of weights of the function approximator per dimension.

int_dtfloat, optional (default: 0.001)

Time difference for Euler integration.

smooth_scalingbool, optional (default: False)

Avoids jumps during the beginning of DMP execution when the goal is changed and the trajectory is scaled by interpolating between the old and new scaling of the trajectory.

References

[1]

Ude, A., Nemec, B., Petric, T., Murimoto, J. (2014). Orientation in Cartesian space dynamic movement primitives. In IEEE International Conference on Robotics and Automation (ICRA) (pp. 2997-3004). DOI: 10.1109/ICRA.2014.6907291, https://acat-project.eu/modules/BibtexModule/uploads/PDF/udenemecpetric2014.pdf

[2]

Pastor, P., Hoffmann, H., Asfour, T., Schaal, S. (2009). Learning and Generalization of Motor Skills by Learning from Demonstration. In 2009 IEEE International Conference on Robotics and Automation, (pp. 763-768). DOI: 10.1109/ROBOT.2009.5152385, https://h2t.iar.kit.edu/pdf/Pastor2009.pdf

Attributes:
execution_time_float

Execution time of the DMP.

dt_float

Time difference between DMP steps. This value can be changed to adapt the frequency.

Methods

configure([t, start_y, start_yd, start_ydd, ...])

Set meta parameters.

get_weights()

Get weight vector of DMP.

imitate(T, Y[, regularization_coefficient, ...])

Imitate demonstration.

n_steps_open_loop(last_y, last_yd, n_steps)

Perform 'n_steps' steps.

open_loop([run_t, coupling_term, ...])

Run DMP open loop.

reset()

Reset DMP to initial state and time.

set_weights(weights)

Set weight vector of DMP.

step(last_y, last_yd[, coupling_term, ...])

DMP step.

get_execution_time_

set_execution_time_

__init__(execution_time=1.0, dt=0.01, n_weights_per_dim=10, int_dt=0.001, smooth_scaling=False)

Methods

__init__([execution_time, dt, ...])

configure([t, start_y, start_yd, start_ydd, ...])

Set meta parameters.

get_execution_time_()

get_weights()

Get weight vector of DMP.

imitate(T, Y[, regularization_coefficient, ...])

Imitate demonstration.

n_steps_open_loop(last_y, last_yd, n_steps)

Perform 'n_steps' steps.

open_loop([run_t, coupling_term, ...])

Run DMP open loop.

reset()

Reset DMP to initial state and time.

set_execution_time_(execution_time)

set_weights(weights)

Set weight vector of DMP.

step(last_y, last_yd[, coupling_term, ...])

DMP step.

Attributes

execution_time_

configure(t=None, start_y=None, start_yd=None, start_ydd=None, goal_y=None, goal_yd=None, goal_ydd=None)

Set meta parameters.

Parameters:
tfloat, optional

Time at current step.

start_yarray, shape (n_dims,)

Initial state.

start_ydarray, shape (n_vel_dims,)

Initial velocity.

start_yddarray, shape (n_vel_dims,)

Initial acceleration.

goal_yarray, shape (n_dims,)

Goal state.

goal_ydarray, shape (n_vel_dims,)

Goal velocity.

goal_yddarray, shape (n_vel_dims,)

Goal acceleration.

get_weights()

Get weight vector of DMP.

Returns:
weightsarray, shape (6 * n_weights_per_dim,)

Current weights of the DMP.

imitate(T, Y, regularization_coefficient=0.0, allow_final_velocity=False)

Imitate demonstration.

Parameters:
Tarray, shape (n_steps,)

Time for each step.

Yarray, shape (n_steps, 7)

State at each step.

regularization_coefficientfloat, optional (default: 0)

Regularization coefficient for regression.

allow_final_velocitybool, optional (default: False)

Allow a final velocity.

n_steps_open_loop(last_y, last_yd, n_steps)

Perform ‘n_steps’ steps.

Parameters:
last_yarray, shape (n_dims,)

Last state.

last_ydarray, shape (n_dims,)

Last time derivative of state (e.g., velocity).

n_stepsint

Number of steps.

Returns:
yarray, shape (n_dims,)

Next state.

ydarray, shape (n_dims,)

Next time derivative of state (e.g., velocity).

open_loop(run_t=None, coupling_term=None, step_function='rk4-cython', quaternion_step_function='cython')

Run DMP open loop.

Parameters:
run_tfloat, optional (default: execution_time)

Run time of DMP. Can be shorter or longer than execution_time.

coupling_termobject, optional (default: None)

Coupling term that will be added to velocity.

step_functionstr, optional (default: ‘rk4’)

DMP integration function. Possible options: ‘rk4’, ‘euler’, ‘euler-cython’, ‘rk4-cython’.

quaternion_step_functionstr, optional (default: ‘cython’ if available)

DMP integration function. Possible options: ‘python’, ‘cython’.

Returns:
Tarray, shape (n_steps,)

Time for each step.

Yarray, shape (n_steps, 7)

State at each step.

reset()

Reset DMP to initial state and time.

set_weights(weights)

Set weight vector of DMP.

Parameters:
weightsarray, shape (6 * n_weights_per_dim,)

New weights of the DMP.

step(last_y, last_yd, coupling_term=None, step_function=<cyfunction dmp_step_rk4>, quaternion_step_function=<cyfunction dmp_step_quaternion>)

DMP step.

Parameters:
last_yarray, shape (7,)

Last state.

last_ydarray, shape (6,)

Last time derivative of state (velocity).

coupling_termobject, optional (default: None)

Coupling term that will be added to velocity.

step_functioncallable, optional (default: RK4)

DMP integration function.

quaternion_step_functioncallable, optional (default: cython code if available)

DMP integration function.

Returns:
yarray, shape (14,)

Next state.

ydarray, shape (12,)

Next time derivative of state (velocity).