Header-only C++ library for robotics, control, and path planning algorithms.


Actions Status Actions Status Actions Status Actions Status CodeFactor Grade .

header pic


A header-only, fully-templated C++ library for robotics algorithms.

This repo is inspired by AtsushiSakai/PythonRobotics. Instead of being just educational, this repo focuses on runtime speed and modularity. The examples folder contains short tutorials for each implemented algorithm.

While this is still a work in progress, I would really appreciate it if you left any suggestion or just a star. Any help is greatly appreciated!


The main goal for this library is to:

  1. Implement as many robotics algorithms as possible, without sacrificing quality. These include, e.g., control, path planning, and estimation algorithms.

  2. Be easy to use and to get started with, thus the header-only and minimal external dependencies.

  3. Be fast: by making use of templates and by relying on Eigen, most algorithms use static-size data structures known at compilation time.


  • C++11 compiler

  • CMake 3.14+ (if using Visual Studio on Windows you should be able to import the project as a CMake project)

  • The C++ dependencies will be obtained automatically by CPM.cmake. Note that the library only depends on Eigen, but matplotplusplus is used in the examples folder to plot the results.

Getting started

Following are some examples to get started. The examples folder contains several examples that are useful to get started.

CppRobotics aims to be modular, which means:

  • Once you define a dynamical system, most algorithms will be readily available for it to use

  • Data should flow seamlessly between objects (e.g. estimator -> controller)

  • Once you setup an algorithm, you should be able to change the dynamical system and integrate it directly

Clone this repo

git clone https://github.com/giacomo-b/CppRobotics.git

Building and running the examples

Given a generic EXAMPLE that you want to run, the following commands build it:

cmake -S examples/EXAMPLE -B build/EXAMPLE
cmake --build build/EXAMPLE

On Windows, this will default to a Debug configuration. To build the project in release mode, you can add --config=Release after the first command.

To run the example on Linux, macOS and most Unix-based systems:


On Windows:


where CONFIG_TYPE is either Debug or Release, depending on how you configured the project.

Using the library in your own projects

Importing the library

#include <robotics/robotics.h>

System definition

SystemBase represents a generic dynamical system. In most cases, you will be using either a LinearSystem or NonlinearSystem.

Since the library is templated, in order to define a system you need to define:

  • The number of states

  • The number of inputs (control actions)

  • The number of outputs


static constexpr int N = 2; // Number of states
static constexpr int M = 1; // Number of inputs
static constexpr int P = 2; // Number of outputs

Type aliases can come handy, and prevent the coder from mixing up the wrong dimensions:

using State = Robotics::ColumnVector

   using Input = Robotics::ColumnVector

    using Output = Robotics::ColumnVector

; using StateMatrix = Robotics::SquareMatrix ; using InputMatrix = Robotics::Matrix ; using OutputMatrix = Robotics::Matrix ; using FeedthroughMatrix = Robotics::Matrix ;

Let's define a linear system whose state form is

x' = A * x + B * u
y  = C * x + D * u

To setup a LinearSystem:

StateMatrix A;
A << 1, 0
     0, 1;

InputMatrix B;
B << 1, 0;

OutputMatrix C;
C << 1, 0,
     0, 1;

Note that having templates not only improves runtime performance, but allows to carry out compile-time checks on the types you define. If you initialize some of the matrices above with the wrong number of elements, the compiler will throw an error.

Matrices C and D are not required: they will be null by default if not provided. In this case, D will be null. To define the system:

   system(A, B, C);

The initial state is zero by default. You can set a custom initial state as follows:

system.SetInitialState(State(1.0, -1.0));

Development features

Check out TheLartians/ModernCppStarter if you want to include these features in your project.

Running tests

From the root directory:

cmake -S test -B build/test
cmake --build build/test
CTEST_OUTPUT_ON_FAILURE=1 cmake --build build/test --target test

# or simply call the executable: 

To also collect code coverage information, run CMake with the -DENABLE_TEST_COVERAGE=1 option.

Running clang-format for autoformatting

This requires clang-format, cmake-format and pyyaml to be installed on the current system.

cmake -S test -B build/test

# view changes
cmake --build build/test --target format

# apply changes
cmake --build build/test --target fix-format

See Format.cmake for details.

Build the documentation

The documentation is automatically built and published whenever a GitHub Release is created. To manually build documentation, call the following command.

cmake -S documentation -B build/doc
cmake --build build/doc --target GenerateDocs
# view the docs
open build/doc/doxygen/html/index.html

To build the documentation locally, you will need Doxygen, jinja2 and Pygments installed your system.

Build everything at once

The project also includes an all directory that allows building all targets at the same time. This is useful during development, as it exposes all subprojects to your IDE and avoids redundant builds of the library.

cmake -S all -B build
cmake --build build

# run tests
# format code
cmake --build build --target fix-format
# run standalone
./build/standalone/Robotics --help
# build docs
cmake --build build --target GenerateDocs

