Coder Social home page Coder Social logo

codespjw / carnd-path-planning-project-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dolaameng/carnd-path-planning-project

0.0 1.0 0.0 2.49 MB

Create a path planner that is able to navigate a car safely around a virtual highway

CMake 1.84% Shell 0.17% C++ 83.15% C 2.03% Cuda 1.14% Fortran 11.48% Python 0.08% JavaScript 0.07% CSS 0.05%

carnd-path-planning-project-1's Introduction

CarND-Path-Planning-Project

Self-Driving Car Engineer Nanodegree Program

Simulator

You can download the Term3 Simulator which contains the Path Planning Project from the releases tab.

Project Description & Requirements

Please refer to the project.md for details.

Implementation Overview

  • The implementation is within the single file for the minimum change from project template and organization. I found it acceptable because the code is still relatively short.

  • The main components and their relations are implemented as the following several classes

    • SelfDrivingCar: the state of SDC, including speed, position and etc.
    • PeerCar: the state of other cars on the same side of road (peer cars).
    • Map: it encapusulates the waypoint information into smooth trajectories, which are mappings from coordinates from car's view (a.k.a Frenet coordinates) to map view (x, y). The trajectory mapping is implemented by using the third-party spline library.
    • Path: an encapsulation of a set of steps in (x, y) map coordinates. This is the main protocol that the planner uses to communicate with the controller.
    • PathPlanner: the main class for path planning.
  • The main methods implemented in PathPlanner class are,

    • plan(): it is the main access point of the planner. It uses the self-driving-car and other cars information, combined with previous planned path (for smoothness), to plan for the next path. In general it estimates how the car should behave at the next step, by considering a strategy for different implemented behaviors. Currently the strategy is implemented as a set of rules. It might be implemented by other search algorithms e.g. a-star for more complicated cases.
    • keep_lane(): it implements the car's staying in the current lane behavior
    • change_lane(): the other behavior of the car currently implemented.
    • accelerate(): it controls car's speed following the acceleration and jerk requirements.

Project Rubics Walk-through

1. Build and Compilation

The project compiles and builds as follows,

  1. Make a build directory: mkdir build && cd build
  2. Compile: cmake .. && make
  3. Run it: ./path_planning.

2. The car is able to drive > 4.32 miles without incident.

This breaks down to the following items in details.

2.1 The car drives according to the speed limit, which is 50+/-10 MPH

In the implementation, the car is setting its target speed dynamically according to its environment, e.g.,

2.2 Max acceleration and jerk are not exceeded

This is implemented in the accelerate method of planner.

In general it considers the difference between current and target and calculates the acceleration by considering the constraints.

2.3 Car does not have collisions

Collisions are avoided by,

2.4 The car stays in its lane, except for the time between changing lanes

This is done by building a smooth trajectory mapping using the waypoints. I am currently implementing this as a global trajectory for the whole map. But in practice it might make more sense to build local trajectory around the car for more complicated cases.

2.5 The car is able to change lanes

The lane-chaning is implememted in two parts,

  • In the plan() method, a set of rules is implemented to decide whether a lane-changing is feasible when necessary.
  • The actual path generating is done in the change_lane() method, which is one of the car's preset behaviors.

3. There is reflection on how to generate paths

  • As discussed above, the actual path generating is delegated to the different "behavior" methods of the planner, including keep_lane and change_lane.
  • For keep_lane, two scenarios are considered,
    • when the lane is clear, the car will set its target speed as maximum and come up with a smooth trajectory both spatially and temporally.
    • when there is a car ahead, the car will set its safe distance from the car ahead and set its target speed accordingly. If the speed on this lane is too slow, the car will try to plan to change to another lane by evaluating their feasibility and advantage over current lane.
  • For change_lane,
    • the car will first evaluate whether it is safe to change to the target lane. If not, it wills stay on the same lane.
    • otherwise, the car will plan a smooth local trajectory by combining half from the source lane and the other half from the target lane.
    • at the meantime, since changing lane may take longer than one plan cycle to finish, the planner will monitor the lane changing state to avoid interruption.

4. Things that can be improved

  • Since the car's Frenet coordinates will be reset at the end of loop, I had some difficulties with modelling the end part of the loop. I fixed it by looping the map again. This solves the issue for the current simulation, but a better solution might be just using a local trajectory model along with the travelling.
  • The current lane_changing is implemented by planning a longer path (6 times longer in fact). And during the lane changing there won't be any further planning until it is finished. Safety is considered by employing strict rules on whether it is safe to change beforehand. However, this does make the lane-changing plan more conservative in my implementation. A better way might be continuing planning even during the lane-changing, e.g., possibility of going back to the previous lane in case of emergency.

Result

MPC Simulation

carnd-path-planning-project-1's People

Contributors

awbrown90 avatar dolaameng 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.