Cov txheej txheem:

Mars Roomba: 6 Kauj Ruam
Mars Roomba: 6 Kauj Ruam

Video: Mars Roomba: 6 Kauj Ruam

Video: Mars Roomba: 6 Kauj Ruam
Video: Black Eyed Peas, J Balvin - RITMO (Bad Boys For Life) (Official Music Video) 2024, Kaum ib hlis
Anonim
Mars Roomba
Mars Roomba

Cov Lus Qhia no yuav coj koj mus rau cov lus qhia ntawm kev ua haujlwm Raspberry Pi tswj Roomba lub tshuab nqus tsev. Cov txheej txheem ua haujlwm peb yuav siv yog los ntawm MATLAB.

Kauj Ruam 1: Cov khoom siv

Dab tsi koj yuav tsum tau sau los txhawm rau ua txoj haujlwm no:

  • iRobot's Create2 Roomba lub tshuab nqus tsev bot
  • Raspberry Pi
  • Raspberry Pi Lub Koob Yees Duab
  • Qhov tseeb version ntawm MATLAB
  • Roomba nruab lub cuab yeej rau MATLAB
  • MATLAB thov rau lub xov tooj ntawm tes

Kauj Ruam 2: Nqe Lus Teeb Meem

Nqe Teeb Meem
Nqe Teeb Meem

Peb tau ua lub luag haujlwm los siv MATLAB txhawm rau txhim kho lub rover uas tuaj yeem siv tau ntawm Mars txhawm rau pab cov kws tshawb fawb hauv kev sau cov ntaub ntawv ntiaj chaw. Lub luag haujlwm uas peb hais hauv peb tes haujlwm yog kev tswj chaw taws teeb, paub qhov cuam tshuam, paub dej, paub lub neej, thiab ua duab. Txhawm rau ua tiav cov kev ua no, peb tau siv lub Roomba toolbox cov lus txib los tswj hwm ntau txoj haujlwm ntawm iRobot's Create2 Roomba.

Kauj Ruam 3: Bluetooth Chaw Taws Teeb

Bluetooth Chaw Taws Teeb Tswj
Bluetooth Chaw Taws Teeb Tswj

Qhov swb no yuav taug-hla txoj cai los tswj Roomba txoj kev txav mus los siv lub peev xwm Bluetooth ntawm koj lub cuab yeej siv smartphone. Txhawm rau pib, rub tawm daim ntawv thov MATLAB rau koj lub smartphone thiab nkag mus rau hauv koj li lej lej. Thaum nkag mus, mus rau "ntau dua", "teeb tsa", thiab txuas rau koj lub computer siv nws tus IP chaw nyob. Thaum txuas nrog, rov qab mus rau "ntau dua" thiab xaiv "sensors." Coj mus rhaub rau qhov ntsuas thib peb ntawm lub cuab yeej sab saum toj ntawm lub vijtsam, thiab coj mus rhaub pib. Tam sim no, koj lub smartphone yog chaw taws teeb tswj!

Cov cai yog raws li hauv qab no:

thaum 0 == 0

ncua (.5)

PhoneData = M. Orientation;

Azi = PhoneData (1);

Suab = PhoneData (2);

Sab = PhoneData (3);

pob = r.getBumpers;

yog Sab> 80 || Sab <-80

r.stop

r.beep ('C, E, G, C^, G, E, C')

so

elseif Sab> 20 && Sab <40

r.turnAngle (-5);

elseif Sab> 40

r.turnAngle (-25);

elseif Sab-40

r.turnAngle (5);

elseif Sab <-40

r.turnAngle (25);

kawg

yog Suab> 10 && Suab <35

r.moveDistance (.03)

elseif Suab> -35 && Suab <-10

r.moveDistance (-. 03)

kawg

kawg

Kauj Ruam 4: Kev Paub Ua Haujlwm

Kev lees paub qhov cuam tshuam
Kev lees paub qhov cuam tshuam

Lwm txoj haujlwm uas peb tau siv yog txhawm rau txheeb xyuas qhov cuam tshuam ntawm Roomba rau hauv ib qho khoom thiab tom qab ntawd kho nws txoj hauv kev tam sim no. Txhawm rau ua qhov no, peb yuav tsum tau siv cov xwm txheej nrog kev nyeem los ntawm lub ntsuas cua lub taub hau txhawm rau txiav txim siab yog tias ib qho khoom raug tsoo. Yog tias tus neeg hlau tsoo ib yam khoom, nws yuav thim rov qab.2 metres, thiab tig ntawm lub kaum sab xis txiav txim siab los ntawm qhov uas lub taub hau raug tsoo. Thaum ib yam khoom raug tsoo, cov ntawv qhia zaub mov tshwm tawm uas qhia lo lus "oof."

Txoj Cai tau qhia hauv qab no:

thaum 0 == 0

pob = r.getBumpers;

r.setDriveVelocity (.1)

yog bumps.left == 1

msgbox ('Oof!');

r.moveDistance (-0.2)

r.setTurnVelocity (.2)

r.turnAngle (-35)

r.setDriveVelocity (.2)

elseif bumps.front == 1

msgbox ('Oof!');

r.moveDistance (-0.2)

r.setTurnVelocity (.2)

r.turnAngle (90)

r.setDriveVelocity (.2)

elseif bumps.right == 1

msgbox ('Oof!');

r.moveDistance (-0.2)

r.setTurnVelocity (.2)

r.turnAngle (35)

r.setDriveVelocity (.2)

elseif bumps.leftWheelDrop == 1

msgbox ('Oof!');

r.moveDistance (-0.2)

r.setTurnVelocity (.2)

r.turnAngle (-35)

r.setDriveVelocity (.2)

elseif bumps.rightWheelDrop == 1

msgbox ('Oof!');

r.moveDistance (-0.2)

r.setTurnVelocity (.2)

r.turnAngle (35)

r.setDriveVelocity (.2)

kawg

kawg

Kauj Ruam 5: Kev Paub Lub Neej

Kev Paub Lub Neej
Kev Paub Lub Neej

Peb tau sau lub cim kev paub lub neej los nyeem cov xim ntawm cov khoom nyob rau ntawm nws xub ntiag. Peb yam ntawm lub neej uas peb tau sau tseg yog cov nroj tsuag, dej, thiab neeg txawv teb chaws. Txhawm rau ua qhov no, peb tau ntsuas cov ntsuas ntsuas los ntsuas qhov nruab nrab ntawm liab, xiav, ntsuab, lossis dawb. Cov txiaj ntsig no tau muab piv rau qhov pib uas tau teeb tsa tus kheej los txiav txim siab xim uas lub koob yees duab tab tom saib. Txoj cai tseem yuav npaj txoj hauv kev rau qhov khoom thiab tsim daim duab qhia chaw.

Cov cai yog raws li hauv qab no:

t = 10;

kuv = 0;

thaum t == 10

img = r.getImage; imshow (img)

ncua (0.167)

kuv = kuv + 1;

red_mean = mean (txhais (img (:,:, 1)));

blue_mean = mean (txhais (img (:,:, 3)));

ntsuab_mean = mean (mean (img (:,:, 2)));

white_mean = (blue_mean + green_mean + red_mean) / 3; %xav tau tus nqi kwv yees li 100

cuaj_plus_ten = 21;

ntsuab_threshold = 125;

xiav_threshold = 130;

white_threshold = 124;

red_threshold = 115;

thaum cuaj_plus_ten == 21 %ntsuab - lub neej

yog tias ntsuab_mean> ntsuab_threshold && blue_mean <blue_threshold && red_mean <red_threshold

r.moveDistance (-. 1)

a = msgbox ('muaj peev xwm ua tau lub neej pom, qhov chaw tau npaj tseg');

ncua (2)

rho tawm (a)

[y2, Fs2] = audioread ('z_speak2.wav');

suab (y2, Fs2)

ncua (2)

%cog = r.getImage; %imshow (cog);

%txuag ('plant_img.mat', cog ');

%thaj chaw thaj chaw ntsuab

kuv = 5;

so

lwm tus

cuaj_plus_ten = 19;

kawg

kawg

cuaj_plus_ten = 21;

thaum cuaj_plus_ten == 21 %xiav - woder

yog blue_mean> blue_threshold && green_mean <green_threshold && white_mean <white_threshold && red_mean <red_threshold

r.moveDistance (-. 1)

a = msgbox ('tau pom dej hauv qhov chaw, qhov chaw tau npaj tseg');

ncua (2)

rho tawm (a)

[y3, Fs3] = audioread ('z_speak3.wav');

suab (y3, Fs3);

%woder = r.getImage; %imshow (tus thov)

%txuag ('dej_img.mat', woder)

%qhov chaw nyob hauv xiav

kuv = 5;

so

lwm tus

cuaj_plus_ten = 19;

kawg

kawg

cuaj_plus_ten = 21;

thaum cuaj_plus_ten == 21 %dawb - neeg txawv teb chaws monkaS

yog white_mean> white_threshold && blue_mean <blue_threshold && green_mean <green_threshold

[y5, Fs5] = audioread ('z_speak5.wav');

suab (y5, Fs5);

ncua (3)

r.setDriveVelocity (0,.5)

[ys, Fss] = audioread ('z_scream.mp3');

suab (ys, Fss);

ncua (3)

r.stop

% neeg txawv teb chaws = r.getImage; %imshow (neeg txawv teb chaws);

% txuag ('alien_img.mat', neeg txawv tebchaws);

kuv = 5;

so

lwm tus

cuaj_plus_ten = 19;

kawg

kawg

yog tias kuv == 5

ua = 1; %tig lub kaum sab xis

t = 9; %txiav lub voj loj

kuv = 0;

kawg

kawg

Kauj ruam 6: Khiav Nws

Tom qab tag nrho cov cai tau sau, muab tag nrho nws rau hauv ib daim ntawv thiab voila! Koj Roomba bot tam sim no yuav ua haujlwm tau zoo thiab ua haujlwm raws li tshaj tawm! Txawm li cas los xij, kev tswj hwm Bluetooth yuav tsum yog nyob hauv cov ntawv cais lossis cais los ntawm tus lej seem nrog %%.

Txaus siab rau siv koj tus neeg hlau !!

Pom zoo: