• Stars
    star
    234
  • Rank 171,630 (Top 4 %)
  • Language
    C++
  • Created about 13 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

nnrccar

NNRCCar - build a Neural Network Controlled self-driving car!

August 6th 2017: This project is very old and pretty much obsolete now. I hope it inspires you to learn about ML or build something fun, but I urge you not to replicate this build, but rather to head on over to the much more modern Donkey Car project once you've finished reading!

android/ - An android app which streams video frames to the Driver app running on a PC.
arduino/ - The arduino sketch allowing Driver to send commands to the car via Serial interface.
Driver/  - Java applet which acts as both a TCP server, receiving streamed image frames from a video streaming app on a phone and a user interface allowing a human driver to control the car with the cursor keys or mouse
train/   - Octave code to train the neural network.

ABOUT

Read the explanation and watch videos of the car in action at blog.davidsingleton.org/nnrccar.

BUILD / QUICKSTART

To build and install the android app (using your default Android SDK and device):

cd android/
ant install

Flash the Arduino sketch to your arduino by opening the serialrccar sketch in the Arduino IDE and clicking Upload. Note the USB serial port your Arduino board is connected to (available in Tools -> Serial Port) as you will need to know it later.

Driver depends on the RxTx Serial library and Apache Commons Math library - see the README in Driver/ for more details. Once the dependencies are provided:

Build the Driver app

cd Driver/
ant

Run the Driver app

ant Driver [serial port path]
  • [serial port path] is the path to the serial port connected to your Arduino board - it's the same as the one used by the Arduino IDE so the value noted earlier is what you need.

Run the Android app (with phone and computer on the same wifi network). You'll be prompted to enter the IP address of the computer running the Driver app, once connected, you should start to see incoming video frames from the phone. You will also be able to note the location of the training data being written in record mode on standard out e.g.:

     [java] Features writing to: /tmp/nnrccar4119787618703988036features
     [java] RxTxSerialWrapper init /dev/tty.usbmodemfa131

Driver starts in Manual mode - confirm that you can drive the car using the arrow keys or mouse (Note that 'F' toggles forward, up arrow produces a momentary forward pulse).

Once you've gotten used to driving the car, you're ready to record examples for the neural network to learn from. Press 'R' to enter record mode and drive the car in the same environment you'd like it to drive itself. You can return to manual mode by pressing 'M' and re-enter record at any time by pressing 'R' again. When done, press 'M' and wait for the queue of samples to be written to disk. You're now ready to train the network.

Training:

Pre-process the recorded data into octave matrices:

  • change into the train/ directory and copy the temporary features file above to nnrccar.features
  • run the parse.py script which reads the features and writes two files X.dat and y.dat. X.dat is an octave matrix containing the input frames and y.dat is a matrix containing the labels corresponding to how you drove the car.

Train:

Follow the instructions in train/README to get set up with a solution to Ex4, then Run octave and start the nnrccar script:

octave-3.4.0:4> cd train/
octave-3.4.0:5> nnrccar

Elapsed time is 233.526 seconds.
Training Neural Network... 

It will take ~4 mins for octave to load the training data, after which you'll see the status output from fmincfg showing the progress of training the network. By default, 100 iterations of training will occur.

Once trained, the script will write out the parameters for the two sets of connections in Theta1.dat and Theta2.dat.

Copy these files to the Driver/data directory - note that they need to be renamed theta1.dat and theta2.dat [different capitalization].

Drive!

Run Driver again, and press 'A' to enter auto mode. Hey presto - you have a self driving car!

More Repositories

1

piui

Add a UI to your standalone Raspberry Pi project using your Android phone
JavaScript
416
star
2

remarkable-keywriter

QML
183
star
3

rust-raytracer

๐Ÿ”ญ A simple ray tracer in Rust ๐Ÿฆ€
Rust
180
star
4

remarkable-wikipedia

QML
142
star
5

go-xml-parse

Streaming XML parser example in go
Go
126
star
6

rpi-timelapse

Timelapse Camera Controller for Raspberry Pi
Python
104
star
7

montesheet

JavaScript
13
star
8

piui-sdcards

sdcard images for piui
8
star
9

unhumanize

a simple python library to convert humanized time intervals (e.g. 'an hour ago') into timedeltas
7
star
10

northbelt

A belt that buzzes north
Arduino
6
star
11

SwiftUI-Recipes

๐Ÿฝ A SwiftUI demo app showing how to fetch data from the server to populate list views, navigate to detailed results and wire in a search field.
Swift
6
star
12

piui-timelapse

PiUi version of rpi-timelapse
Python
4
star
13

spreadsheet

JavaScript
4
star
14

shortest-sudoku

A collection of tiny Sudoku solvers
Java
4
star
15

android-vector-climacons

Android vector drawable resources for @adamwhitcroft 's Climacons
3
star
16

aoc

Python
3
star
17

recipes

recipes
Python
2
star
18

wear-exchangerates

Exchange Rates complication data provider for Android Wear 2.0
Java
2
star
19

laserUp

๐Ÿ” Create 3D relief map slices for Glowforge. ๐ŸŒŽGenerate input files at
Python
2
star
20

go-zim

Pure Go reader for the ZIM file format
Go
2
star
21

wixel

Wixel Apps
C
2
star
22

lasercut

A collection of laser cutter designs. Most made for my kids.
Python
1
star
23

wordgrid

1
star
24

multihttp

A multiplexing http notifier in golang
Go
1
star
25

webalert

Python
1
star
26

remarkable-ambient-launcher

A launcher for reMarkable
QMake
1
star
27

gcal-cruncher

Crunches .ics files exported from Google calendar to show you where your time has been spent
Ruby
1
star
28

dial.fyi.complications

dial.fyi complications
Java
1
star
29

hotdog

HTML
1
star
30

sundial

A sundial laser-cutter template generator
Python
1
star
31

dial.fyi

Java
1
star
32

simplescheduler

A simple task scheduler using redis for python
Python
1
star