Hello to All,
I have tested and implemented successfully a neural network library for Arduino on the ArduPilot Mega board (APM2560), this is the neuroduino from Ted Hayes.
This library work fast and the implementation is relatively simple:
Neuroduino params: (network array, number of layers, Eta, Theta, debug)
In attached a sample NN program above and the lib...
So, you may begins to add some AI routines on the ArduCopter...
Good neural network tests and enjoy,
Thanx, the calculations I believe the code does this:
Could you tell me what are the inputs i.e. angles or actuator numbers?
I understand the code, I do not understand what should be the inputs and outputs for Arducopter.
Only two layers are allowed, please see if I am correct:
Could you kindly show me how to calculate these input/outputs in APM board? And if they are the wrong params, could us suggest their replacements:
time now = tn
Speed of Motor = Sm ( eg Sm1 Speed of Motor 1)
Delta Roll = Dr = Roll( tn ) - Roll ( desired )
Delta Pitch = Dp= Pitch ( tn ) - Pitch ( desired )
Delta Yaw = Dy= Yaw ( tn ) - Yaw ( desired )
Error Roll = Er = Roll ( desired ) - Roll (tn-1)
Error Pitch = Ep = Pitch ( desired ) - Pitch (tn-1)
Error Yaw = Ey = Yaw ( desired ) - Yaw (tn-1)
Inputs : Dr ,Dp,Dy,Er,Ep,Ey,Sm1,Sm2,Sm3,Sm4
Outputs : Sm1 (tn+1) , Sm2 (tn+1) , Sm3 (tn+1) , Sm4 (tn+1)
Here an interesting video which shows a simulation of quadcopter controlled by a spiking neural network running on the SpiNNaker hardware.
Black = Control mechanism turned off.
Green = Control mechanism turned on.
The four 'blob' indicators show the speed of the four rotors. Red = faster, green = slower.
SpiNNaker is a scalable parallel processing system designed to simulate spiking neural networks in real-time, developed by the APT group at the University of Manchester.
Here is the source code for FANN
src directory has the necessary C files.
The difference between this code and what you posted from Ted Hayes is that Ted's only two layer NN, and the FANN is multi-layer.
It might be the case that 2-layer NN would be sufficient.
However we need to store the train-data into files and need some GUI for manipulating the training. Both FANN and FANNTool have a lot of useful code.
fann_data.h contains the struct for the single-layer and the FANN network.
The weights are arranged in arrays of long and their beginning and end are stored into struct pointers for future access.
Basically the FANN network is link list of long arrays.
I do not foresee much memory access wasted cycles, but there is however an impact.
I suspect if we tightly coupled a beaglebone board to the APM board, the performance of the CPUs are so high that no specialized hardware for NN simulation would NOT be necessary.
APM board will be the outer-loop: It calculates where to go next and pass it to the inner-loop
BeagleBone will be the inner-loop: It does the NN network simulations, weight calc and real-time training