/towr

A light-weight, Eigen-based C++ library for trajectory optimization for legged robots.

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

A light-weight and extensible C++ library for trajectory optimization for legged robots.

Build Status Documentation ROS hosting CodeFactor License BSD-3-Clause

A base-set of variables, costs and constraints that can be combined and extended to formulate trajectory optimization problems for legged systems. These implementations have been used to generate a variety of motions such as monoped hopping, biped walking, or a complete quadruped trotting cycle, while optimizing over the gait and step durations in less than 100ms (paper).

Features:
✔️ Inuitive and efficient formulation of variables, cost and constraints using Eigen.
✔️ ifopt enables using the high-performance solvers Ipopt and Snopt.
✔️ Elegant rviz visualization of motion plans using xpp.
✔️ ROS/catkin integration (optional).
✔️ Light-weight (~6k lines of code) makes it easy to use and extend.

Install

The easiest way to install is through the ROS binaries:

sudo apt-get install ros-<ros-distro>-towr_ros

In case these don't yet exist for your distro, there are two ways to build this code from source:

  • Option 1: core library and hopper-example with pure CMake.
  • Option 2 (recommended): core library & GUI & ROS-rviz-visualization built with catkin and ROS.

Building with CMake

  • Install dependencies CMake, Eigen, Ipopt:

    sudo apt-get install cmake libeigen3-dev coinor-libipopt-dev

    Install ifopt, by cloning the repo and then: cmake .. && make install on your system.

  • Build towr:

    git clone https://github.com/ethz-adrl/towr.git && cd towr/towr
    mkdir build && cd build
    cmake .. -DCMAKE_BUILD_TYPE=Release
    make
    sudo make install # copies files in this folder to /usr/local/*
    # sudo xargs rm < install_manifest.txt # in case you want to uninstall the above
  • Test (hopper_example.cc): Generates a motion for a one-legged hopper using Ipopt

    ./towr-example # or ./towr-test if gtest was found
  • Use: You can easily customize and add your own constraints and variables to the optimization problem. Herefore, add the following to your CMakeLists.txt:

    find_package(towr 1.2 REQUIRED)
    add_executable(main main.cpp) # Your custom variables, costs and constraints added to TOWR
    target_link_libraries(main PUBLIC towr::towr) # adds include directories and libraries

Building with catkin

We provide a ROS-wrapper for the pure cmake towr library, which adds a keyboard interface to modify goal state and motion types as well as visualizes the produces motions plans in rviz using xpp.

  • Install dependencies CMake, catkin, Eigen, Ipopt, ROS, xpp, ncurses, xterm:

    sudo apt-get install cmake libeigen3-dev coinor-libipopt-dev libncurses5-dev xterm
    sudo apt-get install ros-<ros-distro>-desktop-full ros-<ros-distro>-xpp
  • Build workspace:

    cd catkin_workspace/src
    git clone https://github.com/ethz-adrl/ifopt.git
    git clone https://github.com/ethz-adrl/towr.git
    cd ..
    catkin_make_isolated -DCMAKE_BUILD_TYPE=Release # or `catkin build`
    source ./devel/setup.bash
  • Use: Include in your catkin project by adding to your CMakeLists.txt

    find_package(catkin COMPONENTS towr) 
    include_directories(${catkin_INCLUDE_DIRS})
    target_link_libraries(foo ${catkin_LIBRARIES})

    Add the following to your package.xml:

    <package>
      <depend>towr</depend>
    </package>

Run / Develop

Launch the program using

roslaunch towr_ros towr_ros.launch

Click in the xterm terminal and hit 'o'.

Understand how to tune the parameters according to your problem and other useful information for developers:
➡️ doxygen documentation.

Publications

The theory behind this code can be found in this paper:

A. W. Winkler, D. Bellicoso, M. Hutter, J. Buchli, Gait and Trajectory Optimization for Legged Systems through Phase-based End-Effector Parameterization, IEEE Robotics and Automation Letters (RA-L), 2018:

@article{winkler18,
  author    = {Winkler, Alexander W and Bellicoso, Dario C and 
               Hutter, Marco and Buchli, Jonas},
  title     = {Gait and Trajectory Optimization for Legged Systems 
               through Phase-based End-Effector Parameterization},
  journal   = {IEEE Robotics and Automation Letters (RA-L)},
  year      = {2018},
  month     = {July},
  pages     = {1560-1567},
  volume    = {3},
  doi       = {10.1109/LRA.2018.2798285},
}

Authors

Alexander W. Winkler - Initial Work/Maintainer

The work was carried out at the following institutions:

               

Contributing

We love pull request, whether its new constraint formulations, additional robot models, bug fixes, unit tests or updating the documentation. Please have a look at CONTRIBUTING.md for more information.
See here the list of contributors who participated in this project.

Bugs & Feature Requests

To report bugs, request features or ask questions, please have a look at CONTRIBUTING.md.