dmp
Dynamic Motion Primitive (DMP) generation and reproduction utilities.
DMPs represent demonstrations as stable dynamical systems with learned Gaussian-basis forcing terms. This module supports standard signals, quaternion orientations, and Cartesian pose trajectories.
DMP parameter dictionaries use the following entries:
Parameter |
Description |
|---|---|
|
Number of Gaussian basis functions (default: |
|
Transformation-system spring gain (default: |
|
Transformation-system damping gain (default: |
|
Canonical-system phase decay rate (default: |
|
Integration time step; inferred from the demonstration if omitted. |
|
Demonstration duration used for temporal scaling. |
|
Centers of the Gaussian basis functions in phase space. |
|
Variances of the Gaussian basis functions. |
|
Learned basis-function weights for each trajectory dimension. |
|
Scaling factor for canonical phase decoding DMP. |
|
Initial signal value or, for a Cartesian DMP, initial pose. |
|
Initial signal velocity or Cartesian twist. |
|
Goal signal value or, for a Cartesian DMP, goal pose. |
|
Initial quaternion for a quaternion DMP. |
|
Initial scaled angular velocity for a quaternion DMP. |
|
Goal quaternion for a quaternion DMP. |
|
Per-axis forcing-term scale for a quaternion DMP. |
- robotblockset.dmp.encodeDMP(inputTime: ndarray | List[float] | List[int] | Tuple[float, ...] | Tuple[int, ...], inputTrajectory: ndarray | List[float] | List[int] | Tuple[float, ...] | Tuple[int, ...], DMP: Mapping[str, Any] | None = None) Dict[str, Any][source]
Encode sampled signals into a non-recursive locally weighted DMP.
- Parameters:
inputTime (ArrayLike) – Sample times
(n,)or a scalar sample interval.inputTrajectory (ArrayLike) – Input signals with shape
(n, m)or(n,).DMP (Mapping[str, Any], optional) – Initial parameters. Supported values include
N,a_z,b_z,a_x,ps, anddt. Missing values use DMP defaults.
- Returns:
DMP parameters including
w,c,sigma,tau,y0,dy0, andgoal.- Return type:
DMPType
- Raises:
ValueError – If the trajectory or time vector has an invalid shape or duration.
- robotblockset.dmp.integrateStepDMP(DMP: Mapping[str, Any], S: MutableMapping[str, Any], phase_scaling: float = 1.0) MutableMapping[str, Any][source]
Advance a standard DMP state by one Euler step.
Sis updated in place and contains at leastx,y, andz. The calculateddy,ddy, and normalized basis activation are added to the state.- Parameters:
DMP (Mapping[str, Any]) – Standard DMP parameter dictionary.
S (DMPState) – Mutable integration state.
phase_scaling (float, optional) – Positive canonical-phase time-scaling factor. Values greater than
1slow phase progression and values below1accelerate it. Default is1.
- Returns:
The updated state dictionary.
- Return type:
DMPState
- Raises:
ValueError – If
phase_scalingis not greater than zero.
- robotblockset.dmp.decodeDMP(tf: float, DMP: Mapping[str, Any]) Tuple[ndarray, ndarray, ndarray, ndarray][source]
Generate a trajectory from a standard DMP up to
tf.- Parameters:
tf (float) – Requested final time in seconds.
DMP (Mapping[str, Any]) – Standard DMP parameter dictionary.
- Returns:
Position, velocity, acceleration, and canonical phase arrays. The first three have shape
(n, m)and phase has shape(n,). The initial state att = 0is included, so decoding a demonstration duration of(n - 1) * dtreturnsnsamples.- Return type:
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
- robotblockset.dmp.encodeQuaternionDMP(inputTime: ndarray | List[float] | List[int] | Tuple[float, ...] | Tuple[int, ...], inputQuaternionTrajectory: ndarray, DMP: Mapping[str, Any] | None = None) Dict[str, Any][source]
Encode a quaternion trajectory into a quaternion DMP.
Quaternions use the scalar-first convention
[w, x, y, z]. Angular velocity and acceleration are represented as three-dimensional vectors.- Parameters:
inputTime (ArrayLike) – Sample times
(n,)or a scalar sample interval.inputQuaternionTrajectory (QuaternionsType) – Unit quaternion trajectory with shape
(n, 4).DMP (Mapping[str, Any], optional) – Initial DMP parameters. Missing values use DMP defaults.
- Returns:
Quaternion DMP parameters, including
q0,gq,w,c,sigma,tau, anddiag.- Return type:
DMPType
- Raises:
ValueError – If the quaternion trajectory or time vector is invalid.
- robotblockset.dmp.integrateStepQuaternionDMP(DMP: Mapping[str, Any], S: MutableMapping[str, Any], phase_scaling: float = 1.0) MutableMapping[str, Any][source]
Advance a quaternion DMP state by one Euler step.
The quaternion in
S['q']is integrated on the unit sphere and remains normalized after the update.- Parameters:
DMP (Mapping[str, Any]) – Quaternion DMP parameter dictionary.
S (DMPState) – Mutable state containing
q,o, andx.phase_scaling (float, optional) – Positive canonical-phase time-scaling factor. Values greater than
1slow phase progression and values below1accelerate it. Default is1.
- Returns:
Updated state containing quaternion, angular velocity, and angular acceleration values.
- Return type:
DMPState
- Raises:
ValueError – If
phase_scalingis not greater than zero.
- robotblockset.dmp.decodeQuaternionDMP(tf: float, DMP: Mapping[str, Any]) Tuple[ndarray, ndarray, ndarray, ndarray][source]
Generate a quaternion trajectory from a quaternion DMP.
- Parameters:
tf (float) – Requested final time in seconds.
DMP (Mapping[str, Any]) – Quaternion DMP parameter dictionary.
- Returns:
Unit quaternions
(n, 4), angular velocities(n, 3), angular accelerations(n, 3), and canonical phase values(n,). The initial state att = 0is included.- Return type:
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
- robotblockset.dmp.encodeCartesianDMP(inputTime: ndarray | List[float] | List[int] | Tuple[float, ...] | Tuple[int, ...], inputTrajectory: ndarray, DMP: Mapping[str, Any] | None = None) Dict[str, Any][source]
Encode an SE(3) trajectory as a combined Cartesian DMP.
The input pose is
[x, y, z, qw, qx, qy, qz]. The returned dictionary combines the three position DMP outputs and the three-dimensional quaternion DMP forcing term, matching the MATLAB Cartesian DMP format.- Parameters:
inputTime (ArrayLike) – Sample times
(n,)or a scalar sample interval.inputTrajectory (Poses3DType) – Cartesian pose trajectory with shape
(n, 7).DMP (Mapping[str, Any], optional) – Initial DMP parameters. Missing values use DMP defaults.
- Returns:
Combined Cartesian DMP parameter dictionary.
- Return type:
DMPType
- Raises:
ValueError – If the input trajectory is not an
(n, 7)pose path.
- robotblockset.dmp.decodeCartesianDMP(tf: float, DMP: Mapping[str, Any]) Tuple[ndarray, ndarray, ndarray, ndarray][source]
Generate an SE(3) trajectory from a combined Cartesian DMP.
- Parameters:
tf (float) – Requested final time in seconds.
DMP (Mapping[str, Any]) – Combined Cartesian DMP parameter dictionary.
- Returns:
Cartesian poses
(n, 7), twists(n, 6), accelerations(n, 6), and canonical phase values(n,). The initial state att = 0is included.- Return type:
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]
- robotblockset.dmp.Path2DMP(p: ndarray | List[float] | List[int] | Tuple[float, ...] | Tuple[int, ...], N: int = 25) Dict[str, Any][source]
Encode a time-parameterized path into a standard DMP.
- Parameters:
p (ArrayLike) – Path array
(n, m + 1). The first column contains time and the remaining columns contain the signals.N (int, optional) – Number of Gaussian basis functions. Default is
25.
- Returns:
Encoded DMP parameter dictionary.
- Return type:
DMPType
- Raises:
ValueError – If the path does not contain a time column and at least one signal.
- robotblockset.dmp.DMP2Path(DMP: Mapping[str, Any], x_f: float | None = None) ndarray[source]
Decode a standard DMP into a time, phase, and state path.
- Parameters:
DMP (Mapping[str, Any]) – Standard DMP parameter dictionary.
x_f (float, optional) – Stopping phase. If omitted, it is selected from
tauanddt.
- Returns:
Array with columns
[time, phase, y, dy, ddy].- Return type:
np.ndarray
- robotblockset.dmp.x_encodeDMP(y: ndarray | List[float] | List[int] | Tuple[float, ...] | Tuple[int, ...], DMP: Mapping[str, Any]) Dict[str, Any][source]
Encode uniformly sampled signals using recursive regression.
- Parameters:
y (ArrayLike) – Uniformly sampled signals with shape
(n, m)or(n,).DMP (Mapping[str, Any]) – Initial parameters. It must contain
dt; other missing parameters use DMP defaults.
- Returns:
DMP parameter dictionary containing recursively fitted weights.
- Return type:
DMPType
- robotblockset.dmp.x_decodeDMP(DMP: Mapping[str, Any], S: MutableMapping[str, Any]) MutableMapping[str, Any][source]
Advance a recursive-regression DMP state by one step.
- Parameters:
DMP (Mapping[str, Any]) – DMP parameter dictionary.
S (DMPState) – Mutable state containing phase, position, and scaled velocity.
- Returns:
Updated state dictionary.
- Return type:
DMPState
- robotblockset.dmp.integrateStepCartesianDMP(DMP: Mapping[str, Any], S: MutableMapping[str, Any], phase_scaling: float = 1.0) MutableMapping[str, Any][source]
Advance a combined Cartesian DMP state by one Euler step.
- Parameters:
DMP (Mapping[str, Any]) – Combined Cartesian DMP parameter dictionary.
S (DMPState) – Mutable state containing a seven-dimensional pose
y, six- dimensional scaled velocityz, and phasex.phase_scaling (float, optional) – Positive canonical-phase time-scaling factor. Values greater than
1slow phase progression and values below1accelerate it. Default is1.
- Returns:
Updated Cartesian state with pose, velocity, acceleration, and phase.
- Return type:
DMPState
- Raises:
ValueError – If
phase_scalingis not greater than zero.
Functions
|
Decode a standard DMP into a time, phase, and state path. |
|
Encode a time-parameterized path into a standard DMP. |
|
Generate an SE(3) trajectory from a combined Cartesian DMP. |
|
Generate a trajectory from a standard DMP up to |
|
Generate a quaternion trajectory from a quaternion DMP. |
|
Encode an SE(3) trajectory as a combined Cartesian DMP. |
|
Encode sampled signals into a non-recursive locally weighted DMP. |
|
Encode a quaternion trajectory into a quaternion DMP. |
|
Advance a combined Cartesian DMP state by one Euler step. |
|
Advance a standard DMP state by one Euler step. |
|
Advance a quaternion DMP state by one Euler step. |
|
Advance a recursive-regression DMP state by one step. |
|
Encode uniformly sampled signals using recursive regression. |