/LearningMPC-1

Learning based Model Prodictive Control for online iterative trajectory optimization for the F1/10 car

Primary LanguageC++

LearningMPC

Learning based Model Prodictive Control for online iterative trajectory optimization for F1/10 autonomous racing.

The F1/10 hardware used for experiments:

The car is learning to improve its racing policy iteratively online as it completes more and more laps, until the policy converges to a minimum lap time.

Initial Sample Safe Set is collected using a path following controller. Starting from Lap 3, control policies are generated by learning MPC. Every time a lap is completed, cost-to-go values are updated for all collected samples. Stability and recursive feasibility of MPC is gauranteed by enforcing the terminal state to land within a convex hull of a selected subset of collected samples from previous laps. The MPC manages to minimize the cost-to-go for the terminal state at each run, and is solved with OSQP solver at 20Hz. The sample safe set continues to grow as more and more data is being collected along the way.

The improvement of racing performance over laps is shown here below. The black one is the initial lap with path following controller. The colored ones are the improved trajectories given by LMPC

Dependencies

  1. Install the f1/10 racecar simulator: https://github.com/mlab-upenn/f110-fall2019-skeletons/tree/master/racecar_simulator

  2. Install QSQP Solver: https://osqp.org/docs/get_started/sources.html

  3. Install the C++ Eigen wrapper for OSQP: https://robotology.github.io/osqp-eigen/doxygen/doc/html/index.html

How to Run

Build everything with catkin_make from the root directory of your catkin workspace

Since the simulator uses a different map as default, you will need to add the track map used in this project to the map folder inside the simulator package. Copy levinelobby_track.png and levinelobby_track.yaml to racecar_simulator\map, and modify the path in simulator.launch to levinelobby_track.yaml

Then launch the simulator by entering the command below in terminal:

roslaunch racecar_simulator simulator.launch

Position the car approximately in the starting position as shown below using the interactive marker in Rviz (The car must be placed ahead of the starting line)

Then launch LearningMPC node:

roslaunch LearningMPC lmpc.launch

Add the "LMPC" topic in the Rviz display panel to visualize predicted trajectories by LearningMPC

Enter n in the simulator terminal to unlock the car

Note on how to load this map

The map data which consists of an image file and a yaml file with meta info resides in the /data folder. Place the two files under the /map folder in the F1/10 racecar simulator package. Finally, modify this line in the launch file to point to the yaml file (levinelobby_track.yaml in this case) before you launch the simulator.

Results

Lap 5 (Top speed 1.2 m/s)

Lap 25 (Top speed 3 m/s)

After Lap 60, it converges to an optimal policy (Top speed 6 m/s) with precisely controlled high speed drifting.

.

With low frictions, it converges to a policy with lower top speed but with more drifting.

.

Obstacle Avoidance 1:

.

Obstacle Avoidance 2 (low friction):

.

Lap time vs number of iterations completed:

Converged optimal policy recorded:

Currently working on Gaussian Process and local linear regression for system identification to update the dynamic model online.

The project is inspired by "Learning How to Autonomously Race a Car: a Predictive Control Approach, Ugo Rosolia and Francesco Borrelli"