Title: Artificial Life lecture 6
1Artificial Life lecture 6
Introduction to programming simple basic robots
in the Robot Lab. Rationale- everyone should
have some very basic hands-on experience of the
problems involved in building a robot that
interacts sensibly with its world. Difference
between reality and simulation. Then facilities
available for those who want to carry on in their
own time, or for course projects.
2Braitenberg Vehicles
Braitenberg (1984), Vehicles Experiments in
Synthetic Psychology, MIT Press. R. Pfeifer C.
Scheier (1999),"Understanding intelligence" MIT
Press Arkin (1998), Behavior-Based Robotics, MIT
Press.
3BV
Simplest vehicle has just one sensor and one motor
It can only change its speed according to the
stimulus The sign means positive excitation
4BV
Crossed positive connections mean that it will
turn towards the side with the greater
stimulus -- an aggressor Contra-lateral
excitation
5BV
If the connections are not crossed, then it turns
away from excitation coward Ipsilateral
excitation
6BV
Uncrossed inhibitory connections (note the sign)
give ipsilateral inhibition Turns towards the
light and slows down as it gets close
Note there will need to be some constant
positive signal to the motors as well, that gets
inhibited by the effects of the stimulus
7BV
Contralateral inhibition Slows down on seeing
light, but then turns away and speeds up
again. Again, some constant positive signal to
motors needed also.
8Simulation -- PopBugs
For a simulation that allows you to play with
Braitenberg-vehicle-like creatures, see Chris
Thorntons PopBugs. http//www.cogs.susx.ac.uk/us
ers/christ/popbugs/intro.html Or you could
build these for real and a lot more interesting
issues will crop up.
9Theory and Practice
These sets of conceptual wires could be
implemented in real wires and capacitors and
resistors and
or you can emulate all this with a computer
10Basics
sensors
Body nervous system
environment
motors
Many choices, but in this case body Lego and
Nervous system C program running on a
mini-computer, hooked up to various sensors and
motors
11Program is a cheat
The computer program here is a bit of a cheat
it is emulating a nervous system of components
passing real values around in real
time. Actually real values to/from
motors/sensors are translated into digital
signals, and real time is handled by going round
a program loop indefinitely ( caution needed)
12Sensors and Motors
You can incorporate the EM brick in a Lego
structure, plug in sensors and motors
appropriately, and write a program to load onto
it.
13EM the EASy Mind
Put together by Bill Bigge, based around the MRM
robot control board. Lego box with a 32bit
Motorola 68332 micro- processor, 512k RAM and
512k Flash ROM
14Programming the EM
You will be writing the program in a C file on
the PC, include-ing a header file OS.h which
knows all about the particular translations
needed for the EM. Then you will compile the
code on the PC, but in a special format suitable
for use on the EM, ready to download to it. Then
you send it down a wire from PC to EM
15Set up access to the library files
The compiler looks for all the necessary library
files in robosoft in your home directory on
tsunb. Actually this is a link to robosoft in Ian
Macinnes files (ianma_at_cogs, is writing the
libraries). So once only, you have to login to
tsunb and set up this link. In your home
directory do- ln s /home/ianma/robosoft
/windows/user (that is el-en, to set up a
symbolic link)
16Create a Programs directory on PC
Back on the PC- Open My Documents, from File
menu choose New gt Folder, and name it as Programs
17Cygwin
Open a Cygwin window. This is a Unix-like window
on the PC you are sitting at.
18Edit a file
You can use xemacs orNotepad or Wordpad or
cd MyDocuments/Programs Notepad test.c
19An example program .
Include header file and initialise
variables include ltOS.hgt int main() int
motor1, motor2 motor1 addMotorOnPort(
MOTOR_PORT_01 ) motor2 addMotorOnPort(
MOTOR_PORT_23 ) then the main loop
20 continued
for ( ) setMotorPower( motor1,
readAnaloguePort( 0 ) ) setMotorPower(
motor2, readAnaloguePort( 1 ) )
return 0 The for-loop goes round as fast as
poss for ever
21What does it do?
Every time round the loop, it reads sensor values
of whatever you have plugged into AnaloguePorts 0
and 1 (suitably scaled), and sets the equivalent
power levels (suitably scaled) to whatever you
have plugged into MOTOR_PORTs 01 and 23 All sorts
of stuff is done in the background, hidden from
you A/D conversion, scaling factors, how fast
round the loop?
22Compile the program on the PC
Having saved the program as a file with a .c
suffix, e.g. test.c, then in the Cygwin window
compile it with- compileCode -o output.s19 There
is a h flag that lists possible options, but the
o flag used here gives the output file the name
output.s19. This .s19 format is a special format
suitable for sending down the line to the EM
you can have a look at it if you like.
23The EM brick
24Send from PC to EM
Connect the lead from com port 2 to the RS 323
port on the robot. Then turn the robot on. Find
out where the RESET switch is physically on the
computer. Then in Cygwin sendCodeToRobot -p 2 -f
output.s19 Flag p 2 means send out via port 2.
Flag -f means send this file. Again, use option
-h to view all the possible options. You will
get a message to press the reset button within
ten seconds. Do so.
25 continued
The output of the program should be something
like Now press 'RESET' button on the robot
within 1 second... Checking reset was
performed..... Clearing memory...... Sending your
program...... Sent 55928 bytes out of 55928
(100) Checking program got sent OK.....
26 completed
This program will take about a minute to send
your compiled program across, and you will know
it will have finished because the message
'Program sent correctly' will be printed along
with the command window prompt. Then press RESET
on your robot to start your program!
27Motor Ports
There are 16 output ports for motors, typically
used in pairs.
Signals sent with pulse width modulation
So if you want a motor to go forwards and
backwards, easiest thing is to have one signal
(one port) for each direction.
28H-Bridge
The motors need a higher voltage than the robot
controller, and the low-level signals from the EM
need to be converted into power output. This is
done with the H-Bridge. 4 wires in, from a pair
of output port on the EM 2 wires out to the motor
29Sensor inputs
Light-sensor with a 20-degree field of view
Or with a red-stripe means 40-degree
These produce Analogue signals, and need to go to
the EM via an A/D converter. There are 8 such A/D
input ports
30Binary ports
Some sensors, and indeed some outputs, can be
binary On/Off. Eg. Tactile sensors
A binary output could be eg. Switching a light
On/Off
There are 16 Binary I/O ports for this. Actually,
14 plus 2 already used for a couple of switches.
START/STOP and PAUSE/RESUME
31Ports Summary
16 Motor output ports, typically 2 per motor 8
Input ports for Analogue signals. And 14
available binary ports for Input or Output And
you can plug in an LCD screen for debugging and
scope for further expansion
32What you see
33Warnings about sensors/motors
In simulations, magic sensors deliver reliable
information about eg distances. Magic motors move
the vehicle precise distances. In the real world,
it is nothing like that. Real sensors are noisy,
and react to far more than you might
guess. Calibration of sensors Wheels slip on the
floor, get jammed on bumps.
34Worries about cheating
Sometimes people forget they are using a program
to emulate a nervous system, and sometimes this
breaks down. for ( ) How long does
this loop take? Does the time vary according to
circumstances? If you want something to happen at
a particular rate, how do you ensure that?
35Robot lab classes next week
See http//www.cogs.susx.ac.uk/users/inmanh/easy/a
life02 For details of seminars/lab classes, and
link to Idiots Guide See http//www.cogs.susx.ac
.uk/lab/adapt/aslab/index.html For comprehensive
information on robots