Additional tools

The test and standalone subprojects include the tools.cmake file which is used to import additional tools on-demand through CMake configuration arguments. The following are currently supported.


Sanitizers can be enabled by configuring CMake with -DUSE_SANITIZER=


Static Analyzers

Static Analyzers can be enabled by setting -DUSE_STATIC_ANALYZER= , or a combination of those in quotation marks, separated by semicolons. By default, analyzers will automatically find configuration files such as .clang-format. Additional arguments can be passed to the analyzers by setting the CLANG_TIDY_ARGS, IWYU_ARGS or CPPCHECK_ARGS variables.


Ccache can be enabled by configuring with -DUSE_CCACHE= .


  • Add more algorithms
  • Add support for nonlinear systems automatic differentiation, so that the Jacobians are automatically computed (see autodiff)
  • Add a README.md to each example folder, to explain the theory
  • Cache the packages downloaded by CPM.CMake (currently everything is re-downloaded everytime a new example is built)
  • Many more, feel free to add your ideas!


As mentioned above, this repo was originally inspired by AtsushiSakai/PythonRobotics. So go check it out if you want to see more algorithms (or if you want to help port a few of them!).

  • Revamp build process

    Revamp build process

    What I'm trying to achieve:

    • Better adhere to CMake conventions
    • Better adhere to CMake best practices
    • Improve new developer experience
    • Reduce build times
    • Allow for building all code in one (and only one) binary dir
    • Improve readability
    • Improve maintainability
    • Remove unnecessary complexity
    opened by ChrisThrasher 14
  • Should the library be renamed to Control++?

    Should the library be renamed to Control++?

    As per the title, should we use Control++ (acronym C++) instead of CppRobotics?

    I like the generality of CppRobotics, but it is also unoriginal and might convey the wrong idea about the library.

    Open to suggestions!

    help wanted good first issue question 
    opened by giacomo-b 8
  • Eigen offline

    Eigen offline

    Hey! On building the repository, it throws a fatal error of not being able to clone the eigen repository from gitlab. This is because the main eigen repository is offline due to a technical problem. Can the build process be modified to avoid such things later on? Like maybe maintaining a mirror and cloning that instead?

    opened by kvkpraneeth 3
  • Mistake in build instructions

    Mistake in build instructions

    This first command here fails to run because the directory examples/EXAMPLE doesn't exist:

    cmake -S examples/EXAMPLE -B build/EXAMPLE
    cmake --build build/EXAMPLE
    opened by codeinred 3
  • Should classes accept `std::size_t` as template parameters instead of `int`?

    Should classes accept `std::size_t` as template parameters instead of `int`?

    All class templates currently require ints as input parameters. This choice was made because Eigen accepts ints as parameters, and it is straightforward to just forward the value.

    Since int can be negative, a better solution would be to require std::size_t as template parameters. These inputs can then be cast to ints and then forwarded to Eigen (e.g. static_cast<int>(N)).

    opened by giacomo-b 3
  • The time step should be specified at each call

    The time step should be specified at each call

    The time step is currently set with a setter method, it would be better if the user had to specify the time step every time the dynamics is propagated, such as in:

    system.PropagateDynamics(input, dt);

    Examples of the problem:



    Why is this a problem?

    1. The user must explicitly call the setter, otherwise they might be propagating the dynamics with the wrong (default) time step
    2. Variable time steps are not easily supported
    good first issue 
    opened by giacomo-b 2
  • CMake Error

    CMake Error

    On building with cmake with version 3.16.3, build process crashes with this output:

    CMake Error at CMakeLists.txt:56 (set_target_properties):
      INTERFACE_LIBRARY targets may only have whitelisted properties.  The
      property "CXX_STANDARD" is not allowed.
    -- Configuring incomplete, errors occurred!

    Line 56, where the fault points to

    opened by kvkpraneeth 1
  • Add cubic spline interpolation header and example

    Add cubic spline interpolation header and example

    Hi, This is my first time attempting to contribute to an open source project, so my apologies for my lack of experience. What I attempting to do is to add the cubic spline interpolation modules in this project. Basically it's the same module as PythonRobotic cubicspline planner. But i think the algorithm itself is not path planning, but an interpolation polynomial, therefore I've added a new workspace called Polynomial.

    On the side note, seems the algorithm relies on linspace function, so I've created one in the common.h. The unit test for the linspace is included. Also, one thing iIve notice is somehow the deg2rad function causing compile error due to multiple definition, so i added inline to it.

    Please let me know anything i can help to make the code better..

    opened by kurogane1031 5
  • Using CRTP instead of standard polymorphism

    Using CRTP instead of standard polymorphism

    A Curiously Recurring Template Pattern (CRTP) would probably be a better design choice instead of classic inheritance that makes use of virtual functions.

    Advantage in the case of, e.g. LinearSystem and NonlinearSystem (both of which are Systems):

    1. There's need to replace System instances at runtime or to work with heterogeneous collections of Systems.
    2. CRTP would be more flexible
    3. Virtual methods imply vtable lookups at runtime. With CRTP the compiler knows which class gets instantiated, thus guaranteeing better performance.
    opened by giacomo-b 3
