![]()
Programming The IR Brainibot is programmed from a PC running Windows. Programs are downloaded over a serial cable. ![]() The programming system is based on that used by the Picobotz. (See the Picobotz page for a fuller description.) You can download a copy of the programming system. Variables
There is a single variable called N. Several of the instructions use N as their parameter; for instance
Events and Behaviours
The robot responds to its sensor inputs by executing Events and Behaviours. A program consists of one or more "Behaviours". Each Behaviour contains a Main Handler and zero or more "Event handlers". You can create Event Handlers and Behaviours via the Event and Behaviour programming pages. The program below has two Behaviours. The Main Behaviour has a main program and three Event handlers. Behaviour 2 only has a main program. ![]() ![]() The Main Handler and the Event handlers contain instructions to turn on and off Motors, make Beeps, etc. The robot initially runs the Main Handler of the Main Behaviour. When it reaches the end of the the Main Handler it returns to the start and executes it repeatedy, Events If, at any time, a sensor value triggers an Event then the robot stops executing its current program and starts executing the Event handler. For instance, in the above program, it the robot senses an obstacle to the left then it starts to execute the ObstacleLeft Event handler. When execution reaches the end of the Event handler, the robot starts running the Main Handler of the current Behaviour again. It re-starts at the beginning of the Main Handler. Only events in the current Behaviour which are to the right of the current handler can be triggered. So, while the robot is executing the ObstacleLeft Event handler, it will not respond to obstacles to the right but it will respond to a Light > Threshold Event. Behaviours Behaviours are like independent programs. They have a Main Handler which is executed repeatedly and Event handlers which are executed when Events are triggered. Only one Behaviour is being executed at any time. An Execute Behaviour N instruction tells the robot to start executing a different Behaviour. It continues to execute that new Behaviour until it meets another Execute Behaviour N instruction; at the end of any Event handler, it returns to executing the Main Handler of the current Behaviour. Only Events in the current Behaviour can be triggered. Event Handlers in other events are ignored. In the above program, if a Light > Threshold Event is triggered then the robot starts executing Behaviour 2. |
||||||
Questions or
comments ? E-mail me at PeterBalch@btinternet.com
No part of this web page may be reproduced in any form or by any means,
including photocopying and recording, for any purpose without the express
written permission of Analogue Information Systems Ltd.
This web page is copyright © 2003 Analogue Information Systems Ltd.,
1 Warrender Park Crescent, Edinburgh EH9 1DX, Scotland, UK, Tel: +44 (0)
131 228 6008. All Rights Reserved