You are on page 1of 12

Team 6 BE 1200 1

BE 1200
Shreya Sutariya
Jonathon Khang
Jiwanjot Singh-Gill

Final Project Report


Objective: To construct an autonomous robot that when placed in an arena, can
differentiate between green and white ping pong balls. Once the different colored
balls are deciphered by the robot, the robot must be able to place the white colored
balls outside of the arena and if any green colored balls are found, to keep them
within the arena. Teams will compete in this challenge within three minutes and
whichever team ejects the most white colored balls is the winner!
User Requirements: The user must be able to place the robot in the middle of
the arena and press the orange button on the NXT to initiate the program. The user
must also be able to place and remove a white ball on the fork lift, in front of the
light sensor once the program has been initiated.
Constraints: The constraints on this project was the amount of limited parts that
were available to our team. As we did not have every part that we needed at our
disposal, we were forced to be creative and modify our design according to which
parts that were available.
Functions: The bot has been programmed to randomly navigate the arena and to
continue doing this until the light sensor detects the threshold value for a white ping
pong ball. Afterward, the bot then goes backwards until the edge of the arena is
detected. The bot then lifts the arm and the white ping pong ball rolls off the ramp
and out of the arena. The robot is also programmed to avoid the edge of the arena
when detected and to either avoid or eject green ping pong balls when identified.
Design Specifications: Base model for the robot is the Express Bot construct. We
then built a ramp on top of the NXT Brick and from there, assembled a motorized
fork lift arm. The robot is equipped with two touch sensors and one light sensor. One
touch sensor is equipped on the rear end of the robot to detect the wall and
command the arm to lift the ball onto the ramp and over the wall. The second touch
sensor was installed in the front end of robot to prevent crashing into the wall when
navigating autonomously. We installed the light sensor on the lower front end of the
robot, directed behind the fork lift arm, so when the arm has a hold of a ball, it can
detect it, differentiate the colors, and depending on the color, do a specific action.
Alternatives:
1. Originally, our design involved using four big wheels. We ended up changing
this design as we did not have enough parts to construct a proper turning
system for the bot. We then evolved to another design which only had two
main wheels, and two smaller ones for turning. We determined that even this
hindered the turning ability of the bot. The two turning wheels were changed
to one turning wheel along with the two main wheels. We began working on
an arm for this bot. This arm was very parts intensive and was a single piece
arm and ramp attached to the motor. It was determined that this design was

Team 6 BE 1200 2
not stable enough for the task, and also involved too many parts. We then
used the Express Bot design for our base. We found this conserved some
parts, and separated the ramp from the forklift arm, to make for a better flow
during the task. We added two big and two small wheels turned sideways to
act as a rolling bumper. As the bot was moving randomly, if it hit a wall
without triggering the touch sensor right away, these wheels would guide it
along the wall, either turning it or triggering the sensor. This design proved
very efficient and reliable.
2. Sometimes white ball would get trapped in the space beneath the forklift
arm, or the lone touch sensor at the back would not help guide the bot away
from the wall, as it was still further away. In order to solve this problem, we
attached a larger piece from the bar on the touch sensor, underneath the
forklift arm, attaching to the other side of the bot. This helped by both
ensuring a ball didnt get trapped, and by created a pseudo-bumper
underneath the forklift. This way, if the fork-lift hit a wall and moved back far
enough, while the touch sensor hadnt, it would still trigger the touch sensor,
causing the bot to turn around.

Model Design:

Team 6 BE 1200 3

Evaluations and Refinements:

Team 6 BE 1200 4

Performance
Parameters

Attempt Testing Results

Success Refinements
Rate

Retest
Rate

Navigate

Bot is really slow


and does not fully
cover the arena.

50%

Reduced the time


range in the random
commands and in
increased the speed.

100%

Green ball
detection and
ejection

Bot correctly sensed


green and lifted the
arm.

100%

Green is not always


detected.

60%

Added dynamic
color detection

100%

After hitting a wall, 70%


the bot does not stop
the motors
controlling the
wheels. The bot
does lift the arm.

Put in off commands


for the motors.
Added code to stop
task navigate after a
white ball was
detected.

90%

Bot keeps detecting


a white ball when
one is not present
and lifts the arm.

90%

Added commands to
move the bot
backward for half a
second.

50%

White balls detected


as green and so the
bot did not move
backward against a
wall to lift the arm.

50%

Decreased range of
threshold values for
the white balls.

100%

Green balls are


sometimes detected
as white.

60%

Added dynamic
color detection

100%

Back up to the
1
edge of the arena
before ejecting
white ball

