The Matlab/Octave programs on this page are free for academic use.
The source codes presented here are implementations of the algorithms described in the book "Robot Programming by Demonstration: A Probabilistic Approach".
Please acknowledge the authors in any academic publications that have made use of this code or part of it.
The GMM-GMR sourcecode is also available in C/C++ (platform independent) on Sourceforge.
GMM/GMR v2.0
Download
Download GMM/GMR sourcecode as a zipped file
Usage
Unzip the file and run 'demo1', 'demo2' or 'demo3' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S., Guenter, F. and Billard, A. (2007) On Learning, Representing and Generalizing a Task in a Humanoid Robot. IEEE Transactions on Systems, Man and Cybernetics, Part B. 37:2, 286-298.
Demo 1
Demonstration of the generalization process using Gaussian Mixture Regression (GMR).
The program loads a 3D dataset, trains a Gaussian Mixture Model (GMM), and retrieves a generalized version of the dataset with associated constraints through Gaussian Mixture Regression (GMR). Each datapoint has 3 dimensions, consisting of 1 temporal value and 2 spatial values (e.g., drawing on a 2D Cartesian plane). A sequence of temporal values is used as query points to retrieve a sequence of expected spatial distribution through Gaussian Mixture Regression (GMR).

Demo 2
Demonstration of Gaussian Mixture Regression (GMR) using spatial components as query points of arbitrary dimensions.
The programs loads a 4D dataset, trains a Gaussian Mixture Model (GMM), and uses query points of 2 dimensions to retrieve a generalized version of the data for the remaining 2 dimensions, with associated constraints, through Gaussian Mixture Regression (GMR). Each datapoint has 4 dimensions, consisting of 2x2 spatial values (e.g., drawing on a 2D Cartesian plane simultaneously with right and left hand). A new sequence of 2D spatial values (data for left hand) is loaded and used as query points to retrieve a sequence of expected spatial distribution for the remaining dimensions (data for right hand), through Gaussian Mixture Regression (GMR).

Demo 3
Demonstration of the smooth transitions properties of data retrieved by Gaussian Mixture Regression (GMR).
This program loads two 3D datasets, trains two separates Gaussian Mixture Model (GMM), and retrieves a generalized version of the two datasets concatenated in time, with associated constraints, through Gaussian Mixture Regression (GMR). Each datapoint has 3 dimensions, consisting of 1 temporal value and 2 spatial values (e.g., drawing on a 2D Cartesian plane). A sequence of temporal values is used as query points to retrieve a sequence of expected spatial distribution through Gaussian Mixture Regression (GMR). The position of the last datapoint in the first dataset is not consistent with the first datapoint of the second dataset. However, by encoding separately the two datasets in GMM and concatenating the components in a single model, a smooth signal with smooth transition between the two data is retrieved through regression.

GMM latent space v2.0
Download
Download GMM latent space sourcecode as a zipped file
Usage
Unzip the file and run 'demo1' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S. and Billard, A. (2005) Recognition and Reproduction of Gestures using a Probabilistic Framework combining PCA, ICA and HMM. In Proceedings of the International Conference on Machine Learning (ICML), pp. 105-112.
Demo 1
Demonstration of a probabilistic encoding through Gaussian Mixture Model (GMM) in a latent space of motion extracted by Principal Component Analysis (PCA).
This programs loads a dataset, finds a latent space of lower dimensionality encapsulating the important characteristics of the motion using Principal Component Analysis (PCA), trains a Gaussian Mixture Model (GMM) using the data projected in this latent space, and projects back the Gaussian distributions in the original data space. Training a GMM with EM algorithm usually fails to find a good local optimum when data are high-dimensional. By projecting the original dataset in a latent space as a pre-processing step, GMM training can be performed in a robust way, and the Gaussian parameters can be projected back to the original data space.

