This repository contains the source code to learn robot inverse dyanimcs models, based on the Lagrangian Inspired Polunomial (LIP) Kernal described in our IEEE TRO paper G. Giacomuzzo, R. Carli, D. Romeres, A. Dalla Libera, 'A Black-Box Physics-Informed Estimator based on Gaussian Process Regression for Robot Inverse Dynamics Identification'. The associated data and trained models can be downloaded here.
This repository produces the results shown on our paper G. Giacomuzzo, R. Carli, D. Romeres, A. Dalla Libera, 'A Black-Box Physics-Informed Estimator based on Gaussian Process Regression for Robot Inverse Dynamics Identification'. Additionally, it can be used to learn the inverse dynamics, the inertia matrix, the coriolis and gravitational contributions of rigid body systems like robot manipulators.
The project directory is organized as follows:
-
Utility functions to read config files from python scripts
config_files/Utils.py
-
Python library used to implement the Gaussian Proccess estimators
gpr_lib/
-
Code for the Monte-Carlo experiment on the simulated PANDA robot described in Section 5.A of the paper.
PANDA_MC_test/
-
Scripts and config files to learn the inverse dynamics on the real PANDA robot described in Section 5.B.1 of the paper on the MELFA RV4FL robot
RealData/PANDA/
RealData/MELFA_RV4FRL
-
Code used to simulate the PANDA robot using the SymPyBotics library
simulated_envs/
-
Some pytest tests:
tests/
-
Python scripts on the top level:
GP_estimator_real_data.py
script to perform GPR with Lagrangian models on real dataGP_estimator_single_joint.py
script to perform GPR with single joint approachGP_estimator.py
script to perform GPR with with Lagrangian modelsModels_Lagrangian_kernel.py
library file containing Lagrangian models implementation based ongpr_lib
Models.py
library file containing single joint models implementation based ongpr_lib
Parametric_estimator.py
script to perform parametric identificationProject_Utils_.py
utils to load data, compute scores and plot results
To replicate the results presented in the paper, after installing this repository, please download the data and the model from here and follow the subsequent steps.
Choose one of the following options:
- Download data and generate the plots
- Download
Simulation_PANDA/Results/
directory from here - Copy the
Results/
directory inside thePANDA_MC_test/
directory - Generate plots:
cd PANDA_MC_test/plots python generate_figures.py
- Re-run the experiments using the provided models
-
Download
Simulation_PANDA/Results/
directory from here -
Copy the
Results/
directory inside thePANDA_MC_test/
directory -
The directory
PANDA_MC_test/Results/
contains the trained models -
Run test bash script to execute all the experiments:
$ cd PANDA_MC_test/ $ bash ./run_whole_MC_test[_cuda].sh # (use _cuda if want to run the experiment on GPU)
-
The script will generate the test data inside
PANDA_MC_test/data/
and test the models. Predictions on test trajectories will be saved inPANDA_MC_test/Results/
. Logs will be saved inPANDA_MC_test/log/MC_test_[cuda_]log.txt
. -
Generate plots:
$ cd PANDA_MC_test/plots $ python generate_figures.py
- Train and test the models
-
Run the train and test bash script:
$ cd PANDA_MC_test/ $ bash ./run_whole_MC_train_test[_cuda].sh # (use cuda if want to run the experiment on GPU)
-
The script will generate the data inside
PANDA_MC_test/data/
, train the models and test their performance. Models and predictions on test trajectories will be saved inPANDA_MC_test/Results/
. Logs will be saved inPANDA_MC_test/log/MC_train_test_[cuda_]log.txt
. -
Generate plots:
$ cd PANDA_MC_test/plots $ python generate_figures.py
- Download the
Robots/PANDA/Results
directory from here - Copy the downloaded
Results/
directory inside theRealData/PANDA/
directory - Download the
Robots/PANDA/Experiments
directory from here - Copy the downloaded
Experiments/
directory inside theRealData/PANDA/
directory
- Plots generation
RealData/PANDA/Results
contains the results presented in the paper. To generate plots:$ cd RealData/PANDA/ $ python plot_nMSE_boxplot.py
- Re-run the experiments (train and test)
- Generate PANDA numeric functions:
$ cd gpr_lib/GP_prior/LK $ python Compute_lagrangian_kernel_LIP.py $ python Compute_lagrangian_kernel_LSE.py
- Generate config files:
$ cd RealData/PANDA/config/MC_TEST_REAL $ python gen_config.py $ python gen_config_single_joint.py
- Run the experiment:
$ cd ../../ # (move to the RealData/PANDA directory)
$ bash ./run_PANDA_experiments.sh
- Generate plots:
$ cd RealData/PANDA/CollectedData/ $ python plot_nMSE_boxplot.py
- Download the
Robots/MELFA_RV4FRL/Results
directory from here - Copy the downloaded
Results/
directory inside theRealData/MELFA_RV4FRL/
directory - Download the
Robots/MELFA_RV4FRL/Experiments
directory from here - Copy the downloaded
Experiments/
directory inside theRealData/MELFA_RV4FRL/
directory
- Plots generation
RealData/MELFA_RV4FRL/Results/
contains the results presented in the paper. To generate plots:To print the nMSE boxplots:$ cd RealData/MELFA_RV4FRL/
To print the input distribution:$ python plot_nMSE_boxplot.py
$ python plot_input_distribution.py
- Re-run the experiments (train and test)
- Generate MELFA numeric functions:
$ cd gpr_lib/GP_prior/LK $ python Compute_lagrangian_kernel_LIP.py -robot_strucutre '000000' -robot_name 'PANDA_6dof' $ python Compute_lagrangian_kernel_LSE.py -robot_strucutre '000000' -robot_name '6dof'
- Generate config files:
$ cd RealData/MELFA/config/MC_TEST_REAL/ $ python gen_config.py $ python gen_config_single_joint.py $ python gen_config_parametric_ID.py
- Run the experiment
$ cd ../../ # (move to the RealData/MELFA/ folder) $ bash ./run_MELFA_experiments.sh
- Generate plots:
$ cd RealData/PANDA/CollectedData/ $ python plot_nMSE_boxplot.py
-
Assume your data are stored in
data/my_data.pkl
- data should be a pandas dataframe with column names
[q_1, ..., q_n, dq_1, ..., dq_n, ddq_1, ..., ddq_n, 'output'_1, .. ,'output'_n]
with the output name specified in the config file
- data should be a pandas dataframe with column names
-
write your own config file, see for example the file generated inside
PANDA_MC_test/config/
for examples of the required parameters. The config file is assumed to be inconfig_files/my_config.ini
$ python GP_estimator.py -config 'config_files/my_config.ini' -kernel_name 'LK_GIP_sum'
- Clone or download this repository.
- Create a conda environment
conda env create --file=environment.yaml
conda activate LIP4RID
pip install torch
# This is not mandatory
pre-commit install
Giulio Giacomuzzo: giulio.giacomuzzo@gmail.com
Alberto Dalla Libera: alberto.dallalibera.1@gmail.com
Diego Romeres: romeres@merl.com
See CONTRIBUTING.md for our policy on contributions.
Released under AGPL-3.0-or-later
license, as found in the LICENSE.md file.
All files, except as noted in the external libraries below:
Copyright (C) 2024 Mitsubishi Electric Research Laboratories (MERL).
SPDX-License-Identifier: AGPL-3.0-or-later
Three external libraries are included in this repository:
- GPR-PyTorch with MIT license LICENSE.md
- SymPyBotics with BSD-3-Clause license LICENSE.txt
- Deep Lagrangian Networks with MIT license LICENSE.txt