Giter Club home page Giter Club logo

selfdrivingrccar's Introduction

Self Driving RC Car





A scaled down version of self-driving system using Neural Networks and OpenCV. The system comprises of -

  • Raspberry Pi with a camera and an ultrasonic sensor as inputs,
  • Server that handles:
    • Steering using NN predictions
    • Stop sign and traffic light detection using Haar feature based Cascade Classifiers
    • Distance measurement through monocular vision
    • Front collision avoidance using ultrasonic sensor
  • RC Car, and,
  • an Arduino board for RC car control

Dependencies

  • Server
    • OpenCV ver3.2+
    • Pygame
    • NumPy
    • PiSerial
  • RaspberryPi
    • PiCamera
  • Arduino
  • RC Car

Project structure

  • arduino/rc_driver/rc_driver.ino: An arduino sketch that acts as a middleware between the RC controller and the server. It allows the user to send commands to drive the car via USB serial interface
  • rpi/
    • stream_sensor_data.py: transmits the distance measuerment taken by the ultrasonic sensor over a TCP/IP socket to the server
    • stream_video.py: streams the captures JPEG video frames over a TCP/IP socket to the server
    • utils.py: contains Utility function
  • server/
    • cascade_classifiers/
      • contains the trained Haar-feature based Cascade Classifier xml files
    • collected_images/
      • Images captured during the data set collection phase
    • data_set/
      • Data set for training and testing the Neural Network. Stored in .npz format
    • mlp_xml/
      • Trained MLP_ANN paramters in an XML file
    • auto_driver.py: a multi-threaded server program that captures the video frames and distance measurements streamed from the RPi, steers the car using the predictions from the NN, and provides stop sign and traffic light detection and front collision avoidance capabilities.
    • collect_data.py: Receives the streamed video frames and labels them based on the user input for NN training
    • mlp_training.py: Neural network training using OpenCV
  • test/
    • capture_sensor_data_server_test.py: script to test streaming of distance data from RPi to server
    • capture_video_server_test.py: script to test streaming of video frames from RPi to server
    • car_control_test.py: tests RC car control with keyboard
  • utils/
    • utils.py: contains utility functions

Usage

  • Flash Arduino: Flash the Arduino with the rc_driver.ino sketch. For testing purposes, run car_control_test.py to drive the RC car with the keyboard

  • Collect data set (for NN training and testing purposes): First run collect_data.py on the server and then run stream_video.py on the RPi. Use the arrow keys on the keybaord to drive the car around a track. The frames are saved only when there is a key press action. When finished driving, press “q” to exit. The data will saved in a npz file under data_set folder.

  • Neural network training: Next, run mlp_training.py. The NN training duration can vary depending upon the model hyperparameters chosen. Once the training is complete, the network accuracy on the training and test set will be displayed. Following this, the network weights/parameters will be saved in a xml file under mlp_xml.

  • Pi Camera calibration: Take multiple chess board images using the RPi camera at various angles and put them into the chess_board folder. Then, run picam_calibration.py. It will return the camera matrix which should be entered into auto_driver.py. This matrix will be used for distance measurement by the car while its self driving.

  • Self-driving in action: First run auto_driver.py to start the server and then run “stream_video.py” and “stream_sensor_data.py” on raspberry pi.

Thanks alot to @hamuchiwa for the inspiration.

selfdrivingrccar's People

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.