Giter VIP home page Giter VIP logo

loco-3d / crocoddyl Goto Github PK

View Code? Open in Web Editor NEW
696.0 696.0 145.0 21.58 MB

Crocoddyl is an optimal control library for robot control under contact sequence. Its solver is based on various efficient Differential Dynamic Programming (DDP)-like algorithms

License: BSD 3-Clause "New" or "Revised" License

Python 9.19% CMake 0.52% C++ 90.29%
code-generation conda crocoddyl differential-dynamic-programming legged-robotics model-predictive-control motion-planning optimal-control robotics ros trajectory-optimization

crocoddyl's Introduction

Crocoddyl Logo

Documentation Code style: black

Introduction

Crocoddyl is an optimal control library for robot control under contact sequence. Its solvers are based on novel and efficient differential dynamic programming (DDP) algorithms. Crocoddyl computes optimal trajectories and feedback gains. It uses Pinocchio for fast computation of robot dynamics and analytical derivatives.

If you want to learn more about Crocoddyl and its solvers, we suggest reading [1] [2] [3] and visiting PUBLICATIONS.md. If you want to follow the current developments and contribute, please directly refer to the devel branch.

🐊 Crocoddyl features

Crocoddyl is versatile:

  • Various optimal control solvers (DDP, FDDP, BoxFDDP, Ipopt, etc)
  • Analytical and sparse derivatives via Pinocchio
  • Differential geometry support leveraging Pinocchio
  • Various integrators, dynamics, costs and constraints
  • Numerical differentiation support
  • Automatic differentiation support via CppAD

Crocoddyl is efficient and flexible:

  • Cache friendly
  • Multi-threading support via OpenMP
  • Python bindings (including abstractions) via Boost Python
  • C++14/17/20 compliant
  • Extensively tested
  • Automatic code generation support via CppADCodeGen

🐧 Installation

Crocoddyl can be easily installed on various Linux (Ubuntu, Fedora, etc.) and Unix distributions (Mac OS X, BSD, etc.). Below, there are different ways to install Crocoddyl.

🐉 From

Just run the following command in the terminal:

   conda install crocoddyl -c conda-forge

Conda installation supports conda install.

🐍 From

Just run the following command in the terminal:

  pip install --user crocoddyl

🐢 With ROS

Just clone it (with --recursive) into a catkin workspace and compile it.

📦 From Debian / Ubuntu packages, with robotpkg

  1. If you have never added robotpkg's software repository, do it now:
    sudo tee /etc/apt/sources.list.d/robotpkg.list <<EOF
    deb [arch=amd64] http://robotpkg.openrobots.org/packages/debian/pub $(lsb_release -sc) robotpkg
    EOF
    
    curl http://robotpkg.openrobots.org/packages/debian/robotpkg.key | sudo apt-key add -
    sudo apt update
  2. Install Crocoddyl and its Python bindings:
    sudo apt install robotpkg-py3\*-crocoddyl
  3. Configure your environment variables:
    export PATH=/opt/openrobots/bin:$PATH
    export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
    export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
    export PYTHONPATH=/opt/openrobots/lib/python3.10/site-packages:$PYTHONPATH

📁 From source

  1. Install Crocoddyl's mandatory dependencies:
  2. (optional) Install Crocoddyl's optional dependencies
    • OpenMP                           (for multi-threading support)
    • CppADCogen                  (for code-generation support)
    • Ipopt                                 (for Ipopt support)
    • example-robot-data      (for robotic examples, install Python loaders)
    • gepetto-viewer-corba   (for display)
    • meshcat-python             (for display)
    • jupyter                              (for notebooks)
    • matplotlib                        (for plotting)
  3. Clone it (with --recursive), create a build directory inside, and:
    cmake .. && make && make install

🔍 Documentation

Crocoddyl's Doxygen documentation is available here. Alternatively, you can also check out the Jupyter notebooks. Start in the following order.

Moreover, after installation, you could run the examples as follows:

python -m crocoddyl.examples.quadrupedal_gaits "display" "plot" # enable display and plot

or run examples, unit tests and benchmarks from your build directory as

cd build
make test
make -s examples-quadrupedal_gaits INPUT="display plot" # enable display and plot
make -s benchmarks-cpp-quadrupedal_gaits INPUT="100 walk" # number of trials ; type of gait

where it is possible to enable display and/or plots generated by our examples using the environment variables:

export CROCODDYL_DISPLAY=1
export CROCODDYL_PLOT=1

🔭 Citing Crocoddyl

To cite Crocoddyl in your academic research, please use the following BibTeX lines:

@inproceedings{mastalli20crocoddyl,
  author={Mastalli, Carlos and Budhiraja, Rohan and Merkt, Wolfgang and Saurel, Guilhem and Hammoud, Bilal
  and Naveau, Maximilien and Carpentier, Justin and Righetti, Ludovic and Vijayakumar, Sethu and Mansard, Nicolas},
  title={{Crocoddyl: An Efficient and Versatile Framework for Multi-Contact Optimal Control}},
  booktitle = {IEEE International Conference on Robotics and Automation (ICRA)},
  year={2020}
}

Please consider citing our selected publications and contributions described in PUBLICATIONS.md.

Crocoddyl's contributions extend beyond efficient software development. Please also consider citing the algorithm contributions of our different solvers and formulations:

  • Feasibility-driven DDP (FDDP): [1]
  • Control-limited feasibility-driven DDP (Box-FDDP): [2]
  • Inverse-dynamics trajectory optimization and equality-constrained DDP solver (Intro solver): [3]

Finally, please also consider citing Pinocchio, which contributes to the efficient implementation of rigid body algorithms and their derivatives. For more details on how to cite Pinocchio visit: https://github.com/stack-of-tasks/pinocchio.

📖 Selected publications

[1] C. Mastalli, R. Budhiraja, W. Merkt, G. Saurel, B. Hammoud, M. Naveau, J. Carpentier, L. Righetti, S. Vijayakumar and N. Mansard. Crocoddyl: An Efficient and Versatile Framework for Multi-Contact Optimal Control, IEEE International Conference on Robotics and Automation (ICRA), 2020

[2] C. Mastalli, W. Merkt, J. Marti-Saumell, H. Ferrolho, J. Sola, N. Mansard and S. Vijayakumar. A Feasibility-Driven Approach to Control-Limited DDP, Autonomous Robots, 2022

[3] C. Mastalli, S. P. Chhatoi, T. Corbères, S. Tonneau and S. Vijayakumar. Inverse-Dynamics MPC via Nullspace Resolution, IEEE Transactions on Robotics, 2023

💻 Questions and Issues

You have a question or an issue? Please open a new issue.

🔍 Steering Committee

Crocoddyl is managed by a steering committee which meets every two weeks to discuss ongoing developments. The committee is led by Carlos Mastalli, Nicolas Mansard, Guilhem Saurel and Justin Carpentier are other members of the committee.

©️ Credits

✍️ Written by

👷 With contributions from

🏆 Acknowledgments

Crocoddyl development was supported by the EU MEMMO project and the EU RoboCom++ project. It is maintained by the Robot Motor Intelligence (RoMI) Lab @ Heriot-Watt University, the Gepetto team @ LAAS-CNRS, and the Willow team @ INRIA.

crocoddyl's People

Contributors

andreadelprete avatar arthurh91 avatar cmastalli avatar ddliu365 avatar edantec avatar gfadini avatar ggory15 avatar jaehyunshim avatar jcarpent avatar jmirabel avatar julesser avatar ksyy avatar lmontaut avatar manifoldfr avatar nim65s avatar nmansard avatar olivier-stasse avatar pepms avatar pre-commit-ci[bot] avatar proyan avatar sergim96 avatar skleff1994 avatar spykspeigel avatar teguhsl avatar traversaro avatar vasilyrakche avatar wegank avatar wxmerkt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crocoddyl's Issues

Data class for each individual cost and writing get functions as static ones

In GitLab by @cmastalli on Nov 9, 2018, 14:34

This feature was partially developed in the previous code structure, and it completely removed in the ongoing one.
Having these data classes will allow us to have additionally improvements such as zero computation of Jacobian or Hessian which are constant.

@rbudhira Do you have any feedback regarding this topic?

cannot import action modellimpact in example

Hi, I try to run example in crocoddyl, but the library seems outdated in python.

Can you check?

No actionmodelimpact model appears.

