The Iterative Linear Quadratic Regulator (ILQR) is a control algorithm designed to optimize nonlinear systems. This project implements the ILQR algorithm for various applications, providing a robust and efficient method for trajectory optimization.
There are couple advantages to use this package:
- Pure C++ implementation
- Only depends on Eigen (Gtest is optional for testing)
- Easy dependency control using vcpkg
- Cross platform (Tested on Ubuntu 22.04, Ubuntu 20.04, Windows 11)
- High perfomance since there is no dynamic memory allocations (Templated)
- Provides discritization with different integration steppers
- Provides numerical differantiation for continuous/discrete system and the cost function
Before installing ILQR, ensure you meet the following system requirements:
- Git
- CMake
- A build system such as Make or Ninja
- A C++ compiler like g++ or clang
- Optional: Matplotlib, Pandas, and Pillow for visualization
Follow these steps to install ILQR:
-
Clone the repository:
git clone https://github.com/HalukErdogan/ilqr.git
-
Navigate to the repository directory:
cd ilqr
-
Initilize the submodule
git submodule init
-
Update the submodule
git submodule update
-
Configure the package:
cmake --preset default
-
Build the package:
cmake --build --preset default
An example that demonstrates how to solve a trajectory optimization problem for a pendulum on a cart is given in the "example" folder. Follow the steps provided below to execute the example:
-
Run the executable:
For Windows:
./build/examples/pendulum_on_cart/Release/pendulum_on_cart.exe
For Linux:
./build/examples/pendulum_on_cart/pendulum_on_cart
-
Visualize the results:
python3 ./examples/pendulum_on_cart/scripts/visualize.py
Result:
-
Animate the results:
python3 ./examples/pendulum_on_cart/scripts/animate.py
Result:
The performance of the module is tested using the pendulum on cart example provided above. The following table show the execution time of the algorithm in seconds. Tests has been done on 12th Gen Intel(R) Core(TM) i7-12800H processor and Ubuntu 22.04 WSL operation system. The example is built in Release configuration using g++ and make.
Horizon = 101 | Horizon = 501 | Horizon = 1001 | |
---|---|---|---|
Euler Integration | 0.00297155 s | 0.00924278 s | 0.0175842 s |
Runge Kutta 2nd Order | 0.00415075 s | 0.0180604 s | 0.0357379 s |
Runge Kutta 3nd Order | 0.00721841 s | 0.0264217 s | 0.0532759 s |
Runge Kutta 4nd Order | 0.00782524 s | 0.0363073 s | 0.0706778 s |
Note: I wasn't able to recreate same performance results with MSVC. The results were up to 5 times slower with MSVC (Tested on same PC).
- Add continuous system base class
- Add discrete system base class
- Add cost function base class
- Add continuous system with finite diff class
- Add discrete system with finite diff class
- Add cost function with finite diff class
- Add test for finite diff classes
- Add Euler integration stepper
- Add second order Runge - Kutta integration stepper
- Add third order Runge - Kutta integration stepper
- Add fourth order Runge - Kutta integration stepper
- Add constant integration iterator
- Add discritizer class
- Add quadratic cost function
- Add ilqr class
- Add line search
- Add example: pendulum on cart
- Add scripts to visualize and animate the result of example
- Add inequality constrains using control barrier functions
- Add adaptive itegration iterator
Author: Haluk Erdogan
Email: haluk_erdogan@outlook.com
Linkedin: haluk_erdogan