GMR multiConstraints v2.0
Download
Download GMR multiConstraints sourcecode as a zipped file.
Usage
Unzip the file and run 'demo1' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S. and Billard, A. (2007) What is the Teacher's Role in Robot Programming by Demonstration? - Toward Benchmarks for Improved Learning. Interaction Studies. Special Issue on Psychological Benchmarks in Human-Robot Interaction. 8:3, 441-464.
Demo 1
Demonstration of the reproduction of a generalized trajectory through Gaussian Mixture Regression (GMR), when considering two independent constraints represented separately in two Gaussian Mixture Models (GMMs).
Through regression, a smooth generalized trajectory satisfying
the constraints encapsulated in both GMMs is extracted, with associated
constraints represented as covariance matrices.
The program loads two datasets, which are encoded separetely in two
GMMs. GMR is then performed separately on the two datasets, and the
resulting Gaussian distributions at each time step are multiplied to
find an optimal controller satisfying both constraints, producing a
smooth generalized trajectory across the two datasets.
GMM incremental v2.0
Download
Download GMM incremental sourcecode as a zipped file.
Usage
Unzip the file and run 'demo1' or 'demo2' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S. and Billard, A. (2007) Incremental Learning of Gestures by Imitation in a Humanoid Robot. Proceedings of the ACM/IEEE International Conference on Human-Robot Interaction (HRI), pp. 255-262.
Demo 1
Demonstration of an incremental learning process of Gaussian Mixture Model (GMM) using a direct update method.
The demonstration loads a dataset consisting of several trajectories which are presented one-by-one to update the GMM parameters by using an incremental version of the Expectation-Maximization (EM) algorithm (direct update method). The learning mechanism only uses the latest observed trajectory to update the models (no historical data is used).

Demo 2
Demonstration of an incremental learning process of Gaussian Mixture Model (GMM) using a generative method.
The demonstration loads a dataset consisting of several trajectories which are presented one-by-one to update the GMM parameters by generating stochastically a new dataset from the current model, adding the new trajectory to this dataset and updating the GMM parameters using the resulting dataset, through a standard Expectation-Maximization (EM) algorithm (generative method). The learning mechanism only uses the latest observed trajectory to update the models (no historical data is used).

Cone-plane intersection v2.0
Download
Download Cone-plane intersection sourcecode as a zipped file.
Usage
Unzip the file and run 'demo1' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S. and Billard, A. (2006) Teaching a Humanoid Robot to Recognize and Reproduce Social Cues. IEEE International Symposium on Robot and Human Interactive Communication (RO-MAN), pp. 346-351.
Demo 1
Demonstration of a cone-plane intersection interpreted in terms of Gaussian Probability Density Function (PDF).
This program computes the intersection between a cone and a plane, represented as a Gaussian Probability Density Function (PDF). The algorithm can be used to extract probabilistically information concerning gazing or pointing direction. Indeed, by representing a visual field as a cone and representing a table as a plane, the Gaussian distribution can be used to compute the probability that one object on the table is observed/pointed by the user.

Joint/task constraints v2.0
Download
Download Joint/task constraints sourcecode as a zipped file.
Usage
Unzip the file and run 'demo1' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S. and Billard, A. (2008) A Probabilistic Programming by Demonstration Framework Handling Constraints in Joint Space and Task Space. IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), pp. 367-372.
Demo 1
Demonstration of the use of Gaussian Mixture Regression (GMR) and inverse kinematics to reproduce a task by considering constraints both in joint space and in task space.
This program shows the simulation of a robotic arm composed of 2 links and moving in 2D space. Several demonstrations of a skill are provided, by starting from different initial positions. The skill consists of moving each joint sequentially and then writing the alphabet letter 'N' at a specific position in the 2D space.
Constraints in joint space and in task space are represented through Gaussian Mixture Models (GMMs) and Gaussian Mixture Regression (GMR). By using an inverse kinematics process based on a pseudo-inverse Jacobian, the constraints in task space are then projected in joint space. By considering the projected constraints with the ones originally encoded in joint space, an optimal controller is found for the reproduction of the task. We see through this example that the system is able to generalize the learned skill to new robotic arms (different links lengths) and to new initial positions of the robot.

GMR Dynamics v2.0
Download
Download GMR Dynamics sourcecode as a zipped file.
Usage
Unzip the file and run 'demo1' in Matlab.
References
- Calinon, S. (2009) Robot Programming by Demonstration: A Probabilistic Approach. EPFL/CRC Press.
- Calinon, S., Evrard, P., Gribovskaya, E., Billard, A. and Kheddar, A. (2009) Learning collaborative manipulation tasks by demonstration using a haptic interface. In Proc. Intl Conf. on Advanced Robotics (ICAR).
Demo 1
Demonstration of a trajectory learning system robust to perturbation based on Gaussian Mixture Regression (GMR)
This program first encodes a trajectory represented through time 't', position 'x' and velocity 'dx' in a joint distribution P(t,x,dx) through Gaussian Mixture Model (GMM) by using Expectation-Maximization (EM) algorithm. Gaussian Mixture Regression (GMR) is then used to estimate P(x,dx|t), which retrieves another GMM refining the joint distribution model of position and velocity.
The learned skill can then be reproduced by combining an estimation of P(dx|x) with an attractor to the demonstrated trajectories.