Bot immediately
ejects the white ball
instead of going to
the edge of the
arena.

0%

Removed the code


from the function
arena and placed it
into the fork_lift
function.

100%

Avoid arenas
edge

Does not back away


after hitting the
wall.

0%

Replaced if
statement about
touch sensor with an
until statement.

0%

White ball
detection and
ejection

Team 6 BE 1200 5

Does not back away


after hitting the
wall.

0%

Changed fork_lift
function into a task

30%

The bot crashed


after hitting the
wall.

30%

Changed the fork_lift 0%


task back into task

Implementation Plan:
In this final project design, there were a few unexpected complications with
the overall design with the robot. The use of sounds and tones were a large aid in
determining what part of the program was working correctly and inaccurately.
1. With this project, the objective is to construct a robot that can navigate its
way throughout the arena autonomously and while navigating, be able to
differentiate between green and white ping pong balls while placing the white
ping pong balls outside of the arena. The first step is to construct the base
design of the robot as Express Bot. From there, we built a ramp that is high
enough to place a white ping pong ball outside of the arena and we also
added a third motor for a motorized fork lift arm. We then install three
sensors, two touch sensors and one light sensor. One touch sensor on the
rear end, one touch sensor on the front end, the light sensor behind the fork
lift on the front end. We also add two large wheels of the front end of the
robot on each side. This will prevent any major damage or collision to the
robot itself and also assist with the robot maneuvering around the arena walls
more efficiently. Now, its time for programming!
2. First thing first, we want to write a task for the robot to navigate around the
arena at random amounts of time. We create a task called navigate that
can have the robot move forwards, backwards, and only turn counter
clockwise. To determine the random movements, instead of using a specified
wait time, we write Wait(Random(*Some number*)). With this, the robot will
move accordingly to its command at a random time from one to the specified
number minus one. For example, if the number is 1000, the robot will
randomly move at a time between 1 and 999.
3. Next, we need to write a task for when the light sensor detects the ball.
Instead of a task, we want this part of the program to consistently be running,
but only when a ball is detected. First, we have to write a subroutine function
to dynamically determine the threshold value of the white ball. We name this
subroutine setup and within this, the threshold value of the white ball can
be defined. We also have to define or set a minimum and maximum threshold
value for the green ball.

Team 6 BE 1200 6

4. Write another subroutine, called fork lift, for when to command the fork lift
arm when the light sensor detects a white ball. In a while true statement, if
the white ball is detected, we want the robot to stop task navigate and move
backwards with the motors in sync until the rear touch sensor is pressed. At
that same moment when the touch sensor is tripped, we want the motors to
stop and the fork lift arm to lift the white ball up onto the ramp, where it will
fall out of the arena. After the white ball is placed outside of the arena, the
robot will start task navigate again.
5. Within the subroutine fork lift, we want the green ball to be ejected out of the
fork lift arm contraption. To do that, we write if the green ball is detected,
stop task navigate, command the robot will move backwards, forwards, and
backwards again, causing a jerk movement to occur. This command will
cause the green ball to leave the fork lift arm and begin task navigate again.
6. The last command we need is for the robot to back up a certain amount of
distance when the front end touch sensor is pressed. In order to accomplish
this, write an if statement stating that if the front touch sensor is pressed, to
stop task navigate, and move backwards while in sync at a specified wait
time. Within each of these if statements, the use of sounds are very helpful
when determining the thresholds of each colored ball, when the touch
sensors are pressed, and when the robot is doing certain commands overall.
7. Last but not least, we have to set up a main task. Inside the main task, we set
up all of our sensors. Add the subroutine set up so it will initiate as soon as
the program starts. Then add a start command, initiating the navigate task
and add the subroutine fork lift so it will always be running throughout the
program since it is in a while true statement.
8. Now with all of the programming finished, test out the robot and record any
results you might notice. Make any necessary changes if needed. If all is
correct, congratulations! Youve finished the assignment!

Debugging Procedures:
1. One problem we had is that the light sensor would not differentiate clearly
between green or white ping pong balls. In order to fix this issue, we
changed the program to eliminate anything involved with green. In other
words, the bot would not do anything if it sensed green. During a trial run,
this proved problematic because it loaded a green ball on, didnt do
anything, and prevented white balls from getting loaded on. In order to
avoid this problem, we decided on using fixed variables for green, and
dynamic variables for white. To prevent the accidental exit of the green
ball from the arena during the fling, which is meant to keep it in the
arena, we decided to create a code to jerk the robot when it loaded a

Team 6 BE 1200 7
green ball. Instead of using the forklift at all, we decided to move the bot
forward and reverse for a few seconds, expelling the green ball. This was
very successful as it would keep jerking until the green ball fell out.

