Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact c6 project instructions in README.md #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
154 changes: 126 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,144 @@
# Control and Trajectory Tracking for Autonomous Vehicle
# Project: Control and Trajectory Tracking for Autonomous Vehicle

# Proportional-Integral-Derivative (PID)
## Proportional-Integral-Derivative (PID)

In this project, you will apply the skills you have acquired in this course to design a PID controller to perform vehicle trajectory tracking. Given a trajectory as an array of locations, and a simulation environment, you will design and code a PID controller and test its efficiency on the CARLA simulator used in the industry.

### Installation
## Project Steps Overview

1. Design the PID controller in C++
2. Integrate the controller with the CARLA simulator.
3. Tune the parameters using a technique
4. Explain a strategy to test the controller and perform the test.
5. Create plots to show how successful the controller is as well as the simulator video.
6. Talk about how the controller recovered/etc. Can be a sentence.



## Starter Files

Run the following commands to install the starter code in the Udacity Workspace:

Clone the <a href="https://github.com/udacity/nd013-c6-control-starter/tree/master" target="_blank">repository</a>:
Clone the <a href="https://github.com/udacity/nd013-c6-control-starter" target="_blank">repository</a>:

`git clone https://github.com/udacity/nd013-c6-control-starter.git`

## Run Carla Simulator
```bash
git clone https://github.com/udacity/nd013-c6-control-starter.git
cd nd013-c6-control-starter
```

Open new window
![plot](images/project-setup.png)

* `su - student`
// Will say permission denied, ignore and continue
* `cd /opt/carla-simulator/`
* `SDL_VIDEODRIVER=offscreen ./CarlaUE4.sh -opengl`
To get started, switch to the project directory

## Compile and Run the Controller
```bash
cd project
```

Open new window
You should see the project structure as follow:

```bash
.
├── README.md # Must read
├── cserver_dir
├── install-ubuntu.sh
├── manual_control.py
├── pid_controller
├── plot_pid.py
├── run_carla.sh
├── run_main_pid.sh
├── simulatorAPI.py
├── steer_pid_data.txt
└── throttle_pid_data.txt
```

* `cd nd013-c6-control-starter/project`
* `./install-ubuntu.sh`
* `cd pid_controller/`
* `rm -rf rpclib`
* `git clone https://github.com/rpclib/rpclib.git`
* `cmake .`
* `make` (This last command compiles your c++ code, run it after every change in your code)
## Installation

### For Windows & Ubuntu 18.04 and Earlier
* Pre-requisites:
* python3.7
* carla (API)
* pip
* numpy
* pygame
* gtest
* websocket
* Additional installations:
* sudo apt install python3.7
* python3.7 -m pip install -U pip carla pandas matplotlib numpy pygame websocket-client --user
* sudo apt-get install -y libgoogle-glog-dev libgtest-dev


* The deb installation is the easiest way to get the latest release in Linux.
```
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1AF1527DE64CB8D9
sudo add-apt-repository "deb [arch=amd64] http://dist.carla.org/carla $(lsb_release -sc) main"
sudo apt-get update # Update the Debian package index
sudo apt-get install carla-simulator=0.9.10-2
cd /opt/carla-simulator
# Linux
./CarlaUE4.sh
```

More details can be found at [CARLA Quick Start Installation](https://carla.readthedocs.io/en/latest/start_quickstart/)
> NOTE: CARLA does NOT work on Ubuntu 20.04 or Mac yet!!

* Make sure ALL is working well:
* Open a terminal an launch CARLA (if you don't have it open already):
```bash
cd /opt/carla-simulator
# Linux
./CarlaUE4.sh
```

![plot](images/carla-test.png)

Then, in a few seconds the Carla Simulator will launch:

## Testing
![plot](images/carla-test-window.png)

### Install all dependencies

Run the following commands in another terminal window inside the project folder:
```bash
./install-ubuntu.sh
```

![plot](images/dependencies-install.png)

Then, compile the `rpclib` library. This library is a msgpack-rpc library written using modern C++. The goal of this library is to provide a simple, no-nonsense RPC solution.
```bash
cd pid_controller
rm -rf rpclib
git clone https://github.com/rpclib/rpclib.git
```

![plot](images/rpclib-clone.png)

```bash
cmake .
make
```

![plot](images/rpclib-build.png)


## Build the project and run the simulator

To test your installation run the following commands.

* `cd nd013-c6-control-starter/project`
* `./run_main_pid.sh`
This will silently fail `ctrl + C` to stop
* `./run_main_pid.sh` (again)
Go to desktop mode to see CARLA
Run the following commands in the existing terminal window:
```bash
cd pid_controller/
cmake .
make
cd nd013-c6-control-starter/project
./run_main_pid.sh
# This will silently fail
# ctrl + C to stop
```

![plot](images/carla-simulator.png)

If error bind is already in use, or address already being used

Expand Down Expand Up @@ -91,13 +188,13 @@ Useful variables:
The values of the error and the pid command are saved in thottle_data.txt and steer_data.txt.
Plot the saved values using the command (in nd013-c6-control-refresh/project):

```
```bash
python3 plot_pid.py
```

You might need to install a few additional python modules:

```
```bash
pip3 install pandas
pip3 install matplotlib
```
Expand All @@ -116,3 +213,4 @@ Answer the following questions:
- If the simulation freezes on the desktop mode but is still running on the terminal, close the desktop and restart it.
- When you will be tuning the PID parameters, try between those values:


Binary file added images/carla-simulator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/carla-test-window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/carla-test.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dependencies-install.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/project-setup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rpclib-build.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/rpclib-clone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion project/pid_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(sources main.cpp behavior_planner_FSM.cpp motion_planner.cpp cubic_spiral.cp

set(CARLALIB_DIR ${CMAKE_SOURCE_DIR}/libcarla-install/lib)
set(carla_libs ${CARLALIB_DIR}/libboost_filesystem.a ${CARLALIB_DIR}/libboost_numpy36.a ${CARLALIB_DIR}/libboost_program_options.a ${CARLALIB_DIR}/libboost_python36.a ${CARLALIB_DIR}/libboost_system.a ${CARLALIB_DIR}/libcarla_client.a ${CARLALIB_DIR}/librpc.a ${CARLALIB_DIR}/libDebugUtils.a ${CARLALIB_DIR}/libDetour.a ${CARLALIB_DIR}/libDetourCrowd.a ${CARLALIB_DIR}/libDetourTileCache.a ${CARLALIB_DIR}/libRecast.a)
set(gtest_lib /usr/src/gtest/libgtest.a)
set(gtest_lib /usr/src/gtest/lib/libgtest.a)

include_directories(/usr/local/include)
link_directories(/usr/local/lib)
Expand Down
49 changes: 0 additions & 49 deletions project/pid_controller/cmake_install.cmake

This file was deleted.