Giter Site home page Giter Site logo

carnd-capstone's Introduction

CarND-Capstone

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.

Team Members

Project Components

  • Diagram of nodes and messages

Visualization

Click on the following picture to see the end result of the project:

  • Highway:

    Highway

Traffic Light Detection

  • We adopted the inception v2 model from the tensorflow zoo, the architecture of the model can be found over here: Inception v2 architecture

Traffic Light Classification

Simulator model Test site model
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

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 or UNKNOWN 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 than 16 m, safe distance for the YELLOW (Lines 151 & 152), there is not enough time to pass the traffic line before it turns to RED. 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 (function decelerate_waypoints() from Line 198 to 217) will be generated.

Control Subsystem

This subsystem publishes control commands for the vehicle’s steering, throttle, and brakes based on a list of waypoints to follow.

Waypoint Follower Node

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

Drive By Wire (DBW) Node

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.

Throttle Controller

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.

Steering Controller

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.

Braking Controller

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.

Native 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

  • Dataspeed DBW

  • Download the Udacity Simulator.

Docker Installation

Install Docker

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

Port Forwarding

To set up port forwarding, please refer to the instructions from term 2

Usage

  1. Clone the project repository
git clone https://github.com/udacity/CarND-Capstone.git
  1. Install python dependencies
cd CarND-Capstone
pip install -r requirements.txt
  1. 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 {} \;
  1. Make and run styx
cd ros
catkin_make
source devel/setup.sh
roslaunch launch/styx.launch
  1. Run the simulator

Real world testing

  1. Download training bag that was recorded on the Udacity self-driving car.
  2. Unzip the file
unzip traffic_light_bag_file.zip
  1. Play the bag file
rosbag play -l traffic_light_bag_file/traffic_light_training.bag
  1. Launch your project in site mode
cd CarND-Capstone/ros
roslaunch launch/site.launch
  1. Confirm that traffic light detection works on real life images

carnd-capstone's People

Contributors

mhbahrami avatar charlie-xiaoqi avatar nikolanoxon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.