(Project) Maze Navigator Robot System

June 9, 2017 | Autor: Emma AL Qawasmi | Categoria: Robotics, Matlab Programming, Lego MindStorms NXT
Share Embed


Descrição do Produto










ENGR112: Final Project
Fall 2012

ENGR112: Final Project ReportFall 2012Maze Navigator Robot SystemDana Bazazeh 100038654
Eman Al Qawasmi 100038650Fatima AlHarmoodi 100038231ENGR112: Final Project ReportFall 2012Maze Navigator Robot SystemDana Bazazeh 100038654
Eman Al Qawasmi 100038650Fatima AlHarmoodi 100038231

ENGR112: Final Project Report
Fall 2012
Maze Navigator Robot System




Dana Bazazeh 100038654
Eman Al Qawasmi 100038650
Fatima AlHarmoodi 100038231

ENGR112: Final Project Report
Fall 2012
Maze Navigator Robot System




Dana Bazazeh 100038654
Eman Al Qawasmi 100038650
Fatima AlHarmoodi 100038231



Problem Definition

Objectives:
Build and design a robot used to function as a maze navigator using the NXT Legomindstormers 9797 kit.
The robot should be able to avoid obstacles placed in its path.
The robot should be able to detect the presence of a ball placed randomly in the maze by playing a sound and then pushing the ball until the end of the maze.
A graph should be plotted using Matlab showing the path taken by the robot.
The robot should be completely autonomous without any human intervention.

Constraints:
The robot should not have a height that exceeds 25 cm
The robot should not have a length that exceeds 30cm
The robot should not have a width that exceeds 40cm
You must only use an Ultrasonic sensor and a Light sensor, any other sensor is not needed.
The robot must be designed to navigate through any maze, and not just the one stated.


BEGINBEGINProgram Design:
BEGIN
BEGIN

FalseFalseTrueTruePlay SoundPlay Sounda>400a>400Take (a) Light sensor readingTake (a) Light sensor readingd rightPlot GraphPlot GraphFalseFalseTrueTrueSave Max DistanceSave Max DistanceSave Max DistanceSave Max DistanceTurn LeftTurn LeftTurn RightTurn RightStop RobotStop RobotCheck 180 spanCheck 180 spanMove ForwardMove ForwardREPEATREPEAT

False
False
True
True
Play Sound
Play Sound
a>400
a>400
Take (a) Light sensor reading
Take (a) Light sensor reading
d right
Plot Graph
Plot Graph
False
False
True
True
Save Max Distance
Save Max Distance
Save Max Distance
Save Max Distance
Turn Left
Turn Left
Turn Right
Turn Right
Stop Robot
Stop Robot
Check 180 span
Check 180 span
Move Forward
Move Forward
REPEAT
REPEAT

Physical Design and Implementation
The main goal of the project is to plan, assemble, program and test an independent robot that will navigate through a jumble of interconnecting pathways to find its way out. The robot has been programed using MatLab language to avoid any obstacles and any pathway blockages. This will occur via the help of an Ultrasound sensor, which is fitted at the top of the robot.

Three motors were used to bring together this robot. One of them has been used and placed in a horizontal position to rotate the Ultrasound sensor in order to enable it to detect any obstacles ahead as well as rotate on a span of 180 degrees to find the furthest path from the obstacle. The other two motors are secured in to rotate two wheels in which they shall be used to bring about movement to the robot, whether it would move forwards, backwards, turn left or turn right. The motors are then connected via wires to a power source of four A4-sized batteries which act as the body of the robot.

To complete the second task of detecting and clamping the ball, an open sided cage is built in front to capture the ball and in between it, a color sensor has been associated so that it would act well for the purpose of detecting the ball and so that the cage does not block the sensor. In order to know when the ball has been located, a code has been written using MatLab enabling the sensor to play a sound, something like a low "beep". This would then inform us that the ball has been found.



Complete Program

COM_CloseNXT all
hNXT = COM_OpenNXT();
COM_SetDefaultNXT(hNXT);
%SetHandle and open connection


%Declare Variables needed
cnt1=0;
x=[]; %Array of x and y for saving the maximum distance and plotting the graph of path taken
y=[];
x(1)=0; %Set the initial x and y at coordinates (0,0)
y(1)=0;
i =2;

forward =NXTMotor([MOTOR_B; MOTOR_C]);

while true %Infinity loop


if (cnt1==0) %Save the first Ultrasonic reading (maximum value) to use for plot.

OpenUltrasonic(SENSOR_4);
Pause(0.5)
v = GetUltrasonic(SENSOR_4);
CloseSensor(SENSOR_4);

x(i) = 0;
y(i)= v;

i=i+1;

cnt1= cnt1+1;

end


Forward(); %Move Forward while getting Ultrasonic reading

OpenUltrasonic(SENSOR_4);
pause(0.1);
d = GetUltrasonic(SENSOR_4);
CloseSensor(SENSOR_4);


OpenLight(SENSOR_3, 'ACTIVE'); %Get light reading and save it as b
pause(0.5);
b= GetLight(SENSOR_3);
disp(b);



if b>400 %condition to detect red ball

NXT_PlayTone(600, 500); %play sound
CloseSensor(SENSOR_3);

end


if ddright %Compare which side is the furthest away

TurnLeft();

OpenUltrasonic(SENSOR_4);
pause(0.1);
a = GetUltrasonic(SENSOR_4);
CloseSensor(SENSOR_4);

if (i==3) %For the first turn, plot the points

y(i) = y(i-1);
x(i) = x(i-1) - a;
turn = 0; %0 means it made a left turn

end



if((rem(i,2)==0) & i~= 3) %If the itteration is even

x(i) = x(i-1); % movement is vertical.

if(turn==0) %if previous turn taken was left, the line moves vertically downwards

y(i)=y(i-1)-a;
turn = 0;

else %if previous turn taken was right, the line moves vertically upwards

y(i) = y(i-1)+a;
turn = 0;

end

end


if((rem(i,2)~=0) & i~= 3) %if itteration is odd

y(i) = y(i-1); %y is the same as the previous point, movement is horizontal.

if(turn==0)

x(i)=x(i-1)+a; %if previous turn taken was left, the line moves horizontally to the right
turn = 0;

else

x(i)= x(i-1)-a; %if previous turn taken was right, the line moves horizontally to the left

turn = 0;

end

end



else
TurnRight();

OpenUltrasonic(SENSOR_4);
pause(0.1);
a = GetUltrasonic(SENSOR_4);

CloseSensor(SENSOR_4);

if (i==3) % only for the first turn, plot the points using this formula.
y(i) = y(i-1);
x(i) = x(i-1) + a;

turn = 1;


end



if((rem(i,2)==0) & i~= 3) %if even

x(i) = x(i-1); %x is the same as the previous point, movement is vertical.

if(turn==0)

y(i)=y(i-1)+a;
turn = 1;

else
y(i) = y(i-1)-a;
turn = 1;

end

end


if((rem(i,2)~=0) & i~= 3)

y(i) = y(i-1); %y is the same as the previous point, movement is horizontal.

if(turn==0)

x(i)=x(i-1)-a; %if previous turn taken was left, the line moves horizontally to the left
turn = 1;

else
x(i)= x(i-1)+a; %if previous turn taken was right, the line moves horizontally to the right
turn = 1;

end

end



end


plot(x,y)
axis equal; % to make the ratio of horizontal and vertical distance the same
i=i+1;

end

end %end of the while loop




COM_CloseNXT all % Close all connections


User-Defined Functions

function [] = TurnRight()

lwheel = NXTMotor(MOTOR_B);
rwheel = NXTMotor(MOTOR_C);

lwheel.Power= 15;
rwheel.Power= -15;

lwheel.TachoLimit = 297;
rwheel.TachoLimit = 297;

lwheel.ActionAtTachoLimit = 'brake';
rwheel.ActionAtTachoLimit = 'brake';


lwheel.SendToNXT();
rwheel.SendToNXT();

lwheel.WaitFor();
rwheel.WaitFor();
end

function [] = TurnLeft( )

lwheel = NXTMotor(MOTOR_B);
rwheel = NXTMotor(MOTOR_C);

lwheel.Power= -15;
rwheel.Power= 15;

lwheel.TachoLimit = 297;
rwheel.TachoLimit = 297; %340 on rug

lwheel.ActionAtTachoLimit = 'brake';
rwheel.ActionAtTachoLimit = 'brake';

lwheel.SendToNXT();
rwheel.SendToNXT();

lwheel.WaitFor();
rwheel.WaitFor();

end




function [] = Forward( )

forward =NXTMotor([MOTOR_B; MOTOR_C]);

forward.Power = 30;

forward.SendToNXT();

end



Code Structure
Note: These functions do not have any input or output arguments.
Function
Description
Forward( )
Moves motor B and motor C in the same direction forward with a power of 30.
TurnLeft( )
Moves motor B and motor C in opposite direction with a tacholimit of 297 and a power of 15 and -15 respectively causing the robot to turn to the left.
TurnRight( )
Moves motor C and motor B in opposite direction with a tacholimit of 297 and a power of 15 and -15 respectively causing the robot to turn to the right.

Pre-trial Results


First Set of Trials:
During the first trials, we encountered a number of problems:
The length of the robot was too long compared with the space given when turning corners in the maze.
The robot did not turn a perfect 90 degrees but rather around 80 degrees when turning left and right due to the friction present in the ground material used in the maze.
The data collected from the light sensor kept varying even without the presence of a colored ball.
The final graph drawn was not similar to the path taken by the robot.

Fixing the errors:
We removed some long rods from the robot to make it shorter. In order to attain a perfect 90 degree rotation, we increased the tacho-limit when turning left or right from a value of 270 to 340 for both motors, A and B. For the graph, we have identified a logical error that was made when the program was written and this is why the graph seemed unusual.

Second Set of Trials:
In our second trial, after having fixed most of the errors found on the first trial, we were successful in navigating through the maze and plotting a graph of the path taken. Unfortunately, there remained one error which was the inaccuracy of the light sensor.
We decided to create a condition to detect the ball which needed an extremely high light sensor reading to validate it and thus the ball needs to be very close to the light sensor in order for it to be detected.

Limitations
The tacho-limit value for turning needs to be altered depending on the material of the floor it moves on. A rougher floor needs a larger value for tacho-limit.
The critical value from the light sensor indicating the detection of the ball should be altered depending on the room lighting and the color of the maze walls.

Conclusion
After altering the robots physical design as well as the program's design a couple of times, we achieved the goals set. The robot was able to go through the maze without hitting any obstacles a number of times, although at times, the friction between the wheels and the rough floor led the robot to turn slightly off course. In addition, by initializing low power to the motors which are rotating the wheels, we were able to keep the red ball inside the cage at all times. Finally, the path graph was correctly plotted.

Lihat lebih banyak...

Comentários

Copyright © 2017 DADOSPDF Inc.