Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a neural network in motion control

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.

like image 852
frodeborli Avatar asked Nov 01 '22 23:11

frodeborli


2 Answers

to let it learn you need to log all of the inputs and outputs and then feed the data into the ANN. I have done this in the process control field for water treatment. The software can be expensive and I don't know of open source alternatives, but the way you 'train' it is by giving it historical data. For instance, when you did x on an output, y came back on an input. You can then do a number of experiments while logging the data and feed that data into the ANN.

like image 97
user3666086 Avatar answered Nov 08 '22 14:11

user3666086


You could start with a simulator to avoid having to pickup the robot or resort to using a backup controller. You can find one here built for the T-Bot which is a self balancing robot produced by KLiK Robotics. Look for T-BotSimulator_KB_HD.py file in the python folder. The simulator is currently setup with a cascading PID loop but the framework is very simple and clear and you could easily substitute the existing controller for an ANN. Dependencies are Numpy and Pygame. You will also need TBotTools which is also in the Python folder. Good luck.

like image 22
Gareth Nisbet Avatar answered Nov 08 '22 14:11

Gareth Nisbet