Cov txheej txheem:

Roomba Parking Pal: 6 Kauj Ruam
Roomba Parking Pal: 6 Kauj Ruam

Video: Roomba Parking Pal: 6 Kauj Ruam

Video: Roomba Parking Pal: 6 Kauj Ruam
Video: Temple Run: A day in the life of a Demon Monkey 2024, Kaum ib hlis
Anonim
Roomba Chaw Nres Tsheb Pal
Roomba Chaw Nres Tsheb Pal

Txoj haujlwm no siv iRobot Tsim programmable roomba, MATLAB r2018a, thiab MATLAB mobile. Hauv kev siv peb qhov nruab nrab no thiab peb qhov kev paub txog kev sau tus lej, peb tau teeb tsa iRobot Tsim los txhais cov xim thiab siv cov cim ntsuas ntawm lub nkoj kom ua tiav cov haujlwm. Cov haujlwm no nyob ntawm Raspberry Pi thiab MATLAB kev sib txuas lus los ua cov haujlwm no.

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv
Khoom siv
Khoom siv

1. iRobot Tsim Neeg Hlau

2. MATLAB r2018a

3. Raspberry Pi

4. Lub Koob Yees Duab Module

5. 3-D luam tawm Lub Koob Yees Duab Stabilizer Sawv

6. Smartphone nrog MATLAB mobile ntsia

7. Laptop/Computer nrog MATLAB teeb tsa

Kauj ruam 2: Kev sib txuas

Cov kauj ruam no yog hais txog kev txuas Raspberry Pi rau tus neeg hlau, thib ob txuas cov neeg hlau rau koj lub khoos phis tawj, thiab txuas lub xov tooj smartphone rau lub khoos phis tawj.

Qhov yooj yim tshaj plaws ntawm cov txheej txheem no yog txuas Raspberry Pi rau koj tus neeg hlau, txij li Raspberry Pi tau teeb tsa rau saum cov neeg hlau. Muaj ib txoj hlua los ntawm tus neeg hlau uas txhua yam koj yuav tsum ua yog ntsaws rau sab ntawm Raspberry Pi.

Cov kauj ruam tom ntej yog txuas tus neeg hlau rau koj lub khoos phis tawj kom koj tuaj yeem ua cov lus txib rau tus neeg hlau ua. Thawj qhov uas koj yuav tsum tau ua yog txuas koj lub khoos phis tawj rau lub wireless network uas koj chav nyob tau tsim. Tam sim no, nws raug nquahu kom koj siv Set Set icon hauv MATLAB los teeb tsa txoj hauv kev kom koj tuaj yeem siv cov haujlwm hauv Roomba toolbox los ntawm MATLAB. Txhua lub sijhawm koj tab tom pib thiab siv nrog tus neeg hlau, koj yuav tsum ua "Ob-Finger Salute" nyuaj rov kho lub neeg hlau, uas txhais tau tias koj tuav lub ntsaws thiab khawm cov nyees khawm rau kaum vib nas this kom txog thaum lub teeb pom kev qhia tias tso tawm. Koj tau ua tiav nrog qhov rov pib dua yog tias koj hnov tus neeg hlau ua haujlwm luv luv. Tom ntej no koj yuav tsum txuas mus rau chav nyob siv kab ntawm cov lej zoo li no "r = roomba (x)" qhov twg 'x' yog tus lej raug xaiv rau tus neeg hlau uas koj muaj.

Thaum kawg, koj yuav tsum rub tawm MATLAB mobile ntawm txhua lub xov tooj ntawm tes uas koj yuav siv rau txoj haujlwm no, thiab daim ntawv thov no muaj nyob ntawm ob qho tib si Android thiab Apple li. Thaum daim ntawv thov raug teeb tsa, koj yuav tsum nkag mus siv koj daim ntawv pov thawj. Tom qab ntawd koj yuav tsum txuas lub cuab yeej no rau koj lub khoos phis tawj, siv lub tab uas sau tias "Ntau" -> tom qab ntawd nyem "teeb tsa" -> tom qab ntawd nyem "Ntxiv lub computer" qhov no yuav tsum coj lub vijtsam pom hauv cov duab saum toj no. Tom qab koj pom qhov no Cov kauj ruam tom ntej uas koj yuav tsum hla mus tsuas yog ntsaws thiab chugging cov ntaub ntawv uas nws thov.

Kauj Ruam 3: Tsim Kom Tsim MATLAB Txoj Cai Siv Sensors