Engineer. Control, Robotics, Inertial Sensors. #CPP #Python #Rust
Optimization-based real-time path planning for vehicles.

path_optimizer_2 This is a newer version of my path planning ROS package for autonomous driving vehicles ?? path_optimizer. Improvements Higher succes

Li Jiangnan 71 Dec 26, 2022
CXXGraph is a Header-Only C++ Library for Graph Representation and Algorithms

CXXGraph is a small library, header only, that manages the Graph and it's algorithms in C++. In other words a "Comprehensive C++ Graph Library".

ZigRazor 186 Dec 29, 2022
C++17 (-O2) template for competitive programming algorithms, which contains numerous math algorithms.

cpplibForCP C++17 (-O2) template for competitive programming algorithms, which contains numerous math algorithms. Aims: build a stable, fast, easy-to-

null 33 Nov 25, 2022
A library of common data structures and algorithms written in C.

C Algorithms The C programming language includes a very limited standard library in comparison to other modern programming languages. This is a coll

Simon Howard 2.9k Jan 9, 2023
c++ library including few algorithms and datastructures

c++ library including few algorithms and datastructures

null 2 Dec 25, 2021
Library for building multi-level indoor routes using routing algorithms.

Library for building multi-level indoor routes using routing algorithms. You can easily construct routing graphs and find the shortest path for optimal indoor navigation.

Navigine 5 Nov 21, 2022
This library contains a set of algorithms for working with the routing graph.

Library for building multi-level indoor routes using routing algorithms. You can easily construct routing graphs and find the shortest path for optimal indoor navigation.

Navigine 5 Nov 21, 2022
IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation.

IntX IntX is a C++11 port of IntX arbitrary precision Integer library with speed, about O(N * log N) multiplication/division algorithms implementation

Telepati 8 Dec 22, 2022
Collection of algorithms and data structures in C++ and Java

Collection of algorithms and data structures in C++ and Java

Andrei Navumenka 1.7k Jan 2, 2023
Several algorithms and data structures implemented in C++ by me (credited to others where necessary).

Algorithms This repository contains my implementations of several algorithms and data structures in C++ (credited to others where necessary). It has i

Petar Veličković 589 Dec 19, 2022
C++ implementations of well-known (and some rare) algorithms, while following good software development practices

ProAlgos: C++ This project is focused on implementing algorithms and data structures in C++, while following good software engineering practices, such

ProAlgos 485 Dec 7, 2022
Provide building blocks (software, hardware and algorithms) for implementing SLAM using small sensors

RemoteSLAM The purpose of this repo is to provide the building blocks (software drivers, hardware and algorithms) for implementing SLAM systems using

Autonomous Drones Lab, Tel Aviv University 38 Jan 20, 2022
Fundamentals of Data structures and algorithms in c++

Data Structures & Algorithms About the repository: Contains theories and programming questions related to fundamentals of data structures and algorith

fifu 46 Dec 1, 2022
Every week exercises for Introduction to Algorithms and Programming

cen109-algorithms commands to compile and link C and C++ programs gcc filename.c -o executableFileName g++ filename.cpp -o executableFileName filename

null 2 Dec 19, 2022
c language's datastruct and algorithms.

cdsaa 介绍 学习数据结构与算法的C语言实现 主要数据结构 动态字符串 动态数组 单向链表 栈 主要算法 更新中. . . 目录结构 |-- include |---- CArray.h 动态数组 |---- CList.h 单向链表 |---- CStack.h 栈 |---- CString

Ticks 1 Nov 24, 2021
Snowball compiler and stemming algorithms

Snowball is a small string processing language for creating stemming algorithms for use in Information Retrieval, plus a collection of stemming algorithms implemented using it.

Snowball Stemming language and algorithms 611 Dec 30, 2022
Collection of various algorithms in mathematics, machine learning, computer science, physics, etc implemented in C for educational purposes.

The Algorithms - C # {#mainpage} Overview The repository is a collection of open-source implementation of a variety of algorithms implemented in C and

The Algorithms 15.3k Jan 5, 2023
Algorithms & Data structures in C++.

Algorithms & Data Structures in C++ 目标 ( goal ) : 经典的算法实现 (classical algorithms implementations) 服务器端 (based on linux/gcc) 正确,易于使用和改造, 一个头文件一个算法,并附带一个

xtaci 4.7k Dec 30, 2022
In this project, we implemented twelve different sorting algorithms.

C - Sorting algorithms & Big O In this project, we implemented twelve different sorting algorithms. Tests tests: Folder of test files. Provided by Alx

Nicholas M Mwanza 1 Oct 26, 2021