This is the project repo for the final project of the Udacity Self-Driving Car Nanodegree: Programming a Real Self-Driving Car. For more information about the project, see the project introduction here.
- Mohammad Hossein Bahramimanesh
- Trajectory Planner, Controller, and Integrator
- [email protected]
- Xiaoqi Li
- Nikola Noxon
- Traffic Light Detection
- [email protected]
- Tamoghna Das
- Traffic Light Detection and Controller
- [email protected]
- Diagram of nodes and messages
Click on the following picture to see the end result of the project:
- We adopted the inception v2 model from the tensorflow zoo, the architecture of the model can be found over here: Inception v2 architecture
Simulator model | Test site model |
---|---|
- Four output classes:
GREEN
,YELLOW
,RED
,UNKNOWN
. - Test accuracy: lowest precision was red at 98%, lowest recall was green at 88%.
- See model and training code in the Nikola's repo in
traffic_light_classifier.ipynb
. - See inference code in
tl_classifier.py
.
Trajectory planner is implemented in waypoint_updater.py
. It specifies the speed of waypoints based on the current speed of the vehicle, distance between car and stop line (or traffic light), and the color of the traffic light (the traffic light status).
The code will publish waypoints generated by generate_lane()
. The most important parts of this function are as following:
-
should_accelerate()
function: It determines either the car should accelerate to the cruise speed or decelerate (and be prepared to stop).You can find it from Line 134 to Line 163.
The decision is made based on the stop line index, the current speed of car, and the traffic light status (
GREEN
,YELLOW
,RED
,UNKNOWN
).-
If it's
GREEN
orUNKNOWN
the car would accelerate to cruise speed (From Lines 138 to 143). -
If it's
YELLOW
and the distance between the car and stop line is less than16 m
, safe distance for theYELLOW
(Lines 151 & 152), there is not enough time to pass the traffic line before it turns toRED
. So, the car will decelerate to stop behind the stop line. Otherwise the car will keep going. -
If the traffic light is
RED
, the safe distance to stop a car is calculated using kinematic equations of motion which is a function of car's velocity (Line 166). Again, if car is within this distance the car should decelerate to stop behind the stop line safely.
-
-
Then based on output of the pervious function the waypoints to accelerate (function
accelerate_waypoints()
from Line 184 to 195) or decelerate (functiondecelerate_waypoints()
from Line 198 to 217) will be generated.
This subsystem publishes control commands for the vehicle’s steering, throttle, and brakes based on a list of waypoints to follow.
This node was given to us by Udacity. It parses the list of waypoints to follow and publishes proposed linear and angular velocities to the /twist_cmd topic
The DBW node is the final step in the self driving vehicle’s system. At this point we have a target linear and angular velocity and must adjust the vehicle’s controls accordingly. In this project we control 3 things: throttle, steering, brakes. As such, we have 3 distinct controllers to interface with the vehicle.
The throttle controller is a simple PID controller that compares the current velocity with the target velocity and adjusts the throttle accordingly. The throttle gains were tuned using trial and error for allowing reasonable acceleration without oscillation around the set-point.
This controller translates the proposed linear and angular velocities into a steering angle based on the vehicle’s steering ratio and wheelbase length. To ensure our vehicle drives smoothly, we cap the maximum linear and angular acceleration rates. The steering angle computed by the controller is also passed through a low pass filter to reduce possible jitter from noise in velocity data.
This is the simplest controller of the three - we simply proportionally brake based on the throttle and the brake deadband.
Please use one of the two installation options, either native or docker installation.
-
Be sure that your workstation is running Ubuntu 16.04 Xenial Xerus or Ubuntu 14.04 Trusty Tahir. Ubuntu downloads can be found here.
-
If using a Virtual Machine to install Ubuntu, use the following configuration as minimum:
- 2 CPU
- 2 GB system memory
- 25 GB of free hard drive space
The Udacity provided virtual machine has ROS and Dataspeed DBW already installed, so you can skip the next two steps if you are using this.
-
Follow these instructions to install ROS
- ROS Kinetic if you have Ubuntu 16.04.
- ROS Indigo if you have Ubuntu 14.04.
-
- Use this option to install the SDK on a workstation that already has ROS installed: One Line SDK Install (binary)
-
Download the Udacity Simulator.
Build the docker container
docker build . -t capstone
Run the docker file
docker run -p 4567:4567 -v $PWD:/capstone -v /tmp/log:/root/.ros/ --rm -it capstone
To set up port forwarding, please refer to the instructions from term 2
- Clone the project repository
git clone https://github.com/udacity/CarND-Capstone.git
- Install python dependencies
cd CarND-Capstone
pip install -r requirements.txt
- Make sure
*.py
files and*.sh
files are executable
find [/YOUR/DIRECTORY/TO]/CarND-Capstone -type f -iname "*.py" -exec chmod +x {} \;
find [/YOUR/DIRECTORY/TO]/CarND-Capstone -type f -iname "*.sh" -exec chmod +x {} \;
- Make and run styx
cd ros
catkin_make
source devel/setup.sh
roslaunch launch/styx.launch
- Run the simulator
- Download training bag that was recorded on the Udacity self-driving car.
- Unzip the file
unzip traffic_light_bag_file.zip
- Play the bag file
rosbag play -l traffic_light_bag_file/traffic_light_training.bag
- Launch your project in site mode
cd CarND-Capstone/ros
roslaunch launch/site.launch
- Confirm that traffic light detection works on real life images