|
Software
Analysis
Following a careful examination of the problem it was
decided to divide the software design into the following
three areas:
- Movement: A set of functions that would control the
robot’s movement around the arena. These would
include simple functions such as those to make the robot
move forwards, as well as higher-level functions such
as those to prevent the robot from crashing into walls,
or those to make it go to a specific corner. They would
be triggered by events occurring inside the arena, such
as the successful collection of an object.
- Control: This set of functions would be developed
to control movements in the robot that do not impact
on its physical location. As an example, functions would
be required to open and close the robot’s arms,
and also to control the IR sweep.
- Object Detection: The final group of functions would
be generated for the purpose of object detection. They
would be required to detect the presence of an object,
its location relative to the robot, and also to provide
a positive identification of the object following its
collection.
Movement
The initial analysis carried out prior to the final software
design considered the most appropriate patterns of behaviour
for our robot. One area that was investigated in detail
using experimental methods was the best way to implement
a turn function for the robot. Two alternative approaches
were proposed:
1. Upon encountering an object or wall the robot should
make small turns incrementally until it returns to a state
that is
....acceptable
2. Upon encountering an object or wall, determine the
incident angle and turn an appropriate amount immediately.
For patterns of movement it was decided that when searching
for an object an approach should be taken that copes well
with the random distribution of the objects. For this
reason, it was decided that the most suitable approach
would be to create a simple function that turned the robot
in a random direction when it hit a wall. In contrast,
when the robot is carrying an object, the wall should
be followed in order to help the robot find the appropriate
corner.

Corner Detection
For corner detection it was decided that the simplest
solution would be to take a reading of the colour of the
floor when the robot hit a wall. If the reading indicated
that the robot was in a corner, then it could act accordingly,
otherwise it would follow the wall until it did reach
a corner.
Object Collection vs. Wall Avoidance
A design problem that became apparent immediately upon
embarking on the project was the requirement for the robot
to clearly distinguish between objects in the arena and
the walls. Since the walls of the arena were much taller
than the objects contained within it an obvious solution
seemed to be to use two IR sensors placed at different
heights on the robot. The lower IR sensor would be used
to detect objects within the arena, the higher one to
detect the walls. However, two sensors presented the additional
problem of deciding which sensor should have precedence
in influencing the robot’s behaviour. An approach
was taken to allocate priorities to the respective sensors,
with the higher sensor given the highest priority. This
was decided since the higher sensor would only ever detect
walls and never objects. Since avoiding walls (which could
cause the robot to get stuck) was a higher priority, triggering
the higher sensor would result in the robot acting to
avoid a wall, satisfying the requirement of not getting
trapped on a wall or in a corner.

Feasibility
Movement
Following some basic experimentation it became clear that
the first approach involving incremental turning would
result in the robot moving around the arena unacceptably
slowly. Therefore, it was decided that the second approach
would be the most suitable. The relationship between the
turning speed of the robot and the angle to be turned
was modelled. A function was then written that would convert
the incident angle, as approximated by the IR sweep, into
a time in milliseconds which the robot should turn for.
This worked consistently well, and was incorporated into
the final design.
Experimentation on the idea of turning the robot in a
random direction when it hit a wall when searching for
objects proved feasible. The robot demonstrated good coverage
of the arena, indicating that this approach would lead
to a high success rate in detecting objects.
Corner detection
After initial feasibility testing, it as discovered that
problems differentiating between the red corner and the
floor meant that this method of corner detection would
not perform sufficiently well on its own.
In an attempt to find an alternative approach the sweep
values for the IR sensors were analysed when the robot
was placed in a corner and compared to sets of values
obtained when the robot was next to only one wall. It
was found that a sweep conducted when the robot was placed
in a corner resulted in an array containing two maxima.
This provided a secondary condition from which we would
be able to determine if the robot was in a corner.
The values obtained from the sweep did not always rise
and fall smoothly however. Anomalous values seemed to
occur relatively regularly so a decision was taken to
perform smoothing on the array obtained from the IR sweep.
To perform the smoothing, each value in the array was
replaced with an average of itself and the two values
either side of it. As a result of the smoothing it appeared
that the robot began to identify the presence and location
of walls more accurately; it also improved its ability
to distinguish between a single wall and a corner.
As part of the smoothing the lowest and highest indexes
of the sweep array were reset to zero. This was due to
the unusually high incidence of high values detected when
no object was present at these locations. This often caused
the robot to decide that it was in a corner when in fact
it was close to only one wall. Since the highest and lowest
indexes of the array are gathered from a direction approximately
perpendicular to the robot’s direction of travel,
no negative behaviours were observed as a result of this
practice.


Object Detection vs. Wall Avoidance
The idea of using two IR sensors yielded promising results
following some initial tests in the robotics labs. Initially,
some problems were encountered due to the higher sensor
being triggered by objects placed in the arena. When this
situation occurred the robot would avoid the object instead
of turning towards it as desired. The problem was solved
by raising the highest IR sensor slightly and by ensuring
it was placed so that it scanned horizontally. Following
this adjustment, the observed behaviour of the robot improved
and it seemed to quite accurately distinguish between
the walls and the objects that should be collected. This
means of using two Infra Red Sensors was therefore incorporated
into the final robot design.
|