I am building a self balancing two wheeled robot. I have been planning to implement a simple algorithm for the balancing part - then spend days tweaking the algorithm, but now i have the idea that I could use a neural network instead.
As input I want to give it the current velocity of the wheels, gyro and accelerometer data in the dimensions relevant for balancing and perhaps input from the remote controller.
As output I want a direction and thrust for each motor.
Error situations include falling over and not moving according to the remote control.
The trouble I am having is how to train it? Ideally it'll learn over time, but I don't know how the network will learn - say if it does something, then falls over 2 seconds later.
So there is no way I can tell the network that a certain output was wrong instantly. An idea I have is to say that I "roll back" the entire network state a few seconds every time the robot falls. What is the proper way to do this?
I also would like to have the network try to conserve energy; using power is negative, but neccesary.
I hope to be able to use libfann on a 1 ghz BeagleBone Black computer.
Extra info: I will not allow the robot to fall over, so a manual algorithm will take over control if certain threshold values are reached - and take the robot to a neutral position and give control back to the network.