2. There was also a slight design change that needed to occur for this jerk
to work. Originally there was a black bar at the front of the forklift,
trapping the loaded ball on. After the jerk idea was thought of, we
replaced this single black bar, with two shorter grey bars. These would still
serve the purpose of holding the ball in place while loaded, but had
enough of a gap between them to allow a ball to escape if jerked.

3. The navigation command was an issue in the beginning of this


assignment. The random wait time we had was too short, thus causing the
robot to move only a certain distance and never really reaching the wall.
This caused issues trying to capture a white ball. After a few tests, we
increased the value of the random wait time which caused the robot to
navigate more efficiently. Though during the last trial, there was still an
issue with the navigation task. It was still too long of a wait time, causing
a slight issue of repetitive movements after the front touch was pressed.

4. When backing up while a white ball is detected, there was a slight issue of
when the rear touch sensor will be pressed. Sometimes it wouldnt be
pressed at all and that was because the piece that was held in the touch
sensor, to extend its capability, was too short. In order to avoid this kind of
complication again, we decided to replace the shorter piece with a much
longer piece, thus eliminating the problem of not being pressed when
needed.

Program Table:

Item

Description

Preprocessor Directives

Team 6 BE 1200 8
GREENMIN
conveniently
GREENMAX
conveniently
EYE
Global Variables
WHITE
Tasks
navigate ()

Functions
void setup()

void fork_lift()

Program Code:

#define GREENMIN 32
#define GREENMAX 36
#define EYE SENSOR_2

Used to call the lower end of the Green spectrum


Used to call the upper end of the Green spectrum
Used to call the light sensor in port 2 conveniently
Data value indicating the percentage of light reflected by
the White ping pong balls.
Task to navigate the arena. Reverses for a random time,
turns for a random time, goes forward for a random time,
and turns again for a random time.
Before the main task is started, this setup gives definition
to the variable WHITE. The bot is first placed on the arena
with a white ball loaded on, where it saves the reflected
light as WHITE and plays a sound to confirm. Within 2
seconds, the bot plays another sound and executes the
main task.
Whenever the light sensor detects that a white ball has
been loaded, it stops the navigation task, plays a sound,
and moves forward until the touch sensor is activated
when it hits the wall. Then it raises the lift to guide the
white ball out. If a green ball is loaded, the bot jerks
forward and backward until the ball falls out of the lift. If
the touch sensor on the rear is activated, the bot stops
navigation, turns and then starts navigation again.

Team 6 BE 1200 9

int WHITE;

void setup()

//This function gives definition to variables

{
WHITE = EYE;
PlaySound(SOUND_UP);
Wait(2000);
PlaySound(SOUND_DOUBLE_BEEP);
Wait(2000);
}

task navigate()
{
while(true)
{
OnRev(OUT_AC, 73);
Wait (Random(3200));
OnFwd(OUT_C, 63);
Wait (Random (1500));
OnFwd (OUT_AC,73);
Wait (Random(3200));

Team 6 BE 1200 10
OnRev(OUT_A, 63);
Wait(Random (1500));
}
}

void fork_lift()
{
while(true)
{
if(EYE >= WHITE) //((EYE <= WHITEMAX) && (EYE >= WHITEMIN))
{
StopTask(navigate);
PlaySound(SOUND_DOUBLE_BEEP);
OnFwdSync(OUT_AC, 50, 0);
until(SENSOR_3 == 1);
{
PlaySound(SOUND_UP);
Off(OUT_AC);
Wait(1000);
RotateMotor(OUT_B, 23, -135);
Wait(100);
RotateMotor(OUT_B, 43, 135);
StartTask(navigate);

Team 6 BE 1200 11
}
}
else if((EYE < GREENMAX) && (EYE > GREENMIN))
{
StopTask(navigate);
PlayTone(1000, 40);
OnFwdSync(OUT_AC, 80, 0);
Wait(200);
OnRevSync(OUT_AC, 80, 0);
Wait(200);
OnFwdSync(OUT_AC, 80, 0);
Wait(500);
StartTask(navigate);
}

else if(SENSOR_1 == 1)
{
StopTask(navigate);
PlayTone(1000,1000);
OnFwd(OUT_AC, 50);
Wait(1000);
OnFwd(OUT_A, 50);
Wait(600);

Team 6 BE 1200 12
StartTask(navigate);
}
}
}

task main()
{
SetSensorLight(IN_2);
SetSensorTouch(IN_1);
SetSensorTouch(IN_3);
setup();
StartTask(navigate);
fork_lift();
}

You might also like