Awesome
Copra
Copra (Control & preview algorithms) is a C++ library implementing linear model predictive control. It relies on quadratic programming (QP) solvers. Python bindings are available.
@Stephane Caron
This work was originally made by Vincent Samy and extended by Niels Dehio.
Copra is licensed under the BSD-2-Clause. However, its default QP solver (eigen-quadprog) is licensed under the LGPL-2 and this cannot be changed. Please be aware of the related restrictions if you plan to work with copra. At a later date, we might switch copra default QP solver to one with a less restrictive license.
Installation
Copra should compiles and is tested on Linux, macOS and Windows.
Ubuntu LTS (16.04, 18.04, 20.04)
You must first setup our package mirror:
curl -1sLf \
'https://dl.cloudsmith.io/public/mc-rtc/stable/setup.deb.sh' \
| sudo -E bash
You can also choose the head mirror which will have the latest version of this package:
curl -1sLf \
'https://dl.cloudsmith.io/public/mc-rtc/stable/setup.deb.sh' \
| sudo -E bash
You can then install the package:
sudo apt install libcopra-dev
Dependencies
- C++ compiler with C++14 support (see below for C++11 support)
- CMake >= 2.8
- Doxygen: to generate documentation (optional)
- Eigen >= 3.2
- eigen-quadprog
Optional
- Boost for Python bindings (>= 1.58) and unit tests
- GUROBI >= 4.0: optional QP solver
- eigen-gurobi: bindings for GUROBI
- eigen-qld: optional QP solver
- eigen-osqp: optional QP solver
- pygen-converter: for python bindings
Building from source on Linux
The library is written in c++14. Compiler that can not support it won't be able to compile it.
git clone --recursive git@github.com:jrl-umi3218/copra.git
cd Copra
mkdir build && cd build
cmake ..
ccmake . # configure e.g. PYTHON_BINDING or BUILD_TESTING
make -j4
sudo make install
C+11 compatible code
A c++11 compatible is available on a specific branch.
Although it exists, it may not be updated as often as the master branch.
The branch is called c++11-compatible
. To use it, before compilation and after cloning the repo, do:
git checkout c++11-compatible
Then follow the steps in the section just above.
Testing
C++ tests will be compiled in your build folder if you enabled the
BUILD_TESTING
option:
cd build/tests
./TestSolvers --log_level=all
./TestLMPC --log_level=all
Once Python bindings are installed, you can check them with:
cd binding/python/tests
python TestMPController.py
Documentation
Doxygen documentation is available online
You can also check out unit tests, as well as the following two examples:
Reference
Linear model predictive control including optimization of the initial state employing COPRA has been described in
@unpublished{Dehio2021ICRA,
title = {Safe Impacts with Soft Contacts Based on Learned Deformations},
author = {Dehio, Niels and Kheddar, Abderrahmane},
booktitle={IEEE Int. Conf. on Robotics and Automation},
pdf = {https://hal.archives-ouvertes.fr/hal-02973947/document},
url = {https://hal.archives-ouvertes.fr/hal-02973947},
year = {2021}
}
Writing code takes time. If this implementation is useful for your research, please cite the related publication.