GithubHelp home page GithubHelp logo

ami-iit / lie-group-controllers Goto Github PK

View Code? Open in Web Editor NEW
59.0 20.0 7.0 872 KB

Header-only C++ library containing controllers designed for Lie Groups.

Home Page: https://ami-iit.github.io/lie-group-controllers/

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

CMake 53.42% C++ 46.58%
lie-groups eigen-library header-only cpp

lie-group-controllers's Introduction

lie-group-controllers

C++ Standard Size Size Size

Header-only C++ library containing controllers designed for Lie Groups

Some theory behind the library

The library aims to contain some controllers designed in lie groups. The library depends only on Eigen and manif.

All the controllers defined in lie-group-controllers have in common that they inherit from a templated base class (CRTP). It allows one to write generic code abstracting the controller details. This follows the structure of manif and Eigen.

The library implements two controllers:

  1. Proportional Controller (P controller)
  2. Proportional Derivative Controller (PD controller)

The controllers have the following form

Trivialization Proportional Controller Proportional Derivative Controller
Left (default) $\psi = \psi^d + k_p \text{Log}\left(X^d \circ X^{-1}\right)$ $\dot{\psi} = \dot{\psi}^d + k_d \left(\psi^d - \psi \right) + k_p \text{Log}\left(X^d \circ X^{-1}\right)$
Right $\psi = \psi^d + k_p \text{Log}\left(X^{-1} \circ X^d \right)$ $\dot{\psi} = \dot{\psi}^d + k_d \left(\psi^d - \psi \right) + k_p \text{Log}\left(X^{-1}\circ X^d \right)$

where X and Xᵈ are elements of a Lie group. is the group operator. ψ represents an element in the Lie algebra of the Lie group whose coordinates are expressed in ℝⁿ.

The controllers support all the groups defined in manif. Namely:

  • ℝ(n): Euclidean space with addition.
  • SO(2): rotations in the plane.
  • SE(2): rigid motion (rotation and translation) in the plane.
  • SO(3): rotations in 3D space.
  • SE(3): rigid motion (rotation and translation) in 3D space.

Please you can find further information in

Modern Robotics: Mechanics, Planning, and Control,
Kevin M. Lynch and Frank C. Park,
Cambridge University Press, 2017,
ISBN 9781107156302

Basic Usage

The library implements proportional and proportional derivative controllers on Lie groups. What follows are two simple snippets that you can follow to build and use such controllers. For sake of simplicity, only controllers in SO(3) are shown. The very same applies to the other Lie groups

Proportional controller SO(3)

// set random initial state and zero feedforward
manif::SO3d desiredState, state;
desiredState.setRandom();
state.setRandom();
Eigen::Vector3d feedForward = Eigen::Vector3d::Zero();

// create the controller.
ProportionalControllerSO3d controller;

// In case you want to use the right trivialized controller
// ProportionalControllerTplSO3d<Trivialization::Right> controller;

// set the proportional gain
const double kp = 10;
controller.setGains(kp);

// set the desired state, the feed-forward, and the state
controller.setDesiredState(desiredState);
controller.setFeedForward(feedForward);
controller.setState(state);

// compute the control law
controller.computeControlLaw();
const auto& controlOutput = controller.getControl();

Proportional Derivative controller SO(3)

// set random initial state and zero feedforward
manif::SO3d desiredState, state;
desiredState.setRandom();
state.setRandom();
manif::SO3d::Tangent stateDerivative = Eigen::Vector3d::Zero();
manif::SO3d::Tangent desiredStateDerivative = Eigen::Vector3d::Zero();
Eigen::Vector3d feedForward = Eigen::Vector3d::Zero();

// create the controller.
ProportionalDerivativeControllerSO3d controller;

// In case you want to use the right trivialized controller
// ProportionalDerivativeControllerTplSO3d<Trivialization::Right> controller;

// set the proportional and the derivative gains
const double kp = 10;
const double kd = 2 * std::sqrt(kp);
controller.setGains(kp, kd);

// set the desired state, its derivative, the feed-forward, and the state
controller.setDesiredState(desiredState, desiredStateDerivative);
controller.setFeedForward(feedForward);
controller.setState(state, stateDerivative);

// compute the control law
controller.computeControlLaw();
const auto& controlOutput = controller.getControl();

Dependeces

Build the library

git clone https://github.com/GiulioRomualdi/lie-group-controllers.git
cd lie-group-controllers
mkdir build && cd build
cmake ../
cmake --build .
[sudo] cmake --build . --target install

If you want to enable tests set the BUILD_TESTING option to ON.

Use lie-group-controllers in your project

lie-group-controllers provides native CMake support which allows the library to be easily used in CMake projects. Please add in your CMakeLists.txt

project(foo)
find_package(LieGroupControllers REQUIRED)
add_executable(${PROJECT_NAME} src/foo.cpp)
target_link_libraries(${PROJECT_NAME} LieGroupControllers::LieGroupControllers)

Bug reports and support

All types of issues are welcome.

Note

The original version of the library can be found here.

lie-group-controllers's People

Contributors

danielepucci avatar giulioromualdi avatar riccardogrieco avatar traversaro 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

Watchers

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

lie-group-controllers's Issues

Provide python bindings

I think it would be nice to add the python bindings for the code stored in this library. I think it can be a good first issue if someone wants to get in touch with pybind11.

lie-group-controller implements the CRTP pattern, one may find the implementation a bit obscure. Do not worry! You can follow the bindings implementation provided by manif in https://github.com/artivis/manif/tree/a4ba3df4f793fdce37c98b2cf9778321f9cea7c9/python

If someone is willing to start this activity I can give an hand 😃

cc @Giulero

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.