Logic Tsim MATLAB Code los Siv Cov Kws Paub
Logic Tsim MATLAB Code los Siv Cov Kws Paub

Txoj cai yuav yooj yim tshaj plaws los tsim thaum feem ntau ntawm nws nyob hauv lub voj, yog li ntawd roomba tuaj yeem hloov kho qhov txiaj ntsig tas li nws tab tom saib. Yog tias muaj qhov ua yuam kev, MATLAB yuav tso tawm qhov ua yuam kev thiab qhov twg nws tshwm nyob rau hauv txoj cai, ua kom daws teeb meem yooj yim dua.

Tsim nyob rau hauv r2018a MATLAB, cov cai no siv cov txheej txheem txheej txheem txheej txheem, iRobot Tsim cov cuab yeej, nrog rau MATLAB lub cuab yeej txawb. Roomba siv hauv qhov piv txwv no raug xaiv ua 26, thiab r = roomba (26) xav tau tsuas yog khiav ib zaug kom sib txuas lus zoo nrog chav nyob.

Txoj Cai:

muaj nuj nqi parkassist (x) yog x == 1

r = roomba (26) % txuas mus rau roomba

thaum muaj tseeb

r.setDriveVelocity (.05,.05) % teev roomba mus rau kev tsav tsheb qeeb qeeb

tsoo = r.getBumpers % tau txais cov ntaub ntawv los ntawm lub pob tsoo

cliff = r.getCliffSensors % tau txais cov ntaub ntawv los ntawm cov pob zeb sensors

lub teeb = r.getLightBumpers % tau txais cov ntaub ntawv los ntawm lub teeb tsoo lub teeb

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

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

green_mean = mean (mean (img (:,:, 2))) % nyeem qhov nruab nrab ntawm cov xim ntsuab

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

yog bump.front == 1 %nyeem pem hauv ntej lub pob sensor

r.stop %nres roomba

msgbox ('Path Obscured!', 'Parking Assistant Message') % qhia cov lus hais tias txoj hauv kev tsis pom kev tawg % xaus lub voj

elseif ntsuab_mean> 150

r.stop %nres roomba

cont = questdlg ('Mus ntxiv?', 'Txoj Kev Tiav') %qhia cov lus nug lub thawv nug kom txuas ntxiv

yog tias txuas ntxiv == 'Yog'

parkassist (1) %rov pib dua txoj cai

lwm tus

kawg

tawg % xaus lub voj

elseif red_mean> 140

r.turnAngle (45) %tig lub roomba 45 degrees

r.timeStart %pib lub sijhawm ntsuas

thaum muaj tseeb

r.setDriveVelocity (.05,.05) %teev qhov nrawm ntawm chav

sijhawm = r.timeGet %muab sijhawm rau qhov sib txawv

tsoo = r.getBumpers % tau txais cov ntaub ntawv los ntawm lub pob tsoo

cliff = r.getCliffSensors % tau txais cov ntaub ntawv los ntawm cov pob zeb sensors

lub teeb = r.getLightBumpers % tau txais cov ntaub ntawv los ntawm lub teeb tsoo lub teeb

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

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

green_mean = mean (mean (img (:,:, 2))) % nyeem qhov nruab nrab ntawm cov xim ntsuab

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

yog blue_mean> 120

r.moveDistance (-0.01) % txav lub roomba thim rov qab teeb tsa nkauj nrug PlayPlay (r, 'T400, C, D, E, F, G, A, B, C^', 'tseeb') % ua suab paj nruag nce ntxiv

msgbox ('Dej Pom!', 'Chaw Pab Chaw Nres Tsheb') % qhia cov lus hais tias tau pom dej r.turnAngle (-80) % tig chav nyob 80 degrees

so % xaus lub voj tam sim no

elseif light.rightFront> 25 || light.leftFront> 25 %nyeem lub teeb tsoo lub teeb

r.moveDistance (-0.01) % txav lub roomba rov qab teeb tsa nrug

r.turnAngle (-35) % tig lub roomba 35 degrees

so %xaus lub voj tam sim no

elseif cliff.rightFront <2500 && cliff.leftFront <2500 %nyeem ob lub pob zeb sensors

r.moveDistance (-0.1) % txav roomba rov qab teeb tsa nrug

r.turnAngle (-80) %tig roomba 80 degrees

tawg % xaus lub voj tam sim no

lwm lub sijhawm> = 3

r.stop %nres roomba

