Be 1200 Final Report

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Team 9

Fadi Basheer
John Heinonen
Chirs Mann
BE 1200 Prof. Gina Shreve
Final Report

1. Clarify Objectives

Design and build an NXT robot


Write a code to perform the following tasks:
o Use a light sensor to identify ball
o Use a touch sensor to detect wall of arena
o Use an ultrasonic sensor to detect wall of arena
o Navigate around arena and find ping pong balls
o Identify color of ball
o Dispose of green, keep white balls

2. Establish User Requirements


After the user designs and builds the robot, as well as writes the code, all he has
to do is download the program to the NXT robot, place it in the arena, and press
RUN.
3. Identifying Constraints
We could only use the limited amount of parts from the Lego NXT Mindstorm set
to build our robot. We are also limited by the number of sensor ports on the
brick, as well as all the wires from our sensors interfering with our tires and the
throw arm. We are also limited by the software limitations of NQC programming
language. One other constraint was an error in the software which made our
robot run continuously. The only way to stop it was to remove the battery pack.
4. Establish Functions
Robot must use a light sensor to identify color of ball
Robot must be able to detect the wall of arena using either a touch
(traveling backward) or ultrasonic sensor (traveling forward)
Robot must be able to carry out correct command according to color of
ball

Robot must be able to find wall using touch sensor and throw green ball
out of arena
5. Establish Design Specifications
NXT brick
Three lego motors
One light sensor
One touch sensor with a release type bumper
One ultrasonic sensor
Two wheels
One small track wheel
Various other small parts from Lego Mindstorms set
We used a similar design to the original tri-bot design that we built during
the first couple days of class. However, we added a third motor to the top
of the robot. This motor controls an arm which receives instructions from
the NXT Brick to either keep a white ball or throw a green ball out of the
arena. To the arm, a light sensor was attached to allow the robot to identify
the color of any ball it picks up. Also on the front of the robot, an ultrasonic
sensor allows the robot to read the wall of the arena so that it can reverse
and change direction. We added a touch sensor with a release type
bumper to the back of thero bot to detect the wall of the arena. It is used in
the task identify_ball. Once a green ball is picked up and identified, the
robot reverses until it detects the wall of the arena. At that point, the throw
arm is activated and the green ball is thrown out of the arena. We used
the release type bumper because our group decided that it seemed like
the more consistent way to trigger the touch sensor.
6. Generate Alternatives
Our group discussed either using another touch sensor on the front of
the robot to identify the wall instead of using the ultrasonic sensor. This
would have caused problems if the robot did not hit the wall squarely.
Also, we considered using a press setup instead of a release-type
setup for the touch sensor on the rear of the robot. This would have
yielded a simpler design, but would not have been as effective.
7. Modeling
We built our robot around the same general tri-bot concept that has been
used all semester, since it is simple and effective. Certain changes were required
since the task is so much different than any previous assignments, but the tri-bot
concept worked well.

Program Table:
#define WHITE

This defines the value of a white ball

as 46
Tasks
task drive ()
This tasks commands the robot to
drive around looking for balls, unless it
gets too close to the wall.
OnFwd(OUT_AC, 75)
This commands the robot to drive
forward at 75% power unless the
conditions in the following while
(true) are met.
while (true){
This tells the robot that if the
if SensorUS(IN_3) <13
Ultrasonic Sensor (in input 3,) reads a
value less than 13, it should perform
the following lines of code.
Off(OUT_AC)
If the Ultrasonic sensor reads a value
less than 13; first, the motors shut off.
OnRev(OUT_AC, 75)
Then the robot reverses at 75%
power.
Wait(800)
The robot performs the proceeding
line of code for 800 milliseconds
OnFwd(OUT_A, 100)
This turns the robot to the left.
task identify_ball ()
This task commands the robot to use
the light sensor to identify both green
and white balls.
if (SENSOR_2 > 32 ,, SENSOR_2 <
This tells the robot that if it reads a
43);
value between 32 and 43 (which is a
Wait(50);
green ball) with the Light Sensor
if (SENSOR_2 > 32 ,, SENSOR_2 <
(Input 2) that it should wait 50
43);
milliseconds and read it again.
StopTask (drive)
This command makes the robot stop
performing task drive and makes the
robot perform the following lines of
code.
OnRev(OUT_AC, 50);
This tells the robot to back up at 50%
until (SENSOR_4 == 0)
power until our release type touch
sensor (Input 4) is bumped by the
wall.
OnRev(OUT_B, 100);
This commands the robot to move the
Wait(250)
motor plugged into output B (which is
the arm that ejects the balls) to move
in reverse for 250 milliseconds to
throw the ball.
Off(OUT_B);
These lines of code turn off our
Wait(50);
throwing arm, and then move it
OnFwd(OUT_B, 100); Wait(250)
forward back down to the ground.

if (SENSOR_2 > 46);


Wait(50);
if (SENSOR_2 > 46)

Pictures:

This tells the robot that if it reads a


value greater than 46 (white ball) that
is should wait 50 milliseconds and
read it again.

Video:
The video will be posted on the website.
Refine and Optimize Design:
While constructing the robot, there was few changes that had to be made;
however, the biggest change had to be moving the ultrasonic sensor lower on the robot.
We had issues with it not detecting the wall of the arena, since the wall is so short.
When the ultrasonic sensor was moved lower, it made the detection of the barrier a lot
easier than before. Another problem we encountered in developing the robot was the
throw arm. Since we had never dealt with three motors before, we had difficulty in the
actual mechanical structure being strong enough. When the robot would hit the wall, the
throw arm would get knocked sideways. By squaring up the throw arm, the force
generated by the wall could no longer push the arm sideways, and the arm can stand
repeated bumps into the wall of the arena.
Advanced Strategies:
The main advanced strategy that was used for this robot was using the ultrasonic
sensor. Even though it was used by many students, it was a difficult sensor to use
since there was not a lot of knowledge about it. After reading the NXT tutorial, it was
easier to get an idea of how it needed to be programmed. Ultimately, it was the main
reason why the robot was able to successfully navigate the arena and find ping pong
balls. To go along with the ultrasonic sensor, the light sensor values that were used
helped the robot separate the green from the white balls. These differences in the
reflective light value allowed the robot to be successful.

Data Table:
1

Changes
The wait time on
multiple OnRev
and OnFwd codes.
Adjusting the
values of light
sensor on the
robot to get it to
detect different
colored balls.

New Result
During multiple parts of the project, changing the wait time
allowed the robots to act on different functions during
appropriate times. This allowed the robot to turn around in
different ways to grab different colored balls.
By changing the values on the light sensor, the robot was
able to detect different colored balls and separate them
from others. The values allowed the light sensor to be
more accurate as it was reading the values.

Placing the
ultrasonic sensor
higher on the
robot.

Getting the right


speed values for
Motor B which
threw the balls out
of the arena.
Inserted a releasetype bumper to
enable robot to
throw green ball
out of arena.
Getting the white
ball to eject
immediately

Changing the
distance the robot
detects the wall.

Adding on a
StopTask function
to get the robot to
stop immediately
at different points.
Adding a flat
surface on top of
the robot.

Flowchart:

A huge problem was changing the position of the


ultrasonic sensor on the robot so it can detect the wall
only, and not all the balls in its way. In order to accomplish
this, the ultrasonic sensor had to be placed at different
positions.
This was also a tough challenge because Motor B had to
be set at a certain rotation speed so it had enough power
and accuracy to throw the ball over and out of the arena.
By playing with the speed values, this was possible.
Prior to this, the robot had a tough time knowing when to
throw the ball out of the arena. To fix these, when the
trigger went off for the release-type bumper, it knew to
throw the green ball out of the arena.
After the robot grabbed a white ball, it had to be ejected
immediately because the objective was to grab green balls
and throw them out of the arena. In order to do this, a
command to Motor B need to be added in the middle of
detecting a white ball.
By getting the right distance for the robot from the wall, it
gave the robot accurate measurement to turn around.
This needed to be measured because the robot was so
lengthy, it had to turn at a certain times using the ultrasonic
sensor.
The StopTask function was used in multiple situations in
order to make the robot stop and carry on new functions.
This made transitions from grabbing balls to reversing a lot
easier.
This was done to make throwing the green ball out of the
arena a lot easier. This allowed Motor B to maintain a
certain speed in order to throw the green ball out of the
arena.

Program Code:
#define WHITE 46

//go find a ball


task drive()
{

OnFwd(OUT_AC, 75);
while (true) {
if( SensorUS(IN_3) < 13)
{
Off(OUT_AC);
OnRev(OUT_AC, 75);
Wait(800);
Off(OUT_AC);
OnFwd(OUT_A, 100);
Wait(1500);
Off(OUT_A);
}
else
{
OnFwd(OUT_AC, 75);
}
}
}

task identify_ball()

while(true)
{
if(SENSOR_2 > 32 && SENSOR_2 < 43)
{
Wait(50);
if(SENSOR_2 > 32 && SENSOR_2 < 43)
{
StopTask(drive);
OnRev(OUT_AC, 50);
until(SENSOR_4 == 0);
Off(OUT_AC);
OnRev(OUT_B, 100);
Wait(250);
Off(OUT_B);
Wait(50);
OnFwd(OUT_B, 100);
Wait(250);
Off(OUT_B);
StartTask(drive);
}
}
if (SENSOR_2 > 46)
{
Wait(50);
if(SENSOR_2 > 46){
StopTask(drive);

OnRev(OUT_B, 100);
Wait(250);
Off(OUT_B);
Wait(50);
OnFwd(OUT_B, 100);
Wait(250);
Off(OUT_B);
StartTask(drive);
}
}
}
}

task main()
{
SetSensorTouch (IN_4);
SetSensorLowspeed(IN_3);
SetSensorLight(IN_2);
start identify_ball;
start drive;
}

Group Member Contribution:


Design of Robot: Fadi Basheer, John Heinonen, and Chris Mann
Setup of Program: Fadi Basheer and John Heinonen
Robot Testing: Fadi Basheer
Debugging: Chris Mann and John Heinonen
Improvement on Robot Design: Fadi Basheer and John Heinonen

Report Tables: Fadi Basheer and Chris Mann


Flowchart: Fadi Basheer
Other Parts of Report: Fadi Basheer and John Heinonen

You might also like