This project is submitted for

Description

Using Ogma Corp's EOgmaNeo machine learning library, we created a tiny vision-based self-driving car, powered by a Raspberry Pi Zero and weighing 102g. It learns online from the user in real-time, and then drives on its own with the flick of a switch!

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Contact Ogma via licenses@ogmacorp.com to discuss commercial use and licensing options.

Details

Overview

This project describes how to build a micro Self Driving Car (uSDC), a smaller version of Ogma Corp's 1/10th scale R/C based self driving car. Both versions use a controller to drive the SDCs and a front-facing camera, to provide input into an online Machine Learning predictive algorithm that learns how to autonomously drive around a track. Details of both version can be seen on GitHub here.

The Machine Learning algorithm uses an online learning technique known as Sparse Predictive Hierarchies (SPH). The predictive hierarchies take as input streaming data, in this case a camera image and steering information, and predicts (infers) what the next steering information it expects to be shown. The predicted steering information can also be fed back into the predictive hierarchy to enable autonomous driving behaviour.

A Unity based simulation OgmaDrive was used to prototype the SDC, using C# scripts and Ogma Corp's EOgmaNeo library (that contains the SPH implementation).

Control of the uSDC

There are two Python3 scripts included in the GitHub repository to test the uSDC:

motorTest.py - A script to test the Explorer pHAT, Steam controller, and drive the uSDC around.main.py - The main script containing using the EOgmaNeo library. Allowing for learning, inference, and self-driving on the RPi ZeroW.

Steam controller daemon

Both of the included python scripts require the Steam controller daemon to be running. After the daemon has been started, it emulates the Steam controller as a Xbox controller. PyGame can then connect to and obtain joystick and button information. The motorTest.py and main.py scripts can then make use of the controller to drive the uSDC around.

Starting the daemon requires the following bash command:

sudo python3 ~/steamcontroller/scripts/sc-xbox.py start

and the following command to stop the daemon:

sudo python3 ~/steamcontroller/scripts/sc-xbox.py stop

The motorTest python script

To test the Steam controller and Explorer pHAT motor driver, the following commands and script can be used:

If you train and save out the current state of the hierarchy, that saved state can be reloaded by starting the script with a `load` parameter. For example:

sudo python3 main.py load

Note: Saving the hierarchy to the a file on the SD card can take a minute or so to perform. Console text will announce when saving starts, and also when saving has completed.

If the uSDC doesn't travel in a straight line using one of the trigger buttons, a `trimming` global variable can be modified to compensate for any drift. For example this could be set to `trimming = 0.2`

An `RGB` image is captured from the camera module at each time step. This is converted into a grey scale...