The Scorpio'bot's programming done using object orientated programming
in Java. The robot object contains a two Claw objects, a Tail object, and
a Cage object. As the names suggests, the Claw
object handles operating a claw of the robot: moving the claw up and
down, and holding and releasing a block. The Claw object also handles
detecting wether the block it is currently holding is a hacker or a non-hacker
(student or professor). The Tail
object handles moving the Tail up and down. The Cage
object handles tipping the hackers out of the the left and right
bins (situated at the sides of
the Scorpio robot). The Robot object handles combining these
objects together and moving the Scorpio robot. Calibration routines
in the Robot object class are responsible for calibrating the robot to
determine it's orientation immediately after the start light-signal goes
on.
Because calibrating/testing of the Scorpio'bot has not been completed, certain already-written methods of the Robot object class are not included on this page. Clearly, it is useless to write a lineFollow routine without making sure that the robot can move straight, detect which sensors are on/off a black line correctly, correctly adjust it's direction of motion to compensate for being off the black line, and so on. Because there was not sufficient time close to the competition date to calibrate and test the scorpio'bot's fundamental routines, the other-already-coded methods also were not completely implemented for Scorpio'bot and therefore are not included in this release.
Although competition is over, further work will go into these.
Methods of Cage object class
tipCage(int position) : This methods tips the page. It has
two posible positional values scorpio robot uses. tipCage(0) sets the Servo
to one side and
tips the left bin open. tipCage(255) sets the Servo to another side
and tips the right bin open.
Methods of Tail object class
releaseTail(int speed, long mls) :This method releases
the tail of the Scorpio Robot. the tail is releases by driving the
motor in one direction
for mls milliseconds, at speed speed.
retractTail(int speed, long mls): This method retracts
the tail of the Scorpio Robot to a position above the robot. It does so
by diving the motor
in a direction opposite to that of releaseTail at speed speed for
mls milliseconds.
Methods of Claw object class
boolean detectBlock(): This methods returns
the state of the block detector on the robot's claw. It returns true
if a block has intercepted the
light beam emitter/reciever pair. The value returned remains true until
the block has been released (openClaw method
has been called), otherwise it returns false.
boolean detectHacker(): This method returns checks the state
of the Color detects on the robot. It returns true if previously there
was a block
in the claw and the color detectors detect a black object in the claw.
The value returned remains true until the block
has been released (openClaw methods has been called), otherwise it returns
false.
int openClaw(int ticks) : This method attempts
to open the claw of the scorpio bot by powering the related motor in a
certain direction. It returns
an error code if after 600 milliseconds, the claw has not moved, indicating
that it has stalled. The error code indicates
how far the claw was able to open before it stalled.
int closeClaw(int ticks): This method attempts
to close the claw of the scorpio bot by powering the related motor in the
reversed direction to
openClaw(int ticks). It also returns an error code if the claw stalled.
The error code indicates how far the claw was able
to close before it stalled.
int lowerClaw(int ticks): This method attempts
to lower the claw of the scorpio bot by powering the related motor in a
certain direction. It returns
an error code if after 600 milliseconds, the claw has not moved, indicating
that it has stalled.
int raiseClaw(int ticks): This method attempts
to raise the claw of the scorpio bot by powering the related motor in the
reversed direction to
lowerClaw(int ticks). It also returns an error code if the claw stalled.
Robot Methods
Because some of the robot methods have not been tested/calibrated
none of the methods are included here - for now. A description of the nature
of
the methods and their error correcting ability is detailed below.
The Robot object methods are designed to be mostly reactive. Each
lower-level method handles possible errors up to a point, which thereafter
it gives up and sends an error message to the calling methods. Thus if
the drive method cannot reach the desired point (perhaps because an opponent
is is blocking it), the drive method backs up and tries to move the desired
distance. After the drive method gives up, it sends an error code
to the calling method returning the distance it was able to move and giving
the calling method the option of backing out of the action. The calling
method then pulls the robot backwards and goes to move the robot to do
something else. If the drive method is unable to move backwards during
any of its attempts it realized that the Robot is stuck. At this
point the freeRobot method is called. This method forces the robot to ram
the object preventing it from moving, and then pull away. The ram-pull-away
action proceded until the robot is able to go free.