svenlr / car-physics-pacejka

Vehicle dynamics with a sophisticated friction model and drive-train model that can be used to augment any multi-body simulation (such as Gazebo) involving vehicles.
BSD 2-Clause "Simplified" License
13 stars 1 forks source link
acados ode-model simulation vehicle

Detailed, fast C/C++ vehicle physics based on acados

The python code in this project is used to generate C and C++ libraries that provide discretized car dynamics. In the current state, one can simulate a tenth-scale chassis with drive-train and tire friction dynamics.

Features

How to integrate this in a multi-body simulator such as Gazebo?

Given the current velocities of a car body, vertical loads on the wheels and the controls (throttle and steering angles), this software can calculate the movement of the car in the form of force and torque to be applied to the car within the next millisecond.

Timing with multi-body simulation.png

Integration in multi-body simulation

Installation

Prerequisites

Build

The CMakeLists.txt is set up so that the code is automatically re-generated using acados when the Python files are changed.

mkdir -p build/
cd build/
cmake -DCMAKE_BUILD_TYPE=Release ..
make -j6

Use

The build output to be linked in a C project consists of the libacados_sim_solver_car.so library. Refer to the acados API documentation on how to use it.

The build output to be linked in a C++ project consists of the libcar_physics_pacejka.so library (see CMakeLists.txt) and the libacados_sim_solver_car.so library. A simple C++ interface CarSimulation.h/.cpp is build into the library libcar_physics_pacejka.so which handles the interaction with the acados solver in the other library.

Appendix

Model

States: $v_x, vy, r, \omega, \omega{f \triangle}, \omega_{r \triangle}$
Linear velocities, angular velocity, motor velocity, differential velocities

Controls: $DC, \delta{fl},\delta{fr},\delta{rl},\delta{rr}$
Duty cycle, steering angles

Spatial view of the model

Spatial states: $v_x, v_y, r$
friction model

Drive-train view of the model

Drive-train states: $\omega, \omega{f \triangle}, \omega{r \triangle}$
$\omega{f \triangle}, \omega{r \triangle}$ are the relative velocities in-between front wheels and in-between rear wheels respectively.

drive train model

Plots generated with the implemented Pacejka-type tire model

tire model