This repository contains the code of the controltlbx library that can be used as a standalone library or via the application executable that provides a GUI.
The purpose of the controltlbx is to provide an efficient way of computing trajectories of control systems. It's ultimate goal is to be a solver for (optimal) control design, i.e. designing a control that achieve a certain (optimal) trajectory.
Features :
- Simulation of nonlinear dynamical systems
- Simulation of control-nonlinear dynamical systems
- Linear control (a specification of the above)
Planned features :
- Motion Planing for a state configuration
- Motion planning of a full trajectory
- Optimal Control problem solver
- Delayed ODE
- Real time control design
The application configures and launches experiments (simulations) from a single .json file. The GUI is a wrapper around this program that build the .json configuration file and post-processes the results .
All examples presented below can be configure in a single .json file and will therefore be configured and launched one after another.
This section describe a simulation of the Van derPol oscillator. The dynamical system is as follows: $$ \begin{pmatrix}\dot{x}_1 \ \dot{x}_2 \end{pmatrix} = \begin{pmatrix}{x}_2 \ \mu(1-(x_1)^2)x_2-x_1 \end{pmatrix}. $$
Configuration file : exp.json
{
"experiences": [
{
"type": "dynamical",
"name": "vanderpol",
"run": true,
"dimensions": {
"state_dim": 2,
},
"dynamics": {
"parameters": {
"mymu": 1
},
"f": [
"dxdt(0) = x(1);",
"dxdt(1) = mymu*(1-x(0)*x(0))*x(1)-x(0);"
],
"dfdx": [
"dxdt_dx(0,1) = 1;",
"dxdt_dx(1,0) = -mymu*x(1)*x(0)/2.-1;",
"dxdt_dx(1,1) = mymu*(1-x(0)*x(0));"
]
},
"trajectories": {
"timesteps": {
"method": "linspace",
"linspace": {
"tmin": 0,
"tmax": 20,
"nbT": 513
}
},
"x0": [
[2, 0],
[-4, 1],
["sqrt(2)", "1/2"]
]
},
"methods": {
"ode": {
"method": "RK4",
"parameters": {}
},
"interpolation": {
"method": "INTERP_LINEAR",
"parameters": {
"extend_left": "EXTEND_ZERO",
"extend_right": "EXTEND_ZERO"
}
}
},
"outputs": {
"traj": {
"cli": false,
"file": {
"yn": true,
"dir": "./results/",
"subdir": "data/",
"filename": "trajectory.dat",
"time-filename": "time.dat"
}
},
"cntrl": null
},
"postprocess": {
"plots": [
{
"data": {
"x": 0,
"y": 1,
"nb": 1
},
"type": "line",
"title": "Evolution the x_1 coordinate over time for the first initial condition",
"xlabel": "Time",
"ylabel": "x_1",
"output": {
"gui": false,
"file": {
"yn": true,
"dir": "./results/",
"subdir": "plots/",
"filename": "x1_coordinate.png"
}
}
},
{
"data": {
"x": 1,
"y": 2,
"nb": 0
},
"type": "line",
"title": "Phase diagram of all initial conditions",
"xlabel": "x_1",
"ylabel": "x_2",
"output": {
"gui": true,
"file": {
"yn": true,
"dir": "./results/",
"subdir": "plots/",
"filename": "phase.png"
}
}
},
{
"data": {
"x": 0,
"y": 2,
"nb": 0
},
"type": "line",
"title": "Evolution the x_2 coordinate over time for all initial conditions",
"xlabel": "time",
"ylabel": "x_2",
"output": {
"gui": true,
"file": {
"yn": true,
"dir": "./results/",
"subdir": "plots/",
"filename": "x2_coordinate_all.png"
}
}
}
]
}
}
}
Then using the following commands
mkdir build
cd build
cmake ..
make
cd ../app
./mpp_app ./exp.json
python3 postprocess.py exp.json
produce :
![]() |
![]() |
![]() |
The workflow of the app is as follows:
flowchart LR
A(exp.json) --> B(./app)
B -->|Configure| C(exp.hpp)
B -->|Compile| D(exp.cpp)
C --> D
B -->|Run| E(./exp)
D --> E
E -->|Output| F(data)
A --> G(postprocess.py)
F --> G
G -->|Produce| H(Plots)
The library documentation is generated with doxygen and automatically served at link. In particular, you can find the documentation for the structure of the .json configuration file at link.
- Eigen
sudo apt install libeigen3-dev
- For postprocessing : python3, numpy, matplotlib
sudo apt install python3
pip3 install numpy matplotlib
Require cmake & g++
Optional valgrind for memcheck
git clone https://github.com/tschmoderer/motion-planning-toolbox.git
cd motion-planning-toolbox
mkdir build
cd build
cmake ..
make
make test
(Opt) make memcheck
A main inspiration for this software (and its architecture) mostly come from the control-toolbox, copyright by ETH Zurich - BSD-2 License
Portions of this software are copyright of their respective authors :