Building An Autonomous Vehicle

Now that you have built a robot, experiment with the servo functions so that the robot moves relatively straight.   (Fred Martin, the creator of the handyboard wrote an article titled, “Real Robots Don’t Drive Straight”).   We now want to give the robot some behaviors that will allow it to "drive autonomously".

Creating a Learning Agent - Write a program that implements the back propagation algorithm discussed in class.  Modify the given neural net code to implement a neural network with 2 inputs, 2 hidden nodes, and 2 output nodes.  You will need this code to program your robots.  Hand in one program per robot team.  The source code for a two input, one output neural network can be found at http://www.cs.csi.cuny.edu/~imberman/ai/bpnet.txt and http://www.cs.csi.cuny.edu/~imberman/ai/mainneuralnet.txt.   The source code is downloadable and will run.

Important consideration

• the inputs for the functions learned in the given code are either 0's or 1's.  Your inputs will be photosensor readings
• The result of the neural network code is also 0 or 1 (round the decimals).  You will need to output the value for the servo functions that should range from about 1400 to 1600 (http://learn.parallax.com/node/207) Therefore you may have to multiply by a scalar amount to get your results at the correct order of magnitude.

These are actual training examples used by a former student for the project when we used the Handy Board.  The Arduino will require different values but the logic is similar.  The first two arguments to the train function are values from the photosensors.  The last two arguments will be values to run the motors.

// straight

bp.Train(112,107,.025,.025);

bp.Train(120,115,.025,.025);

// off to the right

bp.Train(107,36,.050,.020);

bp.Train(108,36,.050,.020);

// off to the left

bp.Train(54,111,.020,.050);

bp.Train(63,107,.020,.050);

The robot's photosensors are very sensitive to the amount of light available.  This student multiplied by a scalar of that was half that needed for trained neural network, before he input them to the motor function.  Why did he do this??  Because he needed to slow the robot down more and didn't feel like redoing his training examples!!!

You will also need to write a small program that will output values from the photosensors so that you can create the training examples.  Given the way you position the robot on the black tape road, and  the sensor readings from the robot, estimate the parameters needed  for the left and right motor inputs to control the rear wheels.  Therefore, each training example will consist of two inputs (the sensor readings), and two outputs (the values passed to the right wheel's motor function and the left wheel's motor function).  You may have to write some small programs and experiment with the robots in order to get a good set of training examples.

Use these training examples to train your neural network.

Use the modified neural network code you created for this project to program your robot with a neural network.    Take the trained neural network function, and modify it for use in the Arduino IDE.  Remember, the code as given produces decimal output.  The training code (modified code) of the program is executed in the desktop environment, with the Microsoft Visual Studio C++ compiler.   Once you have the weight values for the neural network equations, incorporate them into the Arduino IDE version neural network RUN program (only the Run portion of the modifed code) and try your robot on the road.    You may have to repeat several times before your robot reasonably follows the road.  One important thing to remember is to make your robot move SLOW enough so that it has time to take readings from the road and act upon these readings.

WHAT YOU NEED TO HAND IN

All Arduino code including:

1. Modified neural network code

2. Arduino program that reads values from photo sensors and displays these on LCD screen or serial monitor.  Instructions on using the LCD shield can be found here:

3. An Arduino version of the trained neural network function for the 2 input 2 output neural network

HAVE YOUR INSTRUCTOR INITIALIZE YOUR ROBOT CHECKOFF SHEET