Code Monkey home page Code Monkey logo

udacity_carnd_term3_path_planning's Introduction

udacity_carnd_term3_path_planning

CarND-Path-Planning-Project

Self-Driving Car Engineer Nanodegree Program

Sample video is here: report_video

Files are include in the submission:
    src/main.cpp
    src/cost.cpp
    src/cost.h
    src/vehcicle.cpp
    src/vehicle.h
    src/help.h

Implementation details:

Path planning:
    Use the state machine to track states between "KL", "PLCL", "PLCR", "LCR", "LCL"
    Psudo code is as follows: (this is in main.cpp)
    create list of vehicle on lanes of same side of road
    check to see if there is any car in front and closer within 25 miles for 1 second time
    if yes, generate projectory.
    for each projector, calculate the cost: inefficiency, collision, goal to distance
    choose lowest trajectory. prepare change lane.
    state change to "PLCL", or "PLCR" dependes on the trajectory.
    in Prepare change lane state, update the "goal lane" and then change state to "LCL" or "LCR"
    In "LCL" or "LCR", calculate the new path and determine if lane change to target lane.

Prediction of vehicles:

    for every vehicle on the same side of road, calculate the next positions apart every 0.02 second.
    that says, there are 50 vehicles for one car predicted postistion. these vehicles are use to calculate if there is collison when possible lane change.

Trajectory Algorithm:

    The alrogithm to calculate the next 50 points is using the spline alrogithm, the ego vehicle state determine to use the current lane or target lane to change.

Cost function:(in cost.cpp)

    * inefficiency cost * : calculate the lane change efficiency as follows:
    cost = (2.0vehicle.target_speed - proposed_speed_intended - proposed_speed_final)/vehicle.target_speed;
    * goal_distance_cost * : calculate the cost to goal distance as follows:
    1 - 2
exp(-(abs(2.0*vehicle.goal_lane - data["intended_lane"] - data["final_lane"]) / distance));
    * collision_cost : calcualte if any collision happens on current lane or predicted lane.
    for collision on current lane, add cost "COLLISION"
    for collison on predicted target lane, add 2
"COLLISION"
    in this case, if change lane cause collison, vehicle will keep on current lane.
    collision is measured if changed lane for ego car, the distance between ego and other car is less than 30m. this 30m distance guardband is also experimental number and can be better determined by current speed and other car speed as well.


# Speed adjustment:
    if car is in "KL" and no way to change lane such as the cost of stay in current lane is minimum. then slow down the ego speed to front car speed plus 14m/s. this additional 14m/s is to avoid car to slow down too much and miss the chance to do lane change. of course, this number is not perfect, will need better methmatical calculation between current car speed and front car speed. this is left to future.if car in "KL" and speed is lower than 49.5m/s then add 0.224 every sim tick.

Note that Vehicle.cpp from class quiz is not naturally fit into this project. in the quiz, the car change lane directly and predicted position in unit of second. it needs a lots of additional change to fit into this project. such as, lane determination, lane numbering from 0, 1, 2, prepare the lane change vehicles, next state logic change.

Notice some case might have collision. the best parameter to adjust the two collision distance guardband, 25m used in main.cpp and 30m used in collision_cost.(future work to have better calculation).

udacity_carnd_term3_path_planning's People

Contributors

aimllifetime 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.