Page 37 - Designing Autonomous Mobile Robots : Inside the Mindo f an Intellegent Machine
P. 37
Chapter 2
screen with smiley faces and arrows, or worse yet displaying the dreaded blue screen
of death.
Methods
Methods are nothing more than functions within an object that act on the properties
or perform tasks as modified by the properties. A call to a method almost always
requires arguments to determine the details of its execution. In many cases, the
arguments are not the value of variables, but rather the addresses of the variables. In
this case, the argument is said to be “by reference” rather than “by value.” The
method may manipulate the values of these arguments by reference, or generate
output in a myriad of other ways. In almost all cases, a method will return a status
value that lets the calling program know if the desired action was successful.
Just as arrays of objects are possible, objects may contain other objects. In one
example I remember, objects contained data types which in turn contained other
objects, which in turn possess arrays.
The power of objects is that they allow us to build walls around well-tested blocks of code,
and to use this code over and over with the certainty that it will execute safely. As an
additional advantage, once an object has been created it makes envisioning the functioning of
the whole module easier.
Robots and robot subsystems as objects
The important thing is to know when to use objects to represent something, and
when to use more conventional representations such as arrays. A true zealot of the
cause will opt for making everything in sight into an object. The result may be more
confusing than helpful.
Generally, the more complex a block of code becomes, and the more variables and
types of variables that act upon it, the better candidate it is to become an object. If
you are writing a robot control program to execute on a PC, then you should give
careful consideration to those items you wish to represent in this way. If you are
expecting to allow third parties to access this code, then placing it into an object
such as an OCX will be very useful.
Additionally, if you are going to include vendor-supplied code into your control
system to support third-party systems like video compressors, the interface code will
most likely be supplied to you as an object (e.g., OCX) file. In most cases this will
20

