This repository is an implementation of a very basic autonomous car using Python, ROS and OpenCV. This car is capable of lane following and detecting STOP signs. The car passes the images obtained from an onboard camera through a neural network to make a decision of its next control signal. This control signal is sent to an Arduino which drives the wheels. The car also uses a Haar feature-based cascade classifier to detect whether or not the current input image contains a STOP sign.
The Arduino code is currently not included in this repository.
I did this project a very long time ago when I did not realize the importance of structuring code (or making proper videos of results for that matter). The code in the repository can be a little difficult to understand and use but should be fairly straightforward if you go through this README file. I don't have the hardware I used to build the car anymore so I do not want to update the code too much. Feel free to send pull requests if you want to change something.
This project is recommended for you if you want to learn how to use very basic neural networks to program a small car to drive autonomously in structured environments.
Prequisites - basics of Neural Networks, OpenCV, Python, ROS, and Raspberry Pi. A basic understanding of cascade classifiers is also required for the STOP sign detection.
If you're interested in builing a more advanced system, I recommend you to look into Duckietown.
You will need the following hardware to build your own autonomous car.
- Raspberry Pi (one of the newer versions is preferable)
- USB / Pi Camera
- Arduino controlled RC Car
You could do away with the Arduino by directly connecting the motor driver to the Raspberry Pi. If you do use an Arduino, you may find it easier to connect it to the Raspberry Pi using a USB cable rather than using the RX and TX pins.
.
├── cascade_xml # XML file for STOP sign detection using a Haar Cascade Classifier
├── computer # Scripts which would run on your laptop/desktop rather than the Raspberry Pi
├── mlp_xml # XML file which stores the neural network which is used for lane following
└── pi # Scripts which would run on the Raspberry Pi
-
Install ROS on your computer and the Raspberry Pi. You can also use an image for your Pi which comes preinstalled with ROS. Here's a video which shows how to do that on the Raspberry Pi 3.
-
Ensure that your computer and the Pi are on the same network. You can do this by connecting them both to your home WiFi.
-
Clone an instance of this repository on both your computer as well as the Pi using the following command:
git clone https://github.com/surirohit/Self-Driving-Car.git
You will also need to build a lane/arena to test the robot. You could build something like the setup below.
You can find the video of the robot I developed on YouTube