Cov txheej txheem:

Roomba Explorer: 4 Kauj Ruam
Roomba Explorer: 4 Kauj Ruam

Video: Roomba Explorer: 4 Kauj Ruam

Video: Roomba Explorer: 4 Kauj Ruam
Video: Best Robot Vacuums 2024 - The Only 5 You Should Consider Today 2024, Hlis ntuj nqeg
Anonim
Roomba Explorer
Roomba Explorer

Los ntawm kev siv MATLAB thiab iRobot's Create2 Robot, txoj haujlwm no yuav tshawb xyuas thaj tsam sib txawv ntawm qhov chaw tsis paub. Peb tau ua haujlwm ntsuas lub ntsej muag ntawm Neeg Hlau los pab tswj kev phom sij. Los ntawm kev tau txais duab thiab yees duab pub los ntawm Raspberry Pi uas tau txuas nrog, peb tuaj yeem txiav txim siab qhov teeb meem uas Robot yuav ntsib, thiab lawv yuav raug cais tawm.

Cov Khoom thiab Cov Khoom

Rau qhov haujlwm no, koj yuav xav tau

-ib lub computer

-Muaj tshiab tshaj ntawm MATLAB (MATLAB R2018b tau siv rau txoj haujlwm no)

- roombaInstall toolbox

-iRobot's Tsim2 Neeg Hlau

-Raspberry Pi nrog Lub Koob Yees Duab

Kauj Ruam 1: Kev pib ua thiab Sensors

Pib thiab Sensors
Pib thiab Sensors

Ua ntej pib ib qho program, peb rub tawm lub roombaInstall toolbox, uas tso cai nkag mus rau cov khoom sib txawv ntawm Robot.

Thaum xub thawj, peb tsim GUI los pib ua ib tus Neeg Hlau. Txhawm rau ua qhov no, koj yuav tsum ntaus tus lej ntawm Tus Neeg Hlau raws li kev nkag. Qhov no yuav tso cai nkag mus ua haujlwm peb txoj haujlwm rau Neeg Hlau Peb tau ua haujlwm kom tau txais Tus Neeg Hlau los tswj hwm los ntawm ntau thaj chaw uas nws yuav ntsib. Peb tau siv Cliff Sensors, Lub Teeb Tswb Sensors, thiab Lub Cev Lub Cev Lub Cev, los ntawm kev siv lawv cov txiaj ntsig los mus rau Neeg Hlau kom hloov nws qhov nrawm thiab lossis kev coj ua. Thaum ib qho ntawm rau rau Lub Teeb Pom Kev Pom Pom pom qhov khoom, tus nqi lawv tso tawm yuav txo qis, ua rau tus neeg hlau nrawm kom txo kom tsis txhob muaj kev sib tsoo nrawm. Thaum Neeg Hlau thaum kawg sib tsoo nrog qhov teeb meem, Lub Cev Lub Cev Sensor yuav tshaj tawm tus nqi ntau dua xoom; vim qhov no, Neeg Hlau yuav tsum nres, yog li yuav tsis muaj kev sib tsoo ntxiv thiab ntau lub luag haujlwm tuaj yeem ua rau hauv kev nqis tes ua. Rau Cliff Sensors, lawv yuav nyeem qhov ci ci ntawm thaj chaw ib puag ncig lawv. Yog tias tus nqi ntau dua 2800, peb txiav txim siab tias Tus Neeg Hlau yuav nyob hauv qhov chaw ruaj khov thiab nyab xeeb. Tab sis, Yog tias tus nqi tsawg dua 800, Cliff Sensors yuav kuaj pom lub pob tsuas, nres tam sim ntawd kom tsis txhob poob. Txhua tus nqi hauv nruab nrab tau txiav txim siab los sawv cev rau dej thiab yuav ua rau Robot nres nws txoj haujlwm. Los ntawm kev siv cov ntsuas ntsuas saum toj no, qhov nrawm ntawm Neeg Hlau tau hloov pauv kom peb txiav txim siab tau zoo dua yog tias muaj kev phom sij.

Hauv qab no yog tus lej (los ntawm MATLAB R2018b)

%% Kev pib ua ntej

dlgPrompts = {'Roomba Naj Npawb'};

dlgTitle = 'Xaiv Koj Roomba';

dlgDefaults = {''};

opts. Resize = 'rau';

dlgout = inputdlg (dlgPrompts, dlgTitle, 1, dlgDefaults, opts) % Tsim lub qhov rai uas hais kom tus neeg siv nkag mus rau lawv tus lej chav nyob

n = str2double (dlgout {1});

r = roomba (n); % Initializes tus neeg siv tau teev tseg Roomba %% Kev txiav txim siab nrawm los ntawm Lub Teeb Pob Ntseg thaum muaj tseeb s = r.getLightBumpers; % tau txais lub teeb tsoo lub teeb

lbumpout_1 = extractfield (s, 'sab laug'); % siv tus lej lej ntawm cov ntsuas thiab ua rau lawv siv tau ntau dua lbumpout_2 = extractfield (s, 'leftFront');

lbumpout_3 = extractfield (s, 'leftCenter');

lbumpout_4 = extractfield (s, 'rightCenter');

lbumpout_5 = extractfield (s, 'rightFront');

lbumpout_6 = extractfield (s, 'yog');

lbout = [lbumpout_1, lbumpout_2, lbumpout_3, lbumpout_4, lbumpout_5, lbumpout_6] % hloov pauv qhov tseem ceeb rau hauv matrix

sLbump = txheeb (lbout); %xaiv matrix rau tus nqi qis tshaj tuaj yeem muab rho tawm

lowLbump = sLbump (1); ceev =.05+(lowLbump)*. 005 %siv tus nqi qis tshaj, uas sawv cev rau kev kaw qhov teeb meem, txhawm rau txiav txim siab nrawm, nrawm dua thaum tsis pom dab tsi

r.setDriveVelocity (nrawm, nrawm)

kawg

% Lub Cev Lub Cev

b = r.getBumpers; %Tawm qhov tseeb, cuav

bsen_1 = extractfield (b, 'sab laug')

bsen_2 = extractfield (b, 'yog')

bsen_3 = extractfield (b, 'pem hauv ntej')

bsen_4 = extractfield (b, 'leftWheelDrop')

bsen_5 = extractfield (b, 'rightWheelDrop')

pob = [bsen_1, bsen_2, bsen_3, bsen_4, bsen_5] tbump = sum (bums)

yog tbump> 0 r.setDriveVelocity (0, 0)

kawg

% Cliff Sensors

c = r.getCliffSensors %% 2800 nyab xeeb, lwm cov dej

csen_1 = extractfield (c, 'sab laug')

csen_2 = extractfield (c, 'yog')

csen_3 = extractfield (c, 'sab laug pem hauv ntej')

csen_4 = extractfield (c, 'sab xis')

pob tsuas = [csen_1, csen_2, csen_3, csen_4]

ordcliff = txheeb (cliffs)

yog ordcliff (1) <2750

r.setDriveVelocity (0, 0)

yog pob tsuas <800

faib 'cliff'

lwm tus

faib 'dej'

kawg

r. TurnAngle (45)

kawg

Kauj ruam 2: Tau Cov Ntaub Ntawv

Tom qab Lub Caij Nyoog Lub Cev Lub Cev raug tsoo, Tus Neeg Hlau yuav siv nws lub nkoj Raspberry Pi txhawm rau thaij duab ntawm qhov teeb meem. Tom qab thaij duab, siv kev lees paub cov ntawv yog tias muaj cov ntawv hauv daim duab, Tus Neeg Hlau yuav txiav txim siab tias qhov kev cuam tshuam yog dab tsi thiab qhov teeb meem hais dab tsi.

img = r.getImage; imshow (img);

imwrite (img, 'imgfromcamera.jpg')

duab = imread ('imgfromcamera.jpg')

ocrResults = ocr (duab)

lees paubText = ocrResults. Text;

daim duab;

imshow (duab) ntawv (220, 0, lees paubText, 'BackgroundColor', [1 1 1]);

Kauj Ruam 3: Tiav Lub Hom Phiaj

Thaum Tus Neeg Hlau txiav txim siab tias qhov teeb meem yog HOME, nws yuav ua tiav nws lub luag haujlwm thiab nyob hauv tsev. Tom qab ua tiav txoj haujlwm, Neeg Hlau yuav xa email ceeb toom tias nws tau rov qab los tsev lawm, thiab nws yuav xa cov duab uas nws tau coj nrog nws mus.

% Xa E-mail

setpref ('Internet', 'SMTP_Server', 'smtp.gmail.com');

setpref ('Internet', 'E_mail', '[email protected]'); % xa nyiaj xa los ntawm setpref ('Internet', 'SMTP_Username', 'nkag tus email xa'); % xa cov neeg siv lub npe setpref ('Internet', 'SMTP_Password', 'nkag tus password xa'); % Cov neeg xa tus password

cov khoom = java.lang. System.getProperties; props.setProperty ('mail.smtp.auth', 'tseeb'); props.setProperty ('mail.smtp.socketFactory.class', 'javax.net.ssl. SSLSocketFactory'); props.setProperty ('mail.smtp.socketFactory.port', '465');

xa email ('Nkag mus txais email', 'Roomba', 'Roomba tau rov qab los tsev !!', 'imgfromcamera.jpg') % xa ntawv xa mus rau

Tus Neeg Hlau yog ua tiav.

Kauj ruam 4: Xaus

Xaus
Xaus

MATLAB txoj haujlwm suav nrog yog cais los ntawm tag nrho tsab ntawv uas tau siv nrog Neeg Hlau. Hauv kab ntawv kawg, nco ntsoov tso tag nrho cov cai, tshwj tsis yog rau theem pib, mus rau hauv lub voj ib ntus kom ntseeg tau tias cov pob tw ua haujlwm tas li. Qhov program no tuaj yeem kho kom haum rau qhov xav tau ntawm tus neeg siv. Kev teeb tsa ntawm peb Cov Neeg Hlau tau qhia.

*Nco ntsoov: Tsis txhob hnov qab tias chav roombaInstall cov cuab yeej xav tau rau MATLAB los cuam tshuam nrog Neeg Hlau thiab nyob ntawm board Raspberry Pi.

Pom zoo: