rofunc.learning.ml.tpgmm#

1.  Module Contents#

1.1.  Classes#

TPGMM

TPGMMBi

Simple TPGMMBi (no coordination)

TPGMM_RPCtrl

Simple TPGMMBi (no coordination in the representation) with bimanual coordination in the LQR controller

TPGMM_RPRepr

TPGMM for bimanual coordination in representation

TPGMM_RPAll

TPGMM for bimanual coordination in both representation and LQR controller

1.2.  API#

class rofunc.learning.ml.tpgmm.TPGMM(demos_x: Union[List, numpy.ndarray], task_params: dict, nb_states: int = 4, nb_frames: int = None, reg: float = 0.001, plot: bool = False, save: bool = False, save_params: dict = None)[source]#

Initialization

Task-parameterized Gaussian Mixture Model (TP-GMM) :param demos_x: demo displacement :param task_params: task parameters, require {‘frame_origins’: [start_xdx, end_xdx]} :param nb_states: number of states in the HMM :param nb_frames: number of candidate frames in a task-parameterized mixture :param reg: regularization coefficient :param plot: whether to plot the result :param save: whether to save the result :param save_params: save parameters, {‘save_dir’: ‘path/to/save’, ‘save_format’: ‘eps’}

nb_frames = None#

Some related matrices are generated from the demo data with displacement M: Number of demonstrated trajectories in a training set (m will be used as index) T: Number of datapoints in a trajectory (t will be used as index) P: Number of candidate frames in a task-parameterized mixture (j will be used as index/exponent) nb_dim: Dimension of the demo state nb_deriv: Number of derivatives of the demo state

demos_xdx: concat original states with their first derivative, [M, T, nb_dim * nb_deriv] demos_A: the orientation of the p-th candidate coordinate system for this demonstration, [M, T, P, nb_dim, nb_dim] demos_b: the position of the p-th candidate coordinate system for this demonstration, [M, T, P, nb_dim] demos_A_xdx: augment demos_A to original states and their first derivative, [M, T, P, nb_dim * nb_deriv, nb_dim * nb_deriv] demos_b_xdx: augment demos_b to original states and their first derivative, [M, T, P, nb_dim * nb_deriv] demos_xdx_f: states and their first derivative in P frames, [M, T, P, nb_dim * nb_deriv] demos_xdx_augm: reshape demos_xdx_f, [M, T, nb_dim * nb_deriv * P]

get_dx()[source]#
get_A_b()[source]#

Get transformation matrices from custom task parameters :return: demos_A, demos_b, demos_A_xdx, demos_b_xdx

hmm_learning() rofunc.learning.ml.hmm.HMM[source]#
poe(model: rofunc.learning.ml.hmm.HMM, show_demo_idx: int) rofunc.learning.ml.gmm.GMM[source]#

Product of Expert/Gaussian (PoE), which calculates the mixture distribution from multiple coordinates :param model: learned model :param show_demo_idx: index of the specific demo to be reproduced :return: The product of experts

fit() rofunc.learning.ml.hmm.HMM[source]#

Learning the single arm/agent trajectory representation from demonstration via TP-GMM.

reproduce(model: rofunc.learning.ml.hmm.HMM, show_demo_idx: int) Tuple[numpy.ndarray, rofunc.learning.ml.gmm.GMM][source]#

Reproduce the specific demo_idx from the learned model

generate(model: rofunc.learning.ml.hmm.HMM, ref_demo_idx: int) Tuple[numpy.ndarray, rofunc.learning.ml.gmm.GMM][source]#

Generate a new trajectory from the learned model

class rofunc.learning.ml.tpgmm.TPGMMBi(demos_left_x: Union[List, numpy.ndarray], demos_right_x: Union[List, numpy.ndarray], task_params: dict, nb_states: int = 4, reg: float = 0.001, plot: bool = False, save: bool = False, save_params: dict = None)[source]#

Bases: rofunc.learning.ml.tpgmm.TPGMM

Simple TPGMMBi (no coordination)

Initialization

Task-parameterized Gaussian Mixture Model (TP-GMM) :param demos_x: demo displacement :param task_params: task parameters, require {‘frame_origins’: [start_xdx, end_xdx]} :param nb_states: number of states in the HMM :param nb_frames: number of candidate frames in a task-parameterized mixture :param reg: regularization coefficient :param plot: whether to plot the result :param save: whether to save the result :param save_params: save parameters, {‘save_dir’: ‘path/to/save’, ‘save_format’: ‘eps’}

fit() Tuple[rofunc.learning.ml.hmm.HMM, rofunc.learning.ml.hmm.HMM][source]#

Learning the single arm/agent trajectory representation from demonstration via TP-GMM.

reproduce(models: List, show_demo_idx: int) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#

Reproduce the specific demo_idx from the learned model

generate(models: List, ref_demo_idx: int) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#

Generate a new trajectory from the learned model

class rofunc.learning.ml.tpgmm.TPGMM_RPCtrl(demos_left_x, demos_right_x, task_params, nb_states: int = 4, reg: float = 0.001, plot: bool = False, save: bool = False, save_params: dict = None)[source]#

Bases: rofunc.learning.ml.tpgmm.TPGMMBi

Simple TPGMMBi (no coordination in the representation) with bimanual coordination in the LQR controller

Initialization

Task-parameterized Gaussian Mixture Model (TP-GMM) :param demos_x: demo displacement :param task_params: task parameters, require {‘frame_origins’: [start_xdx, end_xdx]} :param nb_states: number of states in the HMM :param nb_frames: number of candidate frames in a task-parameterized mixture :param reg: regularization coefficient :param plot: whether to plot the result :param save: whether to save the result :param save_params: save parameters, {‘save_dir’: ‘path/to/save’, ‘save_format’: ‘eps’}

get_rel_demos()[source]#
fit() Tuple[rofunc.learning.ml.hmm.HMM, rofunc.learning.ml.hmm.HMM, rofunc.learning.ml.hmm.HMM][source]#
reproduce(models, show_demo_idx: int) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#

Reproduce the specific demo_idx from the learned model

Parameters:
  • models – List of learned models for left, right and relative movement

  • show_demo_idx – index of the specific demo to be reproduced

Returns:

generate(models: List, ref_demo_idx: int) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#

Generate a new trajectory from the learned model

Parameters:
  • models – List of learned models for left, right and relative movement

  • ref_demo_idx – index of the specific demo to be referenced

Returns:

class rofunc.learning.ml.tpgmm.TPGMM_RPRepr(demos_left_x, demos_right_x, task_params, nb_states: int = 4, reg: float = 0.001, plot: bool = False, save: bool = False, save_params: dict = None, **kwargs)[source]#

Bases: rofunc.learning.ml.tpgmm.TPGMMBi

TPGMM for bimanual coordination in representation

Initialization

Task-parameterized Gaussian Mixture Model (TP-GMM) :param demos_x: demo displacement :param task_params: task parameters, require {‘frame_origins’: [start_xdx, end_xdx]} :param nb_states: number of states in the HMM :param nb_frames: number of candidate frames in a task-parameterized mixture :param reg: regularization coefficient :param plot: whether to plot the result :param save: whether to save the result :param save_params: save parameters, {‘save_dir’: ‘path/to/save’, ‘save_format’: ‘eps’}

get_rel_task_params()[source]#
fit() Tuple[rofunc.learning.ml.hmm.HMM, rofunc.learning.ml.hmm.HMM][source]#
reproduce(models: List, show_demo_idx: int) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#
iterative_generate(model_l: rofunc.learning.ml.hmm.HMM, model_r: rofunc.learning.ml.hmm.HMM, ref_demo_idx: int, nb_iter=1) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#
conditional_generate(model_l: rofunc.learning.ml.hmm.HMM, model_r: rofunc.learning.ml.hmm.HMM, ref_demo_idx: int, leader: str) Tuple[numpy.ndarray, numpy.ndarray, None, rofunc.learning.ml.gmm.GMM][source]#
generate(models: List, ref_demo_idx: int, leader: str = None)[source]#
class rofunc.learning.ml.tpgmm.TPGMM_RPAll(demos_left_x, demos_right_x, nb_states: int = 4, reg: float = 0.001, horizon: int = 150, plot: bool = False, save: bool = False, save_params: dict = None, **kwargs)[source]#

Bases: rofunc.learning.ml.tpgmm.TPGMM_RPRepr, rofunc.learning.ml.tpgmm.TPGMM_RPCtrl

TPGMM for bimanual coordination in both representation and LQR controller

Initialization

Task-parameterized Gaussian Mixture Model (TP-GMM) :param demos_x: demo displacement :param task_params: task parameters, require {‘frame_origins’: [start_xdx, end_xdx]} :param nb_states: number of states in the HMM :param nb_frames: number of candidate frames in a task-parameterized mixture :param reg: regularization coefficient :param plot: whether to plot the result :param save: whether to save the result :param save_params: save parameters, {‘save_dir’: ‘path/to/save’, ‘save_format’: ‘eps’}

fit()[source]#
reproduce(model_l: rofunc.learning.ml.hmm.HMM, model_r: rofunc.learning.ml.hmm.HMM, model_c: rofunc.learning.ml.hmm.HMM, show_demo_idx: int) Tuple[numpy.ndarray, numpy.ndarray, rofunc.learning.ml.gmm.GMM, rofunc.learning.ml.gmm.GMM][source]#
generate(model_l: rofunc.learning.ml.hmm.HMM, model_r: rofunc.learning.ml.hmm.HMM, model_c: rofunc.learning.ml.hmm.HMM, ref_demo_idx: int, task_params: dict, leader: str = None)[source]#