txuas ntxiv = questdlg ('Chaw Nres Tsheb Dawb, Mus Ntxiv?', 'Chaw Pabcuam Chaw Nres Tsheb') %nug yog tias chav nyob yuav tsum txuas ntxiv yog txuas ntxiv == 'Yog'

r.turnAngle (-90) % tig lub roomba 90 degrees

parkassist (1) %rov pib ua haujlwm

lwm tus

r.stop % nres lub roomba

kawg

lwm tus

kawg

kawg

elseif cliff.rightFront <2500 && cliff.leftFront <2500 %nyeem ob lub pob zeb sensors

r.moveDistance (-0.1) %txav roomba rov qab teeb tsa nrug

r.turnAngle (-90) %tig roomba 90 degrees

elseif cliff.rightFront <2500 %nyeem txoj cai cliff sensor

r.turnAngle (-5) %me ntsis tig lub roomba hauv qhov kev coj rov qab ntawm lub pob zeb sensor

elseif cliff.leftFront <2500 %nyeem sab laug pob tsuas sensor

r.turnAngle (5) %tig me me rau chav nyob hauv qhov kev coj rov qab ntawm lub pob zeb sensor

lwm tus

kawg

kawg

kawg

Kauj Ruam 4: Xeem Txoj Cai thiab Neeg Hlau

Xeem Txoj Cai thiab Neeg Hlau
Xeem Txoj Cai thiab Neeg Hlau
Xeem Txoj Cai thiab Neeg Hlau
Xeem Txoj Cai thiab Neeg Hlau
Xeem Txoj Cai thiab Neeg Hlau
Xeem Txoj Cai thiab Neeg Hlau

Tom qab tsim txoj cai, cov kauj ruam tom ntej yog los ntsuas cov cai thiab cov neeg hlau. Txij li muaj ntau qhov kev hloov pauv sib txawv uas tuaj yeem ua rau hauv txoj cai, xws li lub kaum ntse ntse neeg hlau tig, qhov nrawm nws txav mus, thiab qhov pib rau txhua xim, txoj hauv kev zoo tshaj los xam cov txiaj ntsig no rau koj tus neeg hlau yog sim lawv thiab hloov pauv thaum koj mus. Rau txhua hnub ua haujlwm peb muaj, peb tau hloov pauv cov txiaj ntsig no tas li vim qee qhov ntawm lawv vam khom ib puag ncig uas koj tus neeg hlau ua haujlwm. teeb meem siab txaus kom lub koob yees duab tsis tuaj yeem pom cov xim uas koj tsis xav kom nws ua. Cov kauj ruam tom ntej yog cia nws khiav thiab qhia nws cov xim uas koj xav tau, thaum koj xav kom nws ua tiav txoj haujlwm ntawd. Thaum koj mus, yog tias koj pom qhov teeb meem qhov zoo tshaj plaws uas yuav tsum tau ua yog thawb lub hauv paus hauv ntej, ua kom nws nres, tom qab ntawd hloov qhov ntsuas uas koj muaj teeb meem nrog.

Kauj Ruam 5: Paub txog Qhov Yuam Kev

Nrog txhua qhov haujlwm tau ua tiav, ib txwm muaj qhov ua yuam kev. Rau peb, peb tau ntsib kev ua yuam kev nrog qhov tseeb yooj yim uas neeg hlau tsis meej nrog lub kaum sab xis uas nws tig, yog li yog koj qhia nws tig 45 degrees nws yuav tsis yog qhov tseeb. Lwm qhov ntawm qhov ua yuam kev rau peb yog tias qee zaum cov neeg ua haujlwm tsis ua haujlwm, thiab koj tau rov pib dua nws ua ntej nws rov ua haujlwm dua. Lub hauv paus tseem ceeb kawg ntawm kev ua yuam kev rau peb yog tias tib txoj cai yuav tsis muaj qhov cuam tshuam zoo ib yam rau cov neeg hlau sib txawv, yog li koj yuav tsum ua siab ntev nrog nws thiab kho kom haum.

Kauj Ruam 6: Xaus

Tam sim no koj muaj txhua yam cuab yeej los ua si ib puag ncig nrog koj chav nyob, uas txhais tau tias koj tuaj yeem siv cov cai hauv ib qho twg koj xav kom ua tiav lub hom phiaj koj xav tau. Qhov no yuav tsum yog qhov zoo tshaj plaws ntawm koj hnub, yog li muaj kev lom zem thiab tsav tsheb nyab xeeb!

Pom zoo: