0% found this document useful (0 votes)
30 views9 pages

The Maze Runner (Final)

The document describes a robotics competition held by Khalifa University where student teams had to program a Lego NXT robot to navigate a maze, pick up a red ball, and exit the maze. The team described in the document designed a robot with color, light, and ultrasonic sensors to follow a white line, detect and catch the ball, and navigate dead ends to complete the task. Their MATLAB code used sensor readings to control the robot's movement and arm through the maze to win credits in the competition.

Uploaded by

linda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views9 pages

The Maze Runner (Final)

The document describes a robotics competition held by Khalifa University where student teams had to program a Lego NXT robot to navigate a maze, pick up a red ball, and exit the maze. The team described in the document designed a robot with color, light, and ultrasonic sensors to follow a white line, detect and catch the ball, and navigate dead ends to complete the task. Their MATLAB code used sensor readings to control the robot's movement and arm through the maze to win credits in the competition.

Uploaded by

linda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

The Maze Runner

Prepared by:
Reem Saif Alneyadi - 100041447
Hind Saeed Amin - 100041484
Linda Taha Ismail - 100041628
Introduction
Today, advances in technology are encouraging all communities to strive to excel
in the robotics division. Therefore, Khalifa University for Science Technology and
Research decided to familiarize its freshmen students to robotics by making a
competition for the students of the Introduction to Computing course. The
mission of the robot was to follow a white line through a maze using only the
algorithm provided by students, and without the interference of anyone. The
robot is supposed to pick up a red ball placed in the maze and then find its way
out of the maze. The programming language that we were asked to use to create
an efficient code is MATLAB. All teams were provided with a Lego NXT kit to build
the robot. The team with the fastest robot would be awarded more credits.

Problem Analysis/Description
Task 1: The robot must follow a white line of width 2 cm.
Task 2: The robot should work on any maze. It should be intelligent.
Task 3: The robot must detect dead ends and find a better route.
Task 4: The robot must detect the red ball and catch it.
Task 5: The robot must start at the YELLOW area and stop when it is fully in the
GREEN area.
Task 6: Our robot must win against other competing robots to get full credit.
Robot Dimensions and Rules
As per the instructions of our lab instructors, the dimensions of the robot should
not exceed a maximum of 25 cm by 25 cm before starting its mission. However, it
can expand after the mission starts. The robot must work on its own without any
intervention. Only one NXT brick may be used, and no extra parts may be used so
that no team has an advantage over the other. The robot must be out of the maze
within 15 minutes. Also, any failures caused by the carelessness of the team
members, such as low battery of the robot, are not enough justification for a
rematch.

Work Strategy
Our team was one of the few teams with only 3 members. This placed a larger
work load on us compared to the rest of the teams in the competition. As a result
we arranged many meetings outside of class to work on the project despite our
packed schedules. We also researched a lot to learn more about what has already
been done in similar projects. Many design and code alternatives were considered
until we found the most suitable one.

Robot Algorithm/ Pseudo code


For the robot to accomplish its mission many alternatives were possible. We
considered many of them before reaching this one that we found ideal. The robot
would have the ultrasonic, light and color sensors open at the beginning. The
robot would follow the white line, using the zigzag method, until it reaches a wall
or finds the ball. If the robot faces a wall, it would turn left and check the distance
to the wall. Then it would turn to the right and check the distance again. If it is
surrounded by walls on three sides, it would turn back to the original path and it
keeps turning left and right to check for an alternative route. It keeps on doing this
until another white line is detected by the color sensor and then it follows that
line. If the light sensor detects the red ball the robot closes its arms to catch it. The
robot switches off the light sensor then continues following the white line until it is
out of the maze. When the color sensor detects the green color, the robot moves
10 cm then stops. The robot must be fully in the green area.
Design Description
Many alternatives were considered before we decided on our final design. Our
first ideas were to make an arm that would go down to keep the ball in front of
the robot, and to use a color sensor that detects the color of the ball and a light
sensor to follow the white line. We found those unsuitable for our robot
especially since the arm would block the ultrasonic sensor when it moves up or
down. Therefore, we made an arm that moves horizontally and grabs the ball
better than the original method. We also switched the color and light sensors for
more accurate detection.

Our final design is an efficient intelligent robot. We provided it with three sensors.
A color sensor for the detection of the white line, the yellow starting area and the
green finishing area. A light sensor which we calibrated to detect the red color of
the ball. An ultrasonic sensor to detect obstacles in front of the robot, this was
particularly helpful to escape dead ends. We also provided it with three motors.
Two motors were to move the wheels and one motor was used to open and close
the arm.
Sensors
1. Color sensor
We placed the color sensor facing downwards at the front of the robot. The job of
this sensor was to detect the colors under the robot which would ultimately guide
the robot on what actions to take. This is the code we wrote for the color sensor:
if strcmp(GetNXT2Color( SENSOR_3 ),'YELLOW')%if the color sensor detects
the color yellow the robot will start moving in a specific speed and a
specefic number of cycles
B.Power=50;
C.Power=50;
B.TachoLimit=360;
C.TachoLimit=360;
B.SendToNXT()
C.SendToNXT()
end

if strcmp(GetNXT2Color( SENSOR_3 ),'GREEN') %if the color is green the


robot will move a specific distance till its fully in the green part of the
maze then the motors will be turned off
B.Power=50;
C.Power=50;
B.TachoLimit=360;
C.TachoLimit=360;
B.SendToNXT()
C.SendToNXT()
B.Stop('off')
C.Stop('off')
B.SendToNXT()
C.SendToNXT()
k=k+1; %adding 1 to the variable k will cause the whole code to exit
from the while loop
if (strcmp( GetNXT2Color( SENSOR_3 ), 'WHITE'))
B.Power=10;
C.Power=20;
B.TachoLimit=0;
C.TachoLimit=0;
B.SendToNXT()
C.SendToNXT()

end
if (strcmp( GetNXT2Color( SENSOR_3 ), 'BLACK'))
B.Power=20;
C.Power=10;
B.TachoLimit=0;
C.TachoLimit=0;
B.SendToNXT()
C.SendToNXT()

end
2. Light Sensor
We placed the light sensor horizontally in front of the robot. We calibrated it to
detect the red color of the ball which leads the robot to take the appropriate
action based on the code provided to it. This is the code we wrote for the light
sensor:
if (GetLight( SENSOR_1 )>=400 && GetLight( SENSOR_1 )<=600)%if the lighht
sensor detects the color red which ranges from 400-600 motor A will cause the
hand of the motor to close
A.Power=20;
A.TachoLimit=120;
A.SendToNXT()
A.Stop('off')
CloseSensor(SENSOR_1)%for the light sensor to detect the red ball only
once we need to close it inside this if statement
end

3. Ultrasonic sensor
We placed the ultrasonic sensor above the slanted NXT brick. This sensor detects
any obstacles in front of it. We wrote the code in a way that when the robot is
faced by a wall it would turn right and left to check the distances in those
directions. It then chooses the path with the largest distance. This is the code we
wrote for the ultrasonic sensor:
while GetUltrasonic(SENSOR_4)<20 %while the ditance between the wall and the
is less than 20 the robot when move to the left first to check if the distance
if greater than 20, if not it will move to the right to check
B.Power=50;
B.TachoLimit=200;
C.Power=-50;
C.TachoLimit=200;
B.SendToNXT()
C.SendToNXT()
B.WaitFor()
C.WaitFor()
if GetUltrasonic(SENSOR_4)>=25 %if the distance is greater than 25 it will
exit the while loop
break;
end

C.Power=50;
B.Power=-50;
C.TachoLimit=590;
b.TachoLimit=590;
C.SendToNXT()
B.SendToNXT()
C.WaitFor()
B.WaitFor()
if GetUltrasonic(SENSOR_4)>=25
break
end
C.Power=50; % if the distance is still less than 20 it will take a
uturn from its first original place
C.TachoLimit=200;
B.Power=-50;
B.TachoLimit=200;
B.SendToNXT()
C.SendToNXT()
C.WaitFor()
B.WaitFor()
end

The MATLAB Code

COM_CloseNXT all
h=COM_OpenNXT();
COM_SetDefaultNXT(h)
k=0;%k is a variable to enter the while loop, k becomes 1 when the color
sensor detects the color green
B=NXTMotor('B');
C=NXTMotor('C');
A=NXTMotor('A');
OpenLight(SENSOR_1, 'ACTIVE')
OpenUltrasonic(SENSOR_4)
OpenNXT2Color( SENSOR_3, 'FULL' )
while k==0
pause(0.01)
if strcmp(GetNXT2Color( SENSOR_3 ),'YELLOW')%if the color sensor detects
the color yellow the robot will start moving in a specific speed and a
specefic number of cycles
B.Power=50;
C.Power=50;
B.TachoLimit=360;
C.TachoLimit=360;
B.SendToNXT()
C.SendToNXT()
end

if strcmp(GetNXT2Color( SENSOR_3 ),'GREEN') %if the color is green the


robot will move a specific distance till its fully in the green part of the
maze then the motors will be turned off
B.Power=50;
C.Power=50;
B.TachoLimit=360;
C.TachoLimit=360;
B.SendToNXT()
C.SendToNXT()
B.Stop('off')
C.Stop('off')
B.SendToNXT()
C.SendToNXT()
k=k+1; %adding 1 to the variable k will cause the whole code to exit
from the while loop
end

if (GetLight( SENSOR_1 )>=400 && GetLight( SENSOR_1 )<=600)%if the lighht


sensor detects the color red which ranges from 400-600 motor A will cause the
hand of the motor to close
A.Power=20;
A.TachoLimit=120;
A.SendToNXT()
A.Stop('off')
CloseSensor(SENSOR_1)%for the light sensor to detect the red ball only
once we need to close it inside this if statement
end

if GetUltrasonic(SENSOR_4) >=20 %if the distance between the robot and the
wall is greater than other equal to 20 is wil move in a zigzag method
depending on the color it detects whether its black or white
if (strcmp( GetNXT2Color( SENSOR_3 ), 'WHITE'))
B.Power=10;
C.Power=20;
B.TachoLimit=0;
C.TachoLimit=0;
B.SendToNXT()
C.SendToNXT()

end
if (strcmp( GetNXT2Color( SENSOR_3 ), 'BLACK'))
B.Power=20;
C.Power=10;
B.TachoLimit=0;
C.TachoLimit=0;
B.SendToNXT()
C.SendToNXT()

end

end
while GetUltrasonic(SENSOR_4)<20 %while the ditance between the wall and the
is less than 20 the robot when move to the left first to check if the distance
if greater than 20, if not it will move to the right to check
B.Power=50;
B.TachoLimit=200;
C.Power=-50;
C.TachoLimit=200;
B.SendToNXT()
C.SendToNXT()
B.WaitFor()
C.WaitFor()
if GetUltrasonic(SENSOR_4)>=25 %if the distance is greater than 25 it will
exit the while loop
break;
end

C.Power=50;
B.Power=-50;
C.TachoLimit=590;
b.TachoLimit=590;
C.SendToNXT()
B.SendToNXT()
C.WaitFor()
B.WaitFor()
if GetUltrasonic(SENSOR_4)>=25
break
end
C.Power=50; % if the distance is still less than 20 it will take a
uturn from its first original place
C.TachoLimit=200;
B.Power=-50;
B.TachoLimit=200;
B.SendToNXT()
C.SendToNXT()
C.WaitFor()
B.WaitFor()
end

end

Project Conclusion and Comments


Constructing a line following robot was a challenging exercise that tested our
MATLAB programming skills and building abilities. We concentrated on building a
very efficient design that performed the tasks required accurately. We also had to
write a working MATLAB code that would coordinate all the sensors and motors.
Despite being a challenging project, it was very helpful and educational. We
became more familiar with MATLAB and LEGO robots. If we could have done
anything differently, it would be to improve the construction of the robot to make
it more stable. Nevertheless, we are very pleased with our efforts over this past
month.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy