Controls Course Project: Implementing PID (Stanley Control for Lateral Control) and Model Predictive Controller in Carla Simulator. The backbon code interfacing with the Carla was used from the Coursera: Introduction to Self-Driving Cars Course.
Model Predictive Controller | PID Controller |
---|---|
100% Waypoints tracked | 87.25% waypoints tracked |
![]() |
![]() |
![]() |
![]() |
-
Install Carla: Download here
-
Download Course1FinalProject.zip into CarlaSimulator folder Download here.
-
Install casadi:
pip install casadi
-
Install Ipopt:
wget http://www.coin-or.org/download/source/Ipopt/Ipopt-3.12.4.tgz
tar xvzf Ipopt-3.12.4.tgz
cd Ipopt-3.12.4/ThirdParty/Blas
./get.Blas
cd ../Lapack
./get.Lapack
cd ../Mumps
./get.Mumps
cd ../Metis
./get.Metis
cd ../../ #Go back to the IPOPT base dir
-
Download HSL: Get Lisensce from here
-
Unpack HSL in Ipopt
cd ~/Ipopt-3.12.4/ThirdParty/HSL
tar xvzf coinhsl-2014.01.10.tar.gz
mv coinhsl-2014.01.10 coinhsl
- Compile HSL
cd coinhsl-2014.01.10
./configure LIBS="-llapack" --with-blas="-L/usr/lib -lblas" CXXFLAGS="-g -O2 -fopenmp" FCFLAGS="-g -O2 -fopenmp" CFLAGS="-g -O2 -fopenmp"
make -j 4
make install
ln -s /usr/local/lib/libcoinhsl.so /usr/local/lib/libhsl.so
echo 'export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"' >> ~/.bashrc
- Compile Ipopt:
cd ~/Ipopt-3.12.4/
mkdir build
cd build
../configure
make -j 4 #Compile using 4 cores (if you have them)
make install
cd CarlaSimulator
./CarlaUE4.sh /Game/Maps/RaceTrack -windowed -carla-server -benchmark -fps=30
In new terminal run,
cd CarlaSimulator/PythonClient/Course1FinalProject
python3 module_7.py -c MPC
Run python3 module_7.py -h
for more options.