• Stars
    star
    235
  • Rank 171,079 (Top 4 %)
  • Language
    Python
  • License
    Other
  • Created almost 7 years ago
  • Updated over 6 years ago

Reviews

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

Repository Details

A simple example of using Microsoft AirSim to train a TensorFlow neural net on collision avoidance

This repository contains Python scripts showing how you can use Microsoft AirSim to collect image data from a moving vehicle, then use that data to train and test a deep-learning neural net in TensorFlow.

Prerequisites

  • Recommended hardware for running UnrealEngine4, required for AirSim. Although it is possible build AirSim on OS X and Linux, we found it easiest to use the pre-compiled Windows binaries in the Neighborhood example.

  • Python3 for 64-bit Windows

  • TensorFlow. To run TensorFlow on your GPU as we and most people do, you'll need to follow the directions for installing CUDA and CuDNN. We recommend setting aside at least an hour to make sure you do this right.

Instructions

  1. Clone this repository.
  2. Download and unzip the Neighborhood example, open it, and click run.bat to launch AirSim.
  3. When prompted, go with the default car simulation. If you press the 3 key on your keyboard, you will see the little image on which the neural net will be trained.
  4. From the repository, run the image_collection.py script. It will start the car moving and stop when the car collides with the fence, creating a carpix folder containing the images on which you will train the network in the next step.
  5. From the repository, run the collision_training.py script. Running on an HP Z440 workstation with NVIDIA GeForce GTX 1080 Ti GPU, we were able to complete the 500 training iterations in a few seconds.
  6. From the repository, run the collision_testing.py script. This should drive the car forward as before, but but the car should stop right before it hits the fence, based on the collision predicted by the neural net.

How it works

The image_collection script maintains a queue of the ten most recent images and saves them to numbered files in the carpix folder. The collision_training script converts these color images to grayscale, then builds a training set in which all images but the final one are labeled as safe (no collision; code [1 0]), and the final one is labeled as a collision (code [0 1]).
Finally, this training script uses Python's built-in pickle library to save the trained network parameters (weights and biases). The collision_testing script uses pickle to restore these parameters, then reconstructs the TensorFlow neural net from them. (We found this approach easier than using TensorFlow's save-and-restore API.) Finally, the collision_testing script moves the vehicle forward, converting the live image into grayscale and running it through the network to make a collision/no-collision prediction. When the value of the β€œcollision bit” exceeds 0.5, the script stops the vehicle by applying the brakes.

Future work

Our single-layer logistic regression network provides a simple proof-of-concept example; however, for a more realistic data set involving collisions with different types of objects, a convolutional network would make more sense. AirSim also provides access to depth images (just press the 1 key during the simulation) which, like the Lidar on today's self-driving cars, would provide a valuable additional source of information for avoiding collisions.

Credits

This code represents the combined work of two teams in Prof. Simon D. Levy's fall 2017 AI course (CSCI 315) at Washington and Lee University (listed alphabetically):

  • Jack Baird
  • Alex Cantrell
  • Keith Denning
  • Rajwol Joshi
  • Will McMurtry
  • Jacob Rosen

Acknowledgement

We thank David Pfaff of the W&L IQ Center for providing the hardware on which we developed this project.

More Repositories

1

TinyEKF

Lightweight C/C++ Extended Kalman Filter with Python for prototyping
Python
1,008
star
2

BreezySLAM

Simple, efficient, open-source package for Simultaneous Localization and Mapping
C
761
star
3

Hackflight

Minimalist flight-control toolkit for makers
C++
285
star
4

SensorFusion

A simple Matlab example of sensor fusion using a Kalman filter
MATLAB
154
star
5

MulticopterSim

Multi-language multirotor flight simulator using UnrealEngine
C++
123
star
6

OpenCV-Python-Hacks

Optical flow and other tricks in OpenCV
Python
97
star
7

RPiAdHocWiFi

Simple ad-hoc wireless network support for Raspberry Pi
Shell
90
star
8

GooMPy

Google Maps in Python
Python
84
star
9

neat-gym

Neuro-evolution for OpenAI Gym environments
Python
56
star
10

ARDroneAutoPylot

