- Direct multiple-shooting method based on the lifted contact dynamics / inverse dynamics.
- Riccati recursion algorithm for switching time optimization (STO) problems and efficient pure-state equality constraint handling.
- Primal-dual interior point method for inequality constraints.
- Very fast computation of rigid body dynamics and its sensitivities thanks to Pinocchio.
- Ubuntu 18.04 or 20.04
- gcc (at least C++11 is required), CMake (at least version 3.11)
- Eigen3, Pinocchio ,
- Python3, NumPy (for Python binding)
- gepetto-viewer-corba and/or meshcat-python (optional to visualize the solution trajectory in Python)
- pinocchio-gepetto-viewer (optional to visualize the solution trajectory in C++)
- PyBullet (optional to simulate MPC examples)
- Install the latest stable version of Eigen3 by
sudo apt install libeigen3-dev
- Install the latest stable version of Pinocchio by following the instruction
- Clone this repository and change the directory as
git clone https://github.com/mayataka/robotoc
cd robotoc
- Build and install
robotoc
as
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make install -j$(nproc)
NOTE: if you want to maximize the performance, use CMake option
cmake .. -DCMAKE_BUILD_TYPE=Release -DOPTIMIZE_FOR_NATIVE=ON
- If you want to visualize the solution trajectory with Python, you have to install gepetto-viewer-corba by
sudo apt update && sudo apt install robotpkg-py38-qt5-gepetto-viewer-corba -y
and/or meshcat-python by
pip install meshcat
- If you want to visualize the solution trajectory with C++, in addition to gepetto-viewer-corba, you have to install pinocchio-gepetto-viewer, e.g., by
git clone https://github.com/stack-of-tasks/pinocchio-gepetto-viewer.git --recursive && cd pinocchio-gepetto-viewer
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make install
and add the CMake option for robotoc
as
cmake .. -DBUILD_VIEWER=ON
- If you do not want to install the Python bindings, change the CMake configuration as
cmake .. -DBUILD_PYTHON_INTERFACE=OFF
You can link your executables to robotoc
by writing CMakeLists.txt
, e.g., as
find_package(robotoc REQUIRED)
add_executable(
YOUR_EXECTABLE
YOUR_EXECTABLE.cpp
)
target_link_libraries(
YOUR_EXECTABLE
PRIVATE
robotoc::robotoc
)
target_include_directories(
YOUR_EXECTABLE
PRIVATE
${ROBOTOC_INCLUDE_DIR}
)
Suppose that the Python version is 3.8. The Python bindings will then be installed at ROBOTOC_INSTALL_DIR/lib/python3.8/site-packages
where ROBOTOC_INSTALL_DIR
is the install directory of robotoc
configured in CMake (e.g., by -DCMAKE_INSTALL_PREFIX
).
To use the installed Python library, it is convenient to set the environment variable as
export PYTHONPATH=ROBOTOC_INSTALL_DIR/lib/python3.8/site-packages:$PYTHONPATH
e.g., in ~/.bashrc
. Note that if you use another Python version than python3.8
, please adapt it.
The following three solvers are provided:
OCPSolver
: Solves the OCP for rigid-body systems (possibly with contacts) by using Riccati recursion. Can optimize the switching times and the trajectories simultaneously.UnconstrOCPSolver
: Solves the OCP for "unconstrained" rigid-body systems by using Riccati recursion.UnconstrParNMPCSolver
: Solves the OCP for "unconstrained" rigid-body systems by using ParNMPC algorithm.
where "unconstrained" rigid-body systems are systems without any contacts or a floating-base.
More detailed documentation is available at https://mayataka.github.io/robotoc/.
Examples of these solvers are found in examples
directory.
Further explanations are found at https://mayataka.github.io/robotoc/page_examples.html.
- Configuration-space and task-space optimal control for a robot manipulator iiwa14 using
UnconstrOCPSolver
(iiwa14/config_space_ocp.cpp
,iiwa14/task_space_ocp.cpp
, oriiwa14/python/config_space_ocp.py
):
- Walking, trotting, pacing, and bounding gaits of quadruped ANYmal using
OCPSolver
(yellow arrows denote contact forces and blue polyhedrons denote linearized friction cone constraints) with fixed contact timings (e.g.,anymal/walking.cpp
oranymal/python/walking.py
):
OCPSolver
for the switching time optimization (STO) problem, which optimizes the trajectory and the contact timings simultaneously (anymal/python/jumping_sto.py
andicub/python/jumping_sto.py
):
- The following three example implementations of whole-body MPC are provided:
MPCCrawling
: MPC withOCPSolver
for the crawling gait of quadrupedal robots.MPCTrotting
: MPC withOCPSolver
for the trotting gait of quadrupedal robots.MPCJumping
: MPC withOCPSolver
for the jumping motion of quadrupedal or bipedal robots.MPCWalking
: MPC withOCPSolver
for the walking motion of bipedal robots.
- You can find the simulations of these MPC at
a1/mpc
,anymal/mpc
, andicub/mpc
(you need to install PyBullet, e.g., bypip install pybullet
):
- Citing the STO algorithm of
OCPSolver
:
@misc{katayama2021sto,
title={Structure-exploiting {N}ewton-type method for optimal control of switched systems},
author={Sotaro Katayama and Toshiyuki Ohtsuka},
url={arXiv:2112.07232},
eprint={2112.07232},
archivePrefix={arXiv}
year={2021}}
- Citing
OCPSolver
without the switching time optimization (STO):
@misc{katayama2021liftedcd,
title={Lifted contact dynamics for efficient optimal control of rigid body systems with contacts},
author={Sotaro Katayama and Toshiyuki Ohtsuka},
url={arXiv:2108.01781},
eprint={2108.01781},
archivePrefix={arXiv}
year={2021}}
- Citing
UnconstrOCPSolver
andUnconstrParNMPCSolver
(the repository name wasidocp
in this paper (https://github.com/mayataka/idocp)):
@inproceedings{katayama2021idocp,
title={Efficient solution method based on inverse dynamics for optimal control problems of rigid body systems},
author={Sotaro Katayama and Toshiyuki Ohtsuka},
booktitle={{IEEE International Conference on Robotics and Automation (ICRA)}},
year={2021}}
- S. Katayama and T. Ohtsuka, "Structure-exploiting Newton-type method for optimal control of switched systems," https://arxiv.org/abs/2112.07232, 2021
- S. Katayama and T. Ohtsuka, Lifted contact dynamics for efficient optimal control of rigid body systems with contacts, https://arxiv.org/abs/2108.01781, 2021
- S. Katayama and T. Ohtsuka, Efficient Riccati recursion for optimal control problems with pure-state equality constraints, American Control Conference (ACC) (accepted), https://arxiv.org/abs/2102.09731, 2022
- S. Katayama and T. Ohtsuka, Efficient solution method based on inverse dynamics for optimal control problems of rigid body systems, IEEE International Conference on Robotics and Automation (ICRA), 2021
- H. Deng and T. Ohtsuka, A parallel Newton-type method for nonlinear model predictive control, Automatica, Vol. 109, pp. 108560, 2019