For Halloween I Gave My Robot a Brain, or Fun With a Backpropagation Neural Network

nn-3pi.zip (5443Bytes)

I’ve long been fascinated by the concept of artificial intelligence and its application to robotics. Being somewhat math challenged but an accomplished copy/paste programmer, I decided the best way to learn was to find someone else who had implemented what I was interested in and try to adapt their program to my robot, a Pololu 3pi, to solve a line following problem.

In my quest, I came across the following sites and books - thanks to the various authors:



The neural net described in the Java Lego article needs to be “trained” with input and expected output data sets (see page 2 of the article above for an explanation of how the “backpropagation” algorithm works). In operation in my robot the “brain” takes an array of three binary inputs and responds with an array of two binary outputs according to the table below (readLine() is a Pololu library function for reading the 3pi’s reflectance sensors):

Rule

Input 1

Input 2

Input 3

Output 1

Output 2

readLine() < 1000 - turn left

0

0

1

0

1

readLine() < 3000 - over line

0

0

0

1

1

otherwise turn right

1

0

0

1

0


The source code for the neural network and my Arduino test sketch for the 3pi are attached. Also attached is a short video of my testing the robot with a simple square line pattern. Happy Halloween!

https://www.youtube.com/watch?v=RZ50zZeYzsY

rules vs network

hey, that’s interesting work. however, i wonder why you’re using a net to train the system instead of the three simple rules?

i think it would be interesting to build a system that is actually learning from real sensor input and real output, i.e. do something, obeserve (via sensors), check whether what you’ve done is “useful” (via other(?) sensors)  and then learn. 

for example, wouldn’t it be cool if your bot could learn to follow the line by it’s own? like, “it’s good to be on a black line” and to learn “what do i have to do, to stay on the black line”?