Traceback (most recent call last):
File "walk.py", line 5, in
from crocoddyl import (ActionModelImpact, ActivationModelWeightedQuad, ActuationModelFreeFloating, CallbackDDPLogger,
ImportError: cannot import name ActionModelImpact

Abstract methods for advanceConfiguration and differenceConfiguration

In GitLab by @cmastalli on Nov 15, 2018, 17:34

This defines addition and difference operators of the geometrical manifold of a given system. advanceConfiguration is typically used to integrate the geometrical system, instead differenceConfiguration to differentiate a geometrical system (for instance for computing a state feedback).

Move the dynamics class to c++

In GitLab by @proyan on Nov 14, 2018, 08:44

I have started moving the dynamics class, since it is the most independent one. I will create the python bindings and keep the current API

Refactoring

In GitLab by @nmansard on Dec 19, 2018, 11:05

I pushed a new branch topic/refact. The name is possibly not properly chosen. It contains a DDP and a KKT solver developed from scratch with the complete unittest (without regularization yet). Here is a description of the work.

  • Dynamic and cost functions are merged into a single class, named ActionModel and ActionData. The class is mostly able to compute the transition function (xnext = f(x,u)) and the cost function (cost = l(x,u)): this is a the calc(x,u) method, returning both the next state and the cost ; and a calcDiff(x,u) method which computes the useful derivatives of calc. A LQR and a unicycle model are implemented, as well as a num-diff extension of existing models.

  • The current DDP class is divided into the problem formulation (SingleShootingProblem) and the solver (SolverDDP and SolverKKT). The problem class is composed of running action models RunningModels and terminal action model TerminalModel, with corresponding data. It is able to calc(xs,us) and calcDiff(xs,us) along the trajectory.

  • Both solvers respect the same organization: computeDirection (equivalent to inverting the KKT or backward DDP pass), tryStep(stepLength) (equivalent to x+dx for KKT and forward pass for DDP), and test a step (expectedImprovement) and the algo stop (stoppingCriteria). The main method is solver.solve(maxiter,init_xs,init_us,isFeasible=[True|False]). Note that both solvers are able to warm start from a non feasible trajectory (i.e x(t+1) != f(xt,ut)).

  • Unitest are proving the DDP and KKT have the exact same behavior for a LQR system (for both feasible and unfeasible init guess), and same behavior on NLP when warm-started from a feasible guess. An integrative test also shows that KKT and LQR converges to the same solution on the unicycle problem.

Renaming of abstract methods for defining a system

In GitLab by @cmastalli on Nov 15, 2018, 11:06

An user should be able to change only two main things:

  1. the computation of f(x,v,u), and
  2. the linear approximation of f(x,v,u).

The current names are forwardCalc and backwardCalc. This names have a sense for DDP but no meaning inside the concept of the dynamics. Indeed DDP during its forward-pass needs to update the dynamics and its backward-pass to update the linear approximation of the dynamics.

Therefore these methods should be renamed as:

  1. updateDynamics
  2. updateLinearAppr

Dynamic system abstract class

In GitLab by @cmastalli on Nov 15, 2018, 11:00

All dynamic problem as the form of:
[v; a] = [v; f(x,v,u)]

and its linearise model is:

[dv; da] = [0, I; fx, fv]*[dx; dv] + [0; fu]*du

where dx is the linearised configuration point. Note that the linearised point belongs to the tangential space.

This abstraction allows us to implement ABA dynamics, constrained forward dynamics, linear systems, etc. Both are implement in f(x,u,v).
Furthermore we can reuse the numerical differentiation (NumDiff) routines. Indeed, we just need to NumDiff only in the lower-block (see linearised dynamics)

Name for the library

In GitLab by @cmastalli on Nov 15, 2018, 11:26

cddp isn't a good name, it's not fun neither.

I put few keywords and generate the different options. @rbudhira and @nmansard please feel free to have a feedback/opinion.

image
image
image

These are some examples. Please let discuss about it

Prospective tasks

In GitLab by @nmansard on Dec 21, 2018, 16:05

Here is a quick list of the main tasks for the next 15 days.

Make sure the solver run good and nice.

  1. unittest the regularization auto setup (#18, #35).
  2. validate with integrative tests on the manipulator arm (#43).

Implement the phased dynamics on the quadruped

  1. validate the solver for tracking a COM on fixed contact.
  2. validate the solver on a single phase with terminal contact constraint. The constraint can be modeled by any possible mean, although we should first validate that penalty based method with simple gain tuning is sufficient (#44).
  3. validate the solver with two phases: first phase with a flying contact and a terminal "constraint" and a a second phase with only fixed constraint (#45).
  4. extend the previous system with several phases (#46).
  5. introduce the analytical derivatives for the dynamics in contact (#16,#52).
  6. formally study the meaning of KKT dynamics, with respect to introducing a state constraint in the OCP. It is possible that the two problems are equivalent. In such a case, it might be better to directly handle the contact constraint as a state constraint, either with penalty or aug-lag (#47).

Implement on the biped.

  1. introduce the biped model (#23).
  2. introduce flat foot contact constraint (#50).
  3. make a OCP with the humanoid and flat foot (#23).

Refactoring.

  1. understand the refact code, and discuss it (#48,#39).
  2. possibly start to implement the refact structure in the main tree.

Initializing with unconsistant xs,us

In GitLab by @nmansard on Dec 20, 2018, 10:47

The DDP solver is an SQP solver which optimize with the decision variables xs,us, so that F(xs,us) = 0, with F a stack of dynamic constraints f(x,u) - xnext = 0. The main difference between a DDP solver and a classical SQP solver (for example KKT based) is that in DDP there is a explicit way to project a candidate xs,us on the constraint (by making a rollout). Indeed, we tend to produce the initial guess by using this explicit projection. I believe that this is a mistake, because finding a us that does not make the xs very bad is difficult and expensive.

On the other hand, the DDP solver, like any SQP solver, should be able to find a good feasible candidate pair x1s,u1s from a bad unfeasible pair xs,us. But does that make a sense to run a backward pass from an unfeasible pair xs,us ?

In term of implementation: yes it is acceptable: all derivatives are computable, hence the backward pass can be run. But then the Value derivatives Vx' are computed at xguess', and xguess' is not f(xguess,uguess). So we need to "relinearize" to move Vx' computed at xguess' to Vx' computed at f(xguess,ugess).

The trick (well mathematically it is exact, so not exactly a trick) is easy. But I was not able to find this trick in the literature. I also double check that we have the exact same behavior than a KKT in case of LQR problem and infeasible initial guess.

No package example_robot_data

I've installed crocoddyl from the robotpkg binaries and it is correctly sourced. The package robotpkg-example-robot-data is installed. However, I get:

Traceback (most recent call last):
  File "bipedal_walking_from_foot_traj.py", line 6, in <module>
    import example_robot_data
ImportError: No module named example_robot_data

NumDiff abstraction for dynamics systems

In GitLab by @cmastalli on Nov 15, 2018, 11:10

We should provide an abstraction for computing the NumDiff, so the users can quickly test a system. NumDiff routines are needed to compute the linear approximation of the dynamics (see issue #19). Having solved the issue #19 and #20, we can defined by default the updateLinearAppr by running a NumDiff routine.

The user can still deploy its analytical derivatives or potentially other methods such as automatic differentiation.

Close unit-test milestone

In GitLab by @nmansard on Nov 28, 2018, 09:52

The unit test list should be as follows:

  1. DDP converges in 1 step for LQR systems
  2. DDP and KKT for LQR matches
  3. num-diff versus algo diff
  4. stopping criteria unit test (tbf, possibly compare with KKT)
  5. regularization unit test (test that backward pass with regularization or with control cost is equal)
  6. regularization tuning test (tbf)

We may also want to add an integrative test with the arm (and later with legged robots), i.e. comparing the numerical results of the test with a reference execution.

Unit-test validation before merge-request, implemented by @nim65s should be active.

When all that points are matched, close the milestone unittest.

Generalization of integrator and discretizer

In GitLab by @cmastalli on Nov 21, 2018, 17:55

The FloatingBaseMultibodyEuler(Integrator/ExpDiscretizer) classes describes general integration or discretization rules. This is possible thanks to task #29. However, before doing such kind of generalization, we need deal with #26.

Logo for the library

In GitLab by @cmastalli on Dec 19, 2018, 16:58

Before incorporating any logo, we should have first few proposals. Feel free to make your contribution :)

Allocated, on-going, priority ... labels

In GitLab by @nmansard on Nov 15, 2018, 11:56

As we are not using a trello-like board (not available in gitlab), we have to play with labels to obtain a similar effect. I suggest using "assignee" to "book" a task, which means you intend to work on this task now or in the future. Then, label a task as "on-going" if you are effectively working on the task. It is intended that you have only ONE task on-going, and that results about this task should be delivered at the end of the day.
Every task should be feasible in 10 hours of work. Otherwise, the task should be subdivided. In that case, by hierarchical: keep the task open, and open subtasks that should be referred to the initial task.
If for some reasons you are not able to deliver the work by the end of the day, commit it to a dedicated branch topic/ongoing_taskid . The last commit may be labeled as partial with the initial keyword [PARTIAL]. Once the task done, the commits may be refactored and the branch topic/ongoing_taskid should be destroyed. In this case, it is acceptable that the the last commit contains craps, as it is only used to backup. Providing partial commit is useful in case of delay (personal latency for example) that allows coworker to take over the lead on an ongoing task.

In case you open such a temporary branch, dont hesitate to comment it in the issue thread.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.