Cov txheej txheem:

MATLAB Tswj Roomba: 5 Kauj Ruam
MATLAB Tswj Roomba: 5 Kauj Ruam
Anonim
MATLAB Tswj Roomba
MATLAB Tswj Roomba
MATLAB Tswj Roomba
MATLAB Tswj Roomba

Lub hom phiaj ntawm txoj haujlwm no yog siv MATLAB nrog rau kev hloov kho iRobot programmable neeg hlau. Peb pab pawg sib koom ua ke peb cov txuj ci txhawm rau txhawm rau tsim MATLAB tsab ntawv uas siv ntau lub zog ntawm iRobot, suav nrog lub pob zeb sensor, lub hauv siab, lub teeb pom kev zoo, thiab lub koob yees duab. Peb siv cov ntsuas no thiab lub koob yees duab nyeem ua cov tswv yim, tso cai rau peb los tsim qee qhov kev tso tawm uas peb xav tau siv MATLAB cov lej ua haujlwm thiab lub voj. Peb kuj tseem siv MATLAB cov cuab yeej siv xov tooj cua thiab ntsuas lub ntsej muag ua txoj hauv kev txuas rau iRobot thiab tswj nws.

Kauj Ruam 1: Cov Khoom thiab Cov Khoom

Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom
Cov Khoom thiab Cov Khoom

MATLAB 2018 a

-Cov 2018 version ntawm MATLAB yog qhov nyiam tshaj plaws, feem ntau vim nws ua haujlwm tau zoo tshaj plaws nrog cov cai uas txuas rau lub xov tooj ntawm tes. Txawm li cas los xij, feem ntau ntawm peb cov lej tuaj yeem txhais tau hauv feem ntau ntawm MATLAB cov qauv.

iRobot Tsim Device

-Qhov cuab yeej no yog lub cuab yeej tshwj xeeb uas yog lub hom phiaj nkaus xwb yog rau kev ua haujlwm thiab cim npe. (Nws tsis yog lub tshuab nqus tsev tiag)

Raspberry Pi (nrog lub koob yees duab)

- Nov yog lub khoos phis tawj tsis kim uas ua haujlwm zoo li lub hlwb ntawm iRobot. Nws yuav yog me me, tab sis muaj peev xwm ua tau ntau yam. Lub koob yees duab yog ib qho ntxiv ntxiv rau. Nws kuj tseem siv raspberry pi kom tau txais tag nrho nws cov haujlwm thiab cov lus txib. Lub koob yees duab daim duab saum toj no tau teeb tsa ntawm lub tshuab luam ntawv 3D, tsim los ntawm Engineering Cov Txheej Txheem Kev Ua Haujlwm ntawm Tsev Kawm Qib Siab Tennessee

Kauj ruam 2: Roomba Database File

Roomba Database Cov Ntaub Ntawv
Roomba Database Cov Ntaub Ntawv

Muaj cov ntaub ntawv tseem ceeb uas koj yuav xav tau txhawm rau siv lub luag haujlwm thiab cov lus txib kom raug rau koj chav nyob. Cov ntaub ntawv no yog qhov uas koj sau cov cai coj los ua haujlwm los txhawm rau ua haujlwm koj chav nyob ntau dua.

Koj tuaj yeem rub tawm cov ntawv ntawm qhov txuas no lossis rub tawm cov ntawv hauv qab no

ef.engr.utk.edu/ef230-2017-08/projects/roomba-s/setup-roomba-instructable.php

Kauj ruam 3: Txuas mus rau Roomba

Ua ntej, koj yuav tsum ua kom ntseeg tau tias koj lub neeg hlau txuas nrog koj lub raspberry pi board los ntawm kev siv lub micro USB ntsaws. Tom qab ntawd koj yuav tsum txuas koj lub khoos phis tawj thiab neeg hlau kom zoo ib yam WiFi. Thaum qhov no tau ua tiav, koj tuaj yeem siv zog ntawm koj tus neeg hlau thiab txuas rau nws siv cov lus txib muab hauv cov ntaub ntawv database neeg hlau. (Ib txwm nyuaj rov pib dua koj lub neeg hlau ua ntej thiab tom qab koj siv nws). Piv txwv li, peb siv cov lus txib "r.roomba (19)" txuas rau peb tus neeg hlau, muab qhov sib txawv r rau peb lub cuab yeej. Qhov no hais txog rov qab mus rau cov ntaub ntawv database, uas teeb tsa peb qhov sib txawv raws li tus qauv uas peb tuaj yeem siv tau nyob rau txhua lub sijhawm.

Kauj ruam 4: Txoj Cai

Txoj Cai
Txoj Cai
Txoj Cai
Txoj Cai

Peb tau txuas tag nrho cov cai hauv qab no, tab sis ntawm no yog cov lus luv luv uas hais txog cov ntsiab lus tseem ceeb hauv peb tsab ntawv. Peb siv tag nrho cov ntsuas, nrog rau lub koob yees duab kom ua tiav siab tshaj peb cov neeg hlau lub peev xwm. Peb kuj suav nrog cov cai uas tso cai rau peb txuas lub xov tooj ntawm tes mus rau peb lub neeg hlau thiab siv nws lub gryoscope los tswj nws tus kheej.

Peb pib tawm nrog cov lus txib yooj yim "r.setDriveVelocity (.06)" uas teeb tsa tus neeg hlau ua ntej nrawm rau.06 m/s. Qhov no tsuas yog ua kom cov neeg hlau txav mus ua ntej

Tom qab ntawd, peb cov ntawv tseem ceeb tau pib tawm nrog lub sijhawm ib ntus uas khaws cov ntaub ntawv ntawm tus neeg hlau muab los ntawm kev tsim cov qauv uas peb tuaj yeem siv thiab siv hauv cov lus hais raws li hauv qab no, yog li tso cai rau peb qhia rau tus neeg hlau ua qee qhov kev hais kom ua raws li cov ntaub ntawv qauv. tus neeg hlau nyeem nrog nws cov sensors. Peb teeb tsa nws kom tus neeg hlau nyeem nws lub ntsej muag sensor thiab ua raws txoj hauv kev dub

thaum muaj tseeb % thaum lub voj mus txog thaum muaj qee yam "cuav" tshwm sim (qhov no nws mus tas li) cov ntaub ntawv = r.getCliffSensors; data2 = r.getBumpers; % khaws cov ntaub ntawv tsis tu ncua txog ntawm pob zeb sensor qhov tseem ceeb thiab muab lawv rau qhov sib txawv % img = r.getImage; % Siv daim duab los ntawm lub koob yees duab mounted % duab (img); % Qhia cov duab uas tau coj % red_mean = mean (mean (img (:,:, 1))); % Siv tus nqi nruab nrab rau xim ntsuab yog data.rightFront <2000 r.turnAngle (-2); % tig lub Roomba kwv yees li.2 degree CW ib zaug tus nqi rau sab xis pob tsuas sensors poob qis dua 2000 r.setDriveVelocity (.05); elseif data.leftFront data.leftFront && 2000> data.rightFront r.moveDistance (.1); % qhia rau Roomba kom mus tom ntej ntawm kwv yees li.2 m/s yog tias ob qho txiaj ntsig los ntawm sab xis thiab sab laug pem hauv ntej lub cev poob qis dua 2000 % r.turnAngle (0); % qhia rau Roomba kom tsis txhob tig rov qab yog tias cov xwm txheej saum toj no muaj tseeb

elseif data2.right == 1 r.moveDistance (-. 12); r.turnAngle (160); r.setDriveVelocity (.05); elseif data2.left == 1 r.moveDistance (-. 2); r.turnAngle (5); r.setDriveVelocity (.05); elseif data2.front == 1 r.moveDistance (-. 12); r.turnAngle (160); r.setDriveVelocity (.05);

Tom qab lub sijhawm no, peb nkag mus rau lwm lub voj uas ua rau cov ntaub ntawv tau txais los ntawm lub koob yees duab. Thiab peb siv cov lus hais hauv qhov no thaum lub voj uas lees paub cov duab siv cov haujlwm tshwj xeeb (alexnet), thiab thaum nws txheeb xyuas cov duab nws tam sim ua rau lub xov tooj ntawm tes tswj chaw taws teeb

anet = alexnet; % Muab alexnet kev kawm tob mus rau qhov sib txawv ntawm qhov tseeb % Infinite thaum lub voj img = r.getImage; img = imresize (img, [227, 227]); label = cais (anet, img); yog daim ntawv == "ntawv phuam" || daim ntawv == "tub yees" daim ntawv lo = "dej"; kawg duab (img); title (char (daim ntawv lo)); kos duab;

Lub sijhawm txuas uas tso cai rau peb tswj hwm lub cuab yeej nrog peb lub xov tooj khaws cov ntaub ntawv ntawd los ntawm lub xov tooj lub xov tooj cua thiab peb txuas nws mus rau hauv cov lej uas txuas ntxiv cov ntaub ntawv rov qab rau hauv MATLAB ntawm lub khoos phis tawj. Peb siv cov lus hais yog tias nyeem cov ntaub ntawv ntawm cov lej thiab muab cov khoom tso tawm uas txav cov cuab yeej raws li qee qhov tseem ceeb ntawm lub xov tooj lub gyroscope. Nws yog ib qho tseem ceeb kom paub tias peb tau siv Orientation sensors ntawm lub xov tooj ntawm tes. Ib los ntawm peb tus lej uas tau hais los saum no tau muab cais los ntawm txhua lub hauv paus ntawm kev taw qhia cov cim ntawm lub xov tooj, uas yog azimuth, suab, thiab sab. Yog tias cov lus tsim cov xwm txheej uas tau hais tseg thaum sab tshaj qhov muaj txiaj ntsig 50 lossis poob qis dua -50, tom qab ntawd tus neeg hlau txav qee qhov nrug mus rau tom ntej (zoo 50) lossis rov qab (tsis zoo 50). Thiab tib yam mus rau tus nqi suab. Yog hais tias tus nqi suab tshaj tus nqi 25 ntawm kev poob qis dua -25, tus neeg hlau tig ntawm lub kaum sab xis ntawm 1 degrees (zoo 25) lossis tsis zoo 1 degrees (tsis zoo 25)

thaum muaj tseeb ncua (.1) % Pause ntawm.5 vib nas this ua ntej txhua tus nqi raug coj los tswj = iphone. Orientation; % Muab cov lej rau qhov tseem ceeb ntawm kev taw qhia ntawm iPhone rau qhov sib txawv Azimuthal = Controller (1); % Muab thawj tus nqi ntawm cov lej rau qhov sib txawv Pitch = Controller (2); % Muab tus nqi thib ob ntawm qhov sib piv rau qhov sib txawv (qaij pem hauv ntej thiab thim rov qab thaum iPhone tuav ib sab) Sab = Tus Tswj (3); % Muab tus nqi thib peb ntawm qhov sib piv rau qhov sib txawv (qaij sab laug thiab sab xis thaum iPhone tuav ib sab) % Ua rau cov zis raws li kev taw qhia ntawm lub xov tooj yog Sab> 130 || Sab 25 r.moveDistance (-. 1) % Tsiv Roomba rov qab los kwv yees li.1 meters yog tias lub iPhone qaij rov qab yam tsawg kawg 25 degress elseif Sab 25 r.turnAngle (-1) % Tig Roomba kwv yees li 1 degree CCW yog tias iPhone yog qaij sab laug yam tsawg kawg 25 degrees lwm qhov Yog hais tias Suab <-25 r.turnAngle (1) % Tig lub Roomba kwv yees li 1 degree CW yog tias iPhone tau qaij tsawg kawg 25 degrees kawg

Cov no tsuas yog cov ntsiab lus tseem ceeb ntawm daim tseem ceeb ntawm peb cov cai, uas peb suav nrog yog tias koj xav tau luam sai thiab muab ntu rau koj li txiaj ntsig. Txawm li cas los xij, peb tag nrho cov lej txuas hauv qab no yog xav tau

Kauj Ruam 5: Xaus

Txoj cai no uas peb tau sau yog tsim tshwj xeeb rau peb cov neeg hlau nrog rau peb lub zeem muag tag nrho ntawm txoj haujlwm. Peb lub hom phiaj yog siv tag nrho peb cov txuj ci MATLAB txhawm rau txhawm rau tsim cov ntawv zoo uas siv feem ntau ntawm cov neeg hlau lub ntsej muag. Siv lub xov tooj tswj tsis yog qhov nyuaj raws li koj xav, thiab peb vam tias peb cov lej tuaj yeem pab koj nkag siab lub tswv yim tom qab coding iRobot.

Pom zoo: