Cov txheej txheem:

Mars Roomba Project UTK: 4 Kauj Ruam
Mars Roomba Project UTK: 4 Kauj Ruam

Video: Mars Roomba Project UTK: 4 Kauj Ruam

Video: Mars Roomba Project UTK: 4 Kauj Ruam
Video: Домино Робот с Мировым Рекордом (100k домино за 24 часа) 2024, Hlis ntuj nqeg
Anonim
Mars Roomba Project UTK
Mars Roomba Project UTK
Mars Roomba Project UTK
Mars Roomba Project UTK

DISCLAIMER: Qhov no tsuas yog ua haujlwm yog tias ROOMBA tau teeb tsa hauv A.

Txoj kev tshwj xeeb heev, Cov lus qhia no tau tsim los rau thiab xav kom raug siv los ntawm UNIVERSITY TENNESSEE Cov Tub Ntxhais Kawm thiab Ua Haujlwm

Txoj cai no tau siv los teeb tsa Roomba los sau cov npe hauv zos thiab khaws cov cai hauv MATLAB. Qhov no yuav tsis ua haujlwm yog tias koj tsis tuaj yeem tau txais cov tsev qiv ntawv tsim nyog los ntawm University of Tennessee lub vev xaib. Yog tias koj muaj cov tsev qiv ntawv koj tuaj yeem siv lawv los ua haujlwm rau koj tus kheej Roomba siv cov haujlwm hauv lub tsev qiv ntawv. Cov Lus Qhia no qhia koj yuav ua li cas rau nruab cov tsev qiv ntawv, tsim cov ntawv tais ceev tseg rau txhua tus lej, thiab yuav ua li cas rau tus lej thiab siv cov haujlwm peb tau muab rau hauv qab no.

Cov Ntaub Ntawv Yuav Tsum Tau:

· Roob

· MATLAB

· Raspberry Pi thiab Pi Lub Koob Yees Duab

Kauj ruam 1: Tau txais Cov Tsev Qiv Ntawv

Ntawm lub vev xaib engineering muaj lub thawv ntawv/tsev qiv ntawv muab, rub tawm nws thiab muab tso rau hauv daim nplaub tshev tshiab. Lub nplaub tshev no yuav tsum muaj txhua qhov haujlwm ua haujlwm cov ntaub ntawv raws li, txhua txoj haujlwm siv hauv qhov haujlwm koj ua yuav xav tau xa mus rau lub tsev qiv ntawv. Tom qab koj ua tiav qhov no koj tuaj yeem pib ua haujlwm ntawm koj cov haujlwm

Kauj Ruam 2: Sau Cov Kev Kawm

Muaj ob peb lub luag haujlwm uas tuaj yeem siv rau hauv txoj haujlwm, cov haujlwm no tuaj yeem nkag los ntawm kev siv cov lus txib "doc roomba". Siv cov haujlwm no, koj tuaj yeem tswj hwm koj Roomba ntau txoj hauv kev sib txawv. Cov cai tau muab hauv qab no siv lub ntsuas qhov taub, lub teeb pom lub teeb pom kev zoo, lub koob yees duab, thiab cov pob zeb ntsuas hauv ntau txoj hauv kev los tsim mars rover. Peb tau siv lub ntsuas qhov ntsuas kom pom thaum Roomba tsoo ib yam khoom, thaum qhov no tshwm sim tus neeg hlau yuav thim rov qab, tig ib ncig, thiab txav mus ntxiv. Ua ntej Roomba tsoo ib yam khoom, lub teeb pom kev yuav pom cov khoom thiab ua rau Roomba qeeb kom thaum ntawd nws tsoo rau hauv qhov khoom kom qhib lub pob tsoo lub Roomba yuav tsis puas/cuam tshuam los ntawm kev cuam tshuam. Lub koob yees duab tshawb nrhiav dej lossis lava saum npoo av, yog tias tsis muaj cov kua pom tom qab ntawd tus neeg hlau yuav tshawb nrhiav txuas ntxiv, yog tias muaj qee qhov dej pom tom qab ntawd tus neeg hlau yuav xa xov mus rau tus tswv. Cliff sensors tau tsim los txwv tus neeg hlau yog tias nws mus rau ntawm lub pob tsuas. Yog tias tus neeg hlau hnov lub pob tsuas nws yuav rov qab thiab tig rov los kom tsis txhob poob.

Kauj ruam 3: Code

Luam thiab muab qhov no tso rau hauv MATLAB cov ntaub ntawv uas nyob hauv tib lub nplaub tshev zoo li lub tsev qiv ntawv

functionMainRoombaFile (r)

r.setDriveVelocity (0.1, 0.1)

thaum muaj tseeb % Infinte thaum lub voj kom cov cai ua haujlwm

dontFall = cliffCheck (r) % Muab qhov sib txawv 'dontFall' rau txoj haujlwm 'cliffCheck'

yog dontFall % yog cov lus hais kom ua hauv cov cai tom qab 'cliffCheck' ua tiav

r.setDriveVelocity (0.1, 0.1) % Khaws Roomba txav mus tom qab 'cliffCheck' tiav

kawg % xaus 'dontFall' yog nqe lus

bumper = bumpcheck (r) % Muab qhov sib txawv 'bumper' rau txoj haujlwm 'bumpcheck'

yog tias bumper % yog cov lus hais kom ua hauv cov cai tom qab 'bumpcheck' ua tiav

r.setDriveVelocity (0.1, 0.1) % Khaws Roomba txav mus tom qab 'bumpcheck' tiav

kawg % xaus 'bumper' yog nqe lus

kua = LiquidCheck (r) % Ua haujlwm sib txawv 'kua' rau txoj haujlwm 'LiquidCheck'

yog tias cov dej % yog cov lus hais los ua hauv cov cai tom qab 'LiquidCheck' ua tiav

r.setDriveVelocity (0.1, 0.1) % Khaws Roomba txav tom qab 'LiquidCheck' ua tiav

kawg % xaus 'kua' yog hais tawm

lightbumper = lightcheck (r) % Muab qhov sib txawv 'lightbumper' rau txoj haujlwm 'lightcheck'

ncua (0.1) % Ncua ntu luv luv kom tsis txhob rov ua dua lub voj

kawg % xaus infinite thaum lub voj

kawg % xaus kev ua haujlwm

muaj nuj nqi bumper = bumpcheck (r) % Tsim kom muaj 'bumpcheck' muaj nuj nqi

bumpdata = r.getBumpers % Muab tag nrho cov ntaub ntawv los ntawm lub bumper mus rau qhov sib txawv 'bumpdata'

bumper = bumpdata.right || bumpdata.left || bumpdata.front % Tsim kom muaj qhov sib txawv khaws cia, 'bumper', rau qhov sib tsoo sib txawv

yog bumpdata.right> 0 % Yog cov lus hais los ua qhov sib txawv ntawm chav nyob kom tshwm sim yog tias Bumper raug tsoo

r.stop % Nres Roomba

r.moveDistance (-0.3, 0.2) % Rov Qab Roomba 0.3m

r.turnAngle (90, 0.5) % Tig Roomba 90 degrees kom nrawm li sai tau

kawg

yog bumpdata.front> 0

r.stop

r.moveDistance (-0.3, 0.2)

r.turnAngle (randi (270), 0.5) % Rotates Roomba ntawm lub sijhawm sib txawv ntawm 0 thiab 270 degrees kom nrawm li sai tau

kawg

yog bumpdata.left> 0

r.stop

r.moveDistance (-0.3, 0.2)

r.turnAngle (-90, 0.5) % Tig Roomba -90 degrees kom nrawm li sai tau

kawg

kawg

muaj nuj nqi lightbumper = lightcheck (r) % Tsim 'lightcheck' ua haujlwm

lightdata = r.getLightBumpers % Muab tag nrho cov ntaub ntawv los ntawm lub teeb tsoo lub teeb rau qhov sib txawv 'lightdata'

lightbumper = lightdata.left || cov ntaub ntawv.right || lightdata.rightCenter || lightdata.leftCenter % Tsim kom muaj qhov sib txawv khaws cia, 'lightbumper', rau lub teeb sib txawv

yog lightbumper % Yog cov lus hais kom hu cov ntaub ntawv lightbumper los ntawm saum toj no

yog lightdata.left> 10 % Yog cov lus hais kom ua haujlwm sib txawv ntawm chav nyob kom tshwm sim yog tias lub teeb ci ntsa iab hnov ntau dua 10 qhov tseem ceeb

r.setDriveVelocity (0.05, 0.05) % Ua rau qeeb hauv chav los npaj rau tsoo

kawg % xaus qhov pib yog nqe lus

yog lightdata.rightCenter> 10

r.setDriveVelocity (0.05, 0.05)

kawg

yog lightdata.right> 10

r.setDriveVelocity (0.05, 0.05)

kawg

yog lightdata.leftCenter> 10

r.setDriveVelocity (0.05, 0.05)

kawg

kawg % xaus 'lightbumper' yog nqe lus

kawg %xaus kev teeb pom kev zoo

muaj nuj nqi dontFall = cliffCheck (r) % Tsim 'cliffCheck' muaj nuj nqi

cov ntaub ntawv = r.getCliffSensors; % Muab tag nrho cov ntaub ntawv los ntawm lub pob zeb sensor mus rau qhov sib txawv 'cov ntaub ntawv'

dontFall = data.left <1020 || data.leftFront <1020 || data.rightFront <1020 || data.right <1020 % Tsim kom muaj qhov sib txawv khaws cia, 'dontFall', rau qhov sib txawv ntawm cov pob tsuas

yog dontFall % Yog hais tias nqe lus hu rau pob tsuas sensor cov ntaub ntawv los ntawm saum toj no

yog data.left <1010 % Yog cov lus hais los ua kom lub luag haujlwm sib txawv ntawm chav nyob tshwm sim yog tias lub pob zeb sensor hnov qhov tsawg dua 1010 qhov tseem ceeb

r.stop

r.moveDistance (-0.2, 0.2) % Rov Qab Roomba 0.2m

r.turnAngle (-90, 0.5) % Tig Roomba -90 degrees kom nrawm li sai tau

elseif data.leftFront <1010

r.stop

r.moveDistance (-0.3, 0.2)

r.turnAngle (90, 0.5) % Tig Roomba 90 degrees kom nrawm li sai tau

elseif data.rightFront <1010

r.stop

r.moveDistance (-0.3, 0.2)

r.turnAngle (90, 0.5) % Tig Roomba 90 degrees kom nrawm li sai tau

elseif data.right <1010

r.stop

r.moveDistance (-0.3, 0.2)

r.turnAngle (90, 0.5) % Tig Roomba 90 degrees kom nrawm li sai tau

kawg

kawg

kawg

ua kua = LiquidCheck (r) % Tsim 'LiquidCheck' ua haujlwm

thaum qhov tseeb %pib tsis muaj qhov kawg rau kev ntsuas

img = r.getImage; % nyeem lub koob yees duab tawm ntawm tus neeg hlau

duab (img) % qhia cov duab hauv daim duab qhov rai

red_mean = mean (mean (img (200, 150, 1)))%% nyeem qhov nruab nrab ntawm cov liab liab

blue_mean = mean (mean (img (200, 150, 3)))%% nyeem qhov nruab nrab ntawm cov xim xiav

kua = red_mean || blue_mean % Tsim qhov khaws cia sib txawv, 'kua', rau qhov sib txawv xim sib txawv

yog kua % Yog cov lus hais kom hu cov ntaub ntawv duab los saum toj no

yog red_mean> 170 % Yog cov lus hais los ua kom lub luag haujlwm sib txawv ntawm chav nyob tshwm sim yog tias lub koob yees duab pom lub ntsiab lus liab ntau dua 170

r.stop % nres roomba

r.setLEDCenterColor (255) % teev lub voj voog rau xim liab

r.setLEDDigits (); % tshem tawm cov zaub

f = waitbar (0, '*XOV XWM TSHIAB*'); % tsim qhov tos tos rau cov lus xa tawm

r.setLEDDigits ('HOT'); % teeb tsa LED tso tawm rau 'HOT'

ncua (0.5) %Luv luv rau nyeem cov ntaub ntawv xa tawm

r.setLEDDigits ('LAVA'); % teeb tsa LED tso tawm kom pom 'LAVA'

ncua (0.5)

waitbar (.33, f, '*XOV XWM TSHIAB*'); %tsim kev nce hauv qhov tos tos

r.setLEDDigits ('HOT');

ncua (0.5)

r.setLEDDigits ('LAVA');

ncua (0.5)

waitbar (.67, f, '*XOV XWM TSHIAB*'); % tsim kev nce hauv qhov tos tos

r.setLEDDigits ('HOT');

ncua (0.5)

r.setLEDDigits ('LAVA');

waitbar (1, f, '*XOV XWM TSHIAB*'); %ua tiav qhov tos tos

ncua (1)

kaw (f) %kaw qhov tos tos

r.setLEDDigits (); % tshem tawm cov zaub LED

kaw tag nrho %Kaw tag nrho lub qhov rais dhau los

axes ('Xim', 'tsis muaj', 'XColor', 'tsis muaj', 'YColor', 'tsis muaj') % Tshem cov phiaj xwm qhov rai ntawm cov kab thiab daim duab

y = 0.5; % teeb tsa y-txoj haujlwm ntawm cov ntawv hauv qhov phiaj xwm qhov rai

x = 0.06; % teeb tsa x-txoj haujlwm ntawm cov ntawv hauv qhov phiaj xwm qhov rai

title ('LOS NTAWM MARS ROOMBA', 'fontsize', 32) % Ntxiv ib lub npe rau lub qhov rais phiaj xwm

quadeqtxt = 'DANGER LAVA'; % Poob qhov sib txawv 'quadeqtxt' rau cov zis 0

ntawv (x, y, quadeqtxt, 'txhais lus', 'latex', 'fontsize', 36); % qhia cov ntawv quadeq hauv lub qhov rai phiaj xwm

r.moveDistance (-0.2, 0.2) %thim rov qab roomba 0.2m

r.turnAngle (180, 0.5) %tig lub roomba 180 degrees kom nrawm li sai tau

r.setLEDCenterColor (128, 128); % teeb tsa chav nyob nruab nrab ntawm LED rau txiv kab ntxwv

kaw tag nrho %kaw qhov qhib qhov rai ntxiv

elseif blue_mean> 175 % Yog cov lus hais kom ua haujlwm sib txawv ntawm chav nyob kom tshwm sim yog tias lub koob yees duab pom lub ntsiab lus xiav ntau dua 175

r.stop % nres roomba

r.setLEDCenterColor (255) % teev lub voj voog rau xim liab

r.setLEDDigits (); % tshem tawm cov zaub

f = waitbar (0, '*XOV XWM TSHIAB*'); % tsim qhov tos tos rau cov lus xa tawm

r.setLEDDigits ('LOOK'); % teeb tsa LED tso tawm kom pom 'LOOK'

ncua (0.5) %Luv luv rau nyeem cov ntaub ntawv xa tawm

r.setLEDDigits ('WATR'); % teeb tsa LED tso tawm kom pom 'WATR'

ncua (0.5)

waitbar (.33, f, '*XOV XWM TSHIAB*'); %tsim kev nce hauv qhov tos tos

r.setLEDDigits ('LOOK');

ncua (0.5)

r.setLEDDigits ('WATR');

ncua (0.5)

waitbar (.67, f, '*XOV XWM TSHIAB*'); % tsim kev nce hauv qhov tos tos

r.setLEDDigits ('LOOK');

ncua (0.5)

r.setLEDDigits ('WATR');

waitbar (1, f, '*XOV XWM TSHIAB*'); %ua tiav qhov tos tos

ncua (1)

kaw (f) %kaw qhov tos tos

r.setLEDDigits (); % tshem tawm cov zaub LED

kaw tag nrho %Kaw tag nrho lub qhov rais dhau los

axes ('Xim', 'tsis muaj', 'XColor', 'tsis muaj', 'YColor', 'tsis muaj') % Tshem cov phiaj xwm qhov rai ntawm cov kab thiab daim duab

y = 0.5; % teeb tsa y-txoj haujlwm ntawm cov ntawv hauv qhov phiaj xwm qhov rai

x = 0.06; % teeb tsa x-txoj haujlwm ntawm cov ntawv hauv qhov phiaj xwm qhov rai

title ('LOS NTAWM MARS ROOMBA', 'fontsize', 32) % Ntxiv lub npe rau lub qhov rais phiaj xwm

quadeqtxt = 'FOUND WATER'; % Poob qhov sib txawv 'quadeqtxt' rau cov zis 0

ntawv (x, y, quadeqtxt, 'txhais lus', 'latex', 'fontsize', 36); % qhia cov ntawv quadeq hauv lub qhov rai phiaj xwm

r.moveDistance (-0.2, 0.2) %thim rov qab roomba 0.2m

r.turnAngle (180, 0.5) %tig lub roomba 180 degrees kom nrawm li sai tau

r.setLEDCenterColor (128, 128); % teeb tsa chav nyob nruab nrab ntawm LED rau txiv kab ntxwv

kaw tag nrho %kaw qhov qhib qhov rai ntxiv

kawg %xaus 'red_mean' yog nqe lus

kawg %xaus 'kua' yog hais tawm

kawg % kaw qhov tsis muaj qhov kawg thaum lub voj

kawg % xaus kev ua haujlwm 'LiquidCheck'

Kauj ruam 4: Khiav Txoj Cai

Tom qab koj tau theej thiab muab cov chaws tso rau hauv MATLAB koj yuav tsum txuas mus rau Roomba. Thaum Roomba txuas nrog koj yuav tsum sau lub npe sib txawv r. Cov haujlwm siv qhov sib txawv r thaum hais txog Roomba, yog li Roomba yuav tsum tau txhais raws li qhov sib txawv r. Tom qab khiav txoj cai Roomba yuav tsum khiav raws li qhia.

Pom zoo: