Skip to content

get_started

Sébastien Kleff edited this page Aug 27, 2024 · 10 revisions

Getting Started

Welcome to the Machines in Motion Lab !! In this page you will learn how to get started with using the codebase in the lab.

The most commonly used packages used in the lab are :

  1. Pinocchio - A rigid body dynamic library used to for robot math.
  2. Crocoddyl - A efficient robot optimization package

it will be best to install them by following the links first !

Setting up the simulation environment

After installing these packages, the next step will be to take a look at mim_robots. Mim_robots contains APIs to easily setup simulations with robots used in the lab (such as Solo12, Kuka IIWA ...). It allows you to switch between different simulators based on your preference.

Getting started with Crocoddyl

A nice place to start with croccoddyl is this repository . The minimal_examples_crocoddyl provides simple examples on how to setup an optimization problem with crocoddyl for the Kuka Robot.

Getting started with Non linear MPC

Easy starting point to setup non linear MPC automatically from templated config files is croco_mpc_utils. It contains APIs that make problem constructions easy. The same principles can be used for other robots as well. This setup can also be used to run MPC on the robots.

Non linear optimization packages

There are two places one can start to look

  1. mim_solvers - This package contains efficiently implemented SQPs that exploit sparsity for optimal control problems. The also contain several solver options underneath to switch between based on preference.
  2. BiconMP - Its a fast non linear optimization package for MPC. The details on how to use it are in the repository.

Note : The recommendation is to use mim_solvers over biconvexMP because it more generic and powerful .

Getting started with robot hardware

Check the links in the wiki for robot hardware. They provide information on how to work with the robots in the lab !

Setup a new machine to run experiments on the KUKA

The goal of this section is to setup a new machine and environment to run experiments on the KUKA.

This setup is currently used for KUKA demos on the gold desktop. The main idea is to have ROS 2 globally installed while building / installing a colcon workspace inside a dedicated conda environment.

  • Install Ubuntu 22.04 and create an Ubuntu pro account to setup the real-time kernel using pro enable realtime-kernel. You can get more information here.

  • Install ROS 2 humble (desktop install + development tools + additional libraries required to build the workspace).

    • sudo apt install ros-humble-desktop
    • sudo apt install ros-dev-tools
    • sudo apt install python3-colcon-common-extensions
    • sudo apt-get install libcereal-dev
    • sudo apt-get libncurses5-dev
    • sudo apt-get freeglut3-dev

Note that this could be greatly simplified as most of those libraries will be installed again by conda in each specific environment. It would be nice to try to replace the previous commands by sudo apt install ros-humble-ros-base

  • Install miniconda
  • Create a conda environment and activate it

conda create -n demo

conda activate demo

  • Setup the conda environment. Note that we install cmake and colcon inside the conda environment and use those to build the colcon workspace. This is a good practice. Indeed, using colcon / cmake from the global ROS2 install (i.e. outside the conda environment) results in a messy installation of python libraries in conda. Also, we need to impose the version of cmake to 3.23 (instead of more recent version found by conda) because some CMake macros used in un-maintained repos are unavailable. Finally, the version of python is imposed by the dynamic graph manager which finds python outside the conda environment.

conda install python==3.10

conda install mim-solvers -c conda-forge

conda install cmake==3.23 setuptools=69.5.1 pkg-config colcon-common-extensions -c conda-forge

conda install catkin_pkg empy lark -c conda-forge

conda install ncurses -c conda-forge

conda install websockets

conda install matplotlib

conda install -c conda-forge robot_descriptions

pip install pybullet

  • Create your workspace, e.g. mkdir workspace_demo

  • Clone the source code inside the workspace (either by hand or using treep). The provided demo workspace on gold contains all necessary repos to run constrained MPC experiments (SQP paper) and the polishing task in MPC using online estimation (ICRA).

  • Build and install with colcon:

colcon build --merge-install --install-base $CONDA_PREFIX --cmake-args -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF -DBUILD_TESTING=OFF

One can use cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DCMAKE_BUILD_TYPE=Release with make [-j6] && make install to build packages one by one.

Launch Kuka DGM

  1. sudo -s
  2. source /opt/ros/humble/setup.bash
  3. source /home/kuka/miniconda3/envs/test/setup.bash
  4. ros2 run dg_kuka dgm_iiwa_main
  5. In a seperate terminal, apply step 1, 2 and 3 and run your python script. Here is an example.

Troubleshooting

Error during colcon build

--- stderr: real_time_tools

/usr/bin/ld: cannot find -ledit: No such file or directory

/usr/bin/ld: cannot find -lXmu: No such file or directory

Fix:

apt install xmu headers

apt install libedit headers

Clone this wiki locally