Page 58 - Designing Autonomous Mobile Robots : Inside the Mindo f an Intellegent Machine
P. 58
The Basics of Real-time Software (For Mere Mortals)
2. Decide which of these will go into common threads and rough in a structure.
3. Decide on the ways you will handle task switching.
4. If you will have control of interrupts, decide on the interrupt priority order
that will assure critical services get done first. If programming in VB, make
sure no task hogs CPU time.
5. Think about which functions are generating data, and which are consuming
it, and look for timing conflicts.
6. Write critical components like communications drivers first.
7. Test each component and service as it is added.
8. Build in error handling at every level, and think about how you are going to
monitor the system’s performance.
9. Decide on the units you will use for distances and angles, and create a basic
library of mathematical and geometric functions.
Creating a library
A good library of mathematical and geometric functions is an essential part of the
foundation of a robot control program. This library should be written with speed and
reentrance in mind. This means that library functions must keep all variables locally,
and units of measure and conventions must be consistent between functions.
Decide the type of variables you will use, and be consistent. If angles are assumed to
be positive for the clockwise direction in one routine, then all routines must assume
this. If the system is to accept both English and metric units of measure, decide
which system it will actually use, and make the conversions to the other system at
the operator interface.
If you are programming in a high-level language, then the choices will range from
integers and long integers, to singles and doubles. Remember that nothing is free. If
you decide to use singles instead of integers, you may slow the calculations dramati-
cally. On the other hand, if your target system has a math coprocessor, this might
not be the case.
41