Auto-Pilot the Parrot AR.Drone from Python (or Matlab or C)
C
43
star
11

RealtimePlotter

Python real-time scrolling multi-plot over time
Python
40
star
12

OpenCV_GStreamer

Simple C++ example of using OpenCV with GStreamer
C++
40
star
13

PyQuadSim

A open-source quadrotor simulator in Python for Linux [NO LONGER SUPPORTED]
Python
38
star
14

UE4_OpenCV

Simple example of adding machine vision to UnrealEngine4 with OpenCV
C++
36
star
15

PyRoboViz

Simple Python tool for 2D visualization of robot pose and map
Python
35
star
16

CppSockets

Simple cross-platform socket support for C++
C++
32
star
17

gym-copter

Gymnasium environment for reinforcement learning with multicopters
Python
30
star
18

USFS

Cross-platform libraries for the EM7180 Ultimate Sensor Fusion Solution
C++
30
star
19

VL53L5CX

Arduino library for ST Microelectronics VL53L5CX multizone Time-of-Flight ranging sensor
C
28
star
20

NeatoPylot

Auto-Pilot the Neato XV-11 from Python
Python
26
star
21

RoverPylot

Pilot the Brookstone Rover 2.0 and Rover Revolution from Python
Python
23
star
22

BreezyCreate2

Ultra-simple Python API for iRobot Create 2
Python
21
star
23

BreezySTM32

Arduino-like API for for STM32-based flight controllers [NO LONGER SUPPORTED]
C
18
star
24

PySticks

Python API for flying with a game controller
Python
17
star
25

PyPX4Flow

A simple Python package for reading from the PX4Flow optical-flow sensor
Python
17
star
26

m021v4l2

Capture images from Leopard Imaging LI-USB30-M021 camera on Linux
C
16
star
27

UBX_Parser

C++ parser for binary UBX GPS messages with Arduino example
C++
14
star
28

AndroidBluetoothClient

Simple Bluetooth socket client for Android
Java
14
star
29

ISCPP

Introduction to Scientific Computing and Programming in Python
Python
13
star
30

BreezyArduCAM

A simple Arduino API for the ArduCAM Mini
C
11
star
31

xvlidar

A simple Python class for reading from GetSurreal's XV Lidar Controller
Python
11
star
32

PS2X_lib

Arduino Playstation2 library with compiler warnings fixed
C++
10
star
33

BreezyLidar

BreezyLidar - Simple, efficient, Lidar access in Python and C++
C
10
star
34

MSPPG

Multiwii Serial Protocol Parser Generator
10
star
35

RoboFirmwareToolkit

Simple C++ Robot Firmware Toolkit for makers
C++
10
star
36

DshotSTM32

DSHOT protocol library for STM32 microcontrollers
C++
9
star
37

CrossPlatformDataBus

Cross-platform C++ support for I2C and SPI devices
C++
9
star
38

ArduRust32

Calling Rust code from an Arduino sketch on STM32 microcontrollers
Python
8
star
39

pidcontroller

Simple example of an altitude-hold PID controller in Python
Python
7
star
40

kbhit

A Python class implementing KBHIT, the standard keyboard-interrupt poller
Python
7
star
41

DSMRX

Cross-platform interrupt-based C++ library for Spektrum DSM receivers
C++
7
star
42

LambdaFlight

Haskell-based flight controller with support for SITL simulation
C
6
star
43

PMW3901

Arduino library for PMW3901 optical flow sensor
C++
6
star
44

CA

Cellular automata in Matlab
MATLAB
6
star
45

PyMaxBotix

A cross-platform Python package for reading from MaxBotix ulatrasonic distance sensors
Python
6
star
46

TinyFlight

Minimalist flight-control firmware with simulator
C++
6
star
47

ArduEye

Arduino libraries and support for Centeye vision chips
C++
5
star
48

RXInterrupt

Interrupt-driven PWM RC receiver handling for Arduino
C++
5
star
49

TwoStepFilter

English translation of Jung Keun Lee's Two-step Kalman/Complementary Filter for Estimation of Vertical Position
TeX
5
star
50

PAA3905

Arduino library for the Pesky Products PAA3905 optical flow camera
C++
5
star
51

OpticalFlow

Simple header-only C++ library for optical flow
C++
5
star
52

AirSimCar

Quickstart for driving the car in Microsoft AirSim
Python
4
star
53

MPU6x00

Arduino library for InvenSense MPU6000/6500 IMU using SPI bus
C++
4
star
54

BMI270-SPI

Simple Arduino library for the Bosch BMI270 inertial measurement unit over the SPI bus
C
3
star
55

ES-Gym

Evolutionary Strategies in PyTorch for OpenAI Gym environments
Python
3
star
56

NMEA

NMEA parsing in C++ with Arduino example
C++
3
star
57

BreezyRobotArm

A simple Python library for controlling robot arms
Python
3
star
58

PythonSockets

Simple socket examples in Python
Python
3
star
59

Besties

Simple serial communication between Arduino Mega and its new BFF, ODROID XU4 with Shifter Shield
Arduino
2
star
60

HackflightGCS

Windows executable for Hackflight Ground Control Station
2
star
61

gym-mygame

A template for making your own OpenAI Gym game environment
Python
2
star
62

FreeSixIMU2

An updated version of the FreeSixIMU library that works with the Arduino Due
C++
2
star
63

LateralInhibition

Matlab software for Levy & Gayler (2009) "Lateral Inhibition" in a Fully Distributed Connectionist Architecture
MATLAB
2
star
64

SUEAP

Suite of Evolutionary Algorithms in Parallel for Matlab and Python
MATLAB
2
star
65

NengoCPP

Example of how to call the Nengo neural simulator from C++
C++
2
star
66

ArduinoTools

Useful sketches for Arduino-compatible microcontrollers
Makefile
2
star
67

MS5637

Cross-platform C++ library for the MS5637 barometer
C++
2
star
68

vsarobot

VSA Behavior-Based Robot Demo with V-REP
C++
2
star
69

arduino-STM32L4

Arduino support for STM32L4 Flight Controllers
C
2
star
70

TinyNEF

Simple implementation of the Neural Engineering Framework
Python
2
star
71

MB1242

Cross-platform C++ library for for MaxBotix MB1242 sonar
C++
2
star
72

LSM6DSM

Cross-platform C++ library for the STMicroelectronics LSM6DSM Inertial Measurement Unit
C++
1
star
73

simondlevy.github.io

JavaScript
1
star
74

bolt-esc

ESC board for Crazyflie Bolt 1.1
1
star
75

simdvs

Simple Python-based Dynamic Vision Sensor simulator
Python
1
star
76

MultirotorDynamics

Multirotor dynamics in Matlab, Python, and C++
MATLAB
1
star
77

BotBoarduino_CH3R_PS2

Cleaned-up version of Lynxmotion BoardBoarduino code for CH3-R hexapod robot
Arduino
1
star
78

ArduinoPrintf

A C-like printf() function for the Arduino
C++
1
star
79

PyGCSUDP

Python API and joystick example for OpenPilot Ground Control Station UDP connection: fly OP with a joystick!
Python
1
star
80

STM32F4_MPU6000

Reading from the MPU6000 IMU using the STM32F405 MCU
C++
1
star
81

WaveshareOLED

Arduino library for Waveshare 1.5" OLED RGB display
C++
1
star
82

huffcode

Simple Huffman code implementation in Python
Python
1
star
83

MAVLinkAutoPylot

Python support for autopilot on MAVLink-based flight controllers
Python
1
star
84

Hackflight-VREP

VREP-based flight simulator using the Hackflight flight control firmware
C++
1
star
85

eDVS

Arduino / Python support for the iniVation eDVS sensor
Python
1
star
86

PECON

Parallel Evaluation CONntroller: Run Matlab in Parallel on your Multicore PC or Unix Cluster
MATLAB
1
star
87

CPPMRX

Bare-bones Arduino library for reading from CPPM receivers
C++
1
star
88

HackflightCPP

C++ flight-control toolkit for makers
Java
1
star
89

WinJSTest

A little Windows console program for testing joysticks , game controllers, and similar devices
C++
1
star
90

CMA-Gym

CMA-ES for OpenAI gym environments
Python
1
star
91

Centeye

Moved to https://github.com/simondlevy/ArduEye
1
star