Cov txheej txheem:

IRobot Tsim-Mars Expedition Rover Mark I: 4 Cov Kauj Ruam
IRobot Tsim-Mars Expedition Rover Mark I: 4 Cov Kauj Ruam

Video: IRobot Tsim-Mars Expedition Rover Mark I: 4 Cov Kauj Ruam

Video: IRobot Tsim-Mars Expedition Rover Mark I: 4 Cov Kauj Ruam
Video: CANBOT Happy Robot Dance Square HOT! 2024, Kaum ib hlis
Anonim
IRobot Tsim-Mars Expedition Rover Mark I
IRobot Tsim-Mars Expedition Rover Mark I

Cov lus qhia no yuav qhia koj yuav teeb tsa iRobot Tsim los ntawm kev siv MatLab coding. Koj tus neeg hlau yuav muaj peev xwm tshawb nrhiav cov zaub mov los ntawm qhov sib txawv ntawm cov duab, maneuver rugged terrain los ntawm kev siv cov pob zeb sensors, thiab muaj lub peev xwm los tswj tus kheej ntawm cov khoom noj.

Kauj Ruam 1: Cov khoom siv

Khoom siv
Khoom siv

Txog qhov haujlwm no, koj yuav xav tau iRobot Tsim, uas yog qhov programmable version of Roomba neeg hlau nqus tsev nqus tsev. Tus neeg hlau tuaj nruab nrog txhua lub ntsuas xav tau rau qhov haujlwm no, tshwj xeeb yog lub pob tsoo lub ntsej muag, lub ntsej muag lub ntsej muag thiab lub teeb "Lub Pob". Koj kuj tseem yuav xav tau Raspberry Pi thiab lub koob yees duab yees duab, siv rau kev sib txuas lus wireless, kev ua haujlwm nyob, thiab cov vis dis aus nyob. Thaum kawg, koj yuav xav tau 3D luam tawm mount rau Raspberry Pi thiab lub koob yees duab.

Kauj Ruam 2: Tsim Coding kom txaus siab Qhov Ua Tau Zoo

Tsim Coding kom txaus siab Qhov Ua Tau Zoo
Tsim Coding kom txaus siab Qhov Ua Tau Zoo

Thaum koj tau txuas nrog koj Roomba, koj yuav tsum tsim Matlab code uas yuav muab rau koj qhov kev xav tau tom qab koj xav tau cov tswv yim.

Cov cai tuaj yeem pom ntawm no:

%Roomba Project%Brenten Arnold (barnol15); Julianne Korn (qdp218); Mike Kho (mheal) %4/11/19 %Cov Lus Qhia Teeb Meem: Tsim lub rover los pab tib neeg thaum %tshawb nrhiav/nyob ntawm mars. %Txoj kev daws teeb meem: Tshawb nrhiav cov organic (ntsuab) teeb meem los ntawm kev siv %lub teeb tsoo, lub ntsej muag lub ntsej muag thiab lub koob yees duab los tshuaj xyuas cov organic. Tso cai %lub rover mus rau qhov av ntxhib los ntawm kev siv cov pob tw, pob tsuas %cov cim, thiab lub log siab ntsuas. Pab kom tib neeg tswj hwm lub rover los ntawm %kev nyab xeeb nyob deb thiab tshawb nrhiav cov zaub mov. xaiv = {'LIFE', 'ROUGH TERRAIN', 'USER CONTROL'}; %Peb qhov kev xaiv hauv cov lus sib tham Chaw teeb tsa = ntawv qhia zaub mov ('', xaiv) yog Teeb> 0 %Yog tias xaiv tau xaiv nug tus neeg siv kev lees paub xaiv 2 = {'Yog', 'Tsis yog'} %Tsim cov kab ke ntawm tes rau "yog" lossis "Tsis yog "xaiv Confirm = menu (['Koj tau xaiv"' xaiv {Teeb} '"hom.'], xaiv 2) %Txheeb xyuas cov neeg siv teeb tsa xaiv yog paub tseeb tias == 1 yog Teem == 1 %Txheeb xyuas yog" LIFE "teeb tsa tau xaiv = 0 thaum kuv == 0 r.setLEDDigits (num2str ('LIFE')) %Zaub 'LIFE' ntawm LED rau kuv = 1: 100 r.setDriveVelocity (0.05) %Tsiv roomba rau pem hauv ntej ntawm 0.05 m/sy = r.getCliffSensors %Retrieve thiab khaws cov pob zeb sensor qhov tseem ceeb hauv cov qauv ntawm tes "y" l = r.getLightBumpers %Retrieve thiab khaws lub teeb tsoo qhov tseem ceeb hauv tus qauv "f" yog l.left> 100 %Txheeb xyuas yog tias sab laug lub teeb bumper tau npog r.moveDistance (-0.05) %Txav roomba rov qab 0.05 meters r.turnAngle (20) %Rotate roomba 20 degrees CCW img = r.getImage %Tau txais duab los ntawm lub koob yees duab ncuav qab zib ntawm chav nyob = [100 0 150 150]; img = imcrop (img, rect) %qoob loo duab kom tsom mus rau nruab nrab liab = nruab nrab (nruab nrab (img (:,:,, 1))) % %qhov nruab nrab liab siv ntsuab = txhais tau tias (mean (img (:,:, 2))) %nruab nrab ntsuab siv zog xiav = txhais tau tias (mean (img (:,:, 3))) % %qhov nruab nrab xiav siv yog ntsuab> liab && ntsuab> xiav %Xyuas seb tsob ntoo puas nyob hauv daim duab d = msgbox (['Lub neej pom! ']); Kuv %Muab lub npov lus hais tias "Lub neej pom!" tos rau (d); kawg elseif l.leftFront> 100 %Kos yog sab laug/pem hauv ntej lub teeb bumper tau npog r.moveDistance (-0.05) %Tsiv roomba rov qab 0.05 meters img = r.getImage %Tau duab los ntawm lub koob yees duab ncuav qab zib ntawm chav nyob thiab khaws hauv qhov sib txawv 'img 'rect = [100 0 150 150]; img = imcrop (img, rect) %qoob loo duab kom tsom mus rau nruab nrab liab = nruab nrab (nruab nrab (img (:,:,, 1))) % %qhov nruab nrab liab siv ntsuab = txhais tau tias (mean (img (:,:, 2))) %nruab nrab ntsuab siv zog xiav = txhais tau tias (mean (img (:,:, 3))) % %qhov nruab nrab xiav siv yog ntsuab> liab && ntsuab> xiav %Xyuas seb tsob ntoo puas nyob hauv daim duab d = msgbox (['Lub neej pom! ']); Kuv %Muab lub npov lus hais tias "Lub neej pom!" tos rau (d); kawg elseif l.leftCenter> 100 %Txheeb xyuas yog tias sab laug/nruab nrab lub teeb bumper tau npog r.moveDistance (-0.05) %Tsiv chav nyob rov qab 0.05 meters img = r.getImage %Tau duab los ntawm lub koob yees duab ncuav qab zib ntawm chav nyob thiab khaws hauv qhov sib txawv 'img 'rect = [100 0 150 150]; img = imcrop (img, rect) %qoob loo duab kom tsom mus rau nruab nrab liab = nruab nrab (nruab nrab (img (:,:,, 1))) % %qhov nruab nrab liab siv ntsuab = txhais tau tias (mean (img (:,:, 2))) %nruab nrab ntsuab siv zog xiav = txhais tau tias (mean (img (:,:, 3))) % %qhov nruab nrab xiav siv yog ntsuab> liab && ntsuab> xiav %Xyuas seb tsob ntoo puas nyob hauv daim duab d = msgbox (['Lub neej pom! ']); Kuv %Muab lub npov lus hais tias "Lub neej pom!" tos rau (d); kawg elseif l.rightCenter> 100 %Txheeb xyuas yog tias txoj cai/nruab nrab lub teeb bumper tau npog r.moveDistance (-0.05) %Tsiv roomba rov qab 0.05 meters img = r.getImage %Tau duab los ntawm lub koob yees duab ncuav qab zib ntawm chav nyob thiab khaws hauv qhov sib txawv 'img 'rect = [100 0 150 150]; img = imcrop (img, rect) %qoob loo duab kom tsom mus rau nruab nrab liab = nruab nrab (nruab nrab (img (:,:,, 1))) % %qhov nruab nrab liab siv ntsuab = txhais tau tias (mean (img (:,:, 2))) %nruab nrab ntsuab siv zog xiav = txhais tau tias (mean (img (:,:, 3))) % %qhov nruab nrab xiav siv yog ntsuab> liab && ntsuab> xiav %Xyuas seb tsob ntoo puas nyob hauv daim duab d = msgbox (['Lub neej pom! ']); Kuv %Muab lub npov lus hais tias "Lub neej pom!" tos rau (d); kawg elseif l.rightFront> 100 %Txheeb xyuas yog tias txoj cai/pem hauv ntej lub teeb bumper tau npog r.moveDistance (-0.05) %Tsiv mus rau roomba rov qab 0.05 meters img = r.getImage %Tau duab los ntawm lub koob yees duab ncuav qab zib ntawm chav nyob thiab khaws hauv qhov sib txawv 'img 'rect = [100 0 150 150]; img = imcrop (img, rect) %qoob loo duab kom tsom mus rau nruab nrab liab = nruab nrab (nruab nrab (img (:,:,, 1))) % %qhov nruab nrab liab siv ntsuab = txhais tau tias (mean (img (:,:, 2))) %nruab nrab ntsuab siv zog xiav = txhais tau tias (mean (img (:,:, 3))) % %qhov nruab nrab xiav siv yog ntsuab> liab && ntsuab> xiav %Xyuas seb tsob ntoo puas nyob hauv daim duab d = msgbox (['Lub neej pom! ']); Kuv %Muab lub npov lus hais tias "Lub neej pom!" tos rau (d); kawg elseif l.right> 100 %Txheeb xyuas yog tias lub teeb bumper raug them r.moveDistance (-0.05) %Tsiv chav nyob rov qab 0.05 meters r.turnAngle (-20) %Rotate roomba 20 degrees CW img = r.getImage %Tau duab los ntawm rasberry ncuav qab zib lub koob yees duab ntawm roomba thiab khaws hauv qhov sib txawv 'img' rect = [100 0 150 150]; img = imcrop (img, rect) %qoob loo duab kom tsom mus rau nruab nrab liab = nruab nrab (nruab nrab (img (:,:,, 1))) % %qhov nruab nrab liab siv ntsuab = txhais tau tias (mean (img (:,:, 2))) %nruab nrab ntsuab siv zog xiav = txhais tau tias (mean (img (:,:, 3))) % %qhov nruab nrab xiav siv yog ntsuab> liab && ntsuab> xiav %Xyuas seb tsob ntoo puas nyob hauv daim duab d = msgbox (['Lub neej pom! ']); Kuv %Muab lub npov lus hais tias "Lub neej pom!" tos rau (d); kawg elseif y.leftFront <1500 %Txheeb xyuas yog tias sab laug/pem hauv ntej ntawm roomba tawm ntawm pob tsuas r.moveDistance (-0.1, 0.05) %Tsiv chav nyob rov qab 0.1 meters ntawm 0.05 m/s r.turnAngle (-5) %Rotate roomba 5 degrees CW elseif y.rightFront <1500 %Txheeb xyuas yog tias sab xis/pem hauv ntej ntawm chav tsev tawm ntawm pob tsuas r.moveDistance (-0.1, 0.05) %Tsiv chav rov qab 0.1 meters ntawm 0.05 m/s r.turnAngle (5) %Rotate roomba 5 degrees CCW elseif y.left <1000 %Txheeb xyuas yog tias sab laug ntawm chav tsev tawm ntawm pob tsuas r.moveDistance (-0.05, 0.05) %Tsiv chav nyob rov qab 0.05 meters ntawm 0.05 m/s r.turnAngle (-10) %Rotate roomba 10 degrees CW elseif y.right0 %Khiav yog khawm tau nias yog txuas ntxiv == 1 i = 0 %Mus txuas ntxiv nrhiav lub neej ntxiv i = 1 %End LIFE mode end end endifif Setting == 2 %Check if "ROUGH TERRAIN" setting was selected i = 0 thaum kuv == 0 r.setLEDDigits (num2str ('RGH')) %Zaub 'Rough' ntawm LED Zaub rau kuv = 1: 1000 r.setDriveVelocity (0.05) %Teeb chav roomba nrawm rau 0.05 m/sx = r.getBumpers %Retrieve thiab khaws lub tswb ntsuas qhov tseem ceeb hauv tus qauv "x" y = r.get CliffSensors %Retrieve thiab khaws cov pob zeb sensor qhov tseem ceeb hauv tus qauv "y" yog x.right == 1 %Txheeb xyuas yog tias txoj cai bumper raug nias r.turnAngle (10) %Rotate roomba 10 degrees CCW elseif x.left == 1 %Txheeb xyuas yog tias sab laug bumper tau nias r.turnAngle (-10) %Rotate roomba 10 degrees CW elseif x.front == 1 %Txheeb xyuas yog tias lub hauv ntej tsoo tau nias r.turnAngle (20) %Rotate roomba 20 degrees CCW elseif x.rightWheelDrop == 1 % Txheeb xyuas yog tias lub log log tau poob r.turnAngle (-20) %Rotate roomba 20 degrees CW elseif x.leftWheelDrop == 1 %Kos yog sab laug log tau poob r.turnAngle (20) %Rotate roomba 20 degrees CCW elseif y.leftFront 1500 %Txheeb xyuas yog tias sab laug sab ntawm roomba tawm ntawm pob tsuas r.moveDistance (-0.05, 0.05) %Tsiv chav nyob rov qab 0.05 meters ntawm 0.05 m/s r.turnAngle (-5) %Rotate roomba 5 degrees CW elseif y.rightFront 1500 %Txheeb xyuas yog tias sab xub ntiag ntawm roomba tawm ntawm pob tsuas r.moveDistance (-0.05, 0.05) %Tsiv chav nyob rov qab 0.05 meters ntawm 0.05 m/s r.turnAngle (5) %Rotate roomba 5 degrees CCW elseif y.left <1000 %Txheeb xyuas yog seem seem o f roomba tawm ntawm pob tsuas r.moveDistance (-0.05, 0.05)%Txav mus rau roomba rov qab 0.05 meters ntawm 0.05 m/s r.turnAngle (-10)%Rotate roomba 10 degrees CW elseif y.right0 yog txuas ntxiv == 1 i = 0 %Mus txuas ntxiv qhov ntxhib lwm qhov i = 1 %Xaus qhov av ntxhib kawg kawg kawg lwm qhov %Phau ntawv hom kuv = 0 r.setLEDDigits (num2str ('USER')) %Zaub 'USER' ntawm LED Zaub d = msgbox (['Cov xub - Tsiv; S - Nres Rover; ESC - Kawg Tus Neeg Siv Tswj; A - Nrhiav cov peev txheej ']); tos rau (d); thaum kuv == 0 r.showCamera %Qhib rasberry ncuav qab zib lub koob yees duab nyob pub nyob rau hauv cais lub qhov rai D = getkey (1) %Rov qab los tus yuam sij nias los ntawm tus neeg siv, khaws ASCII tus nqi raws li sib txawv D yog D == 30 %Txheeb xyuas yog tias "xub" xub muaj tau nias r.setDriveVelocity (0.1) %Xa roomba rau pem hauv ntej ntawm 0.2 m/s elseif D == 28 %Txheeb xyuas yog tias "laug" xub tau nias r.setDriveVelocity (0) %Nres roomba los ntawm kev txav mus tom ntej lossis rov qab r.turnAngle (15), 0.05) %Rotate roomba 45 degrees CCW ntawm 0.05 m/s elseif D == 31 %Txheeb xyuas yog tias "xub" xub tau nias r.setDriveVelocity (-0.1) %Tsiv roomba rov qab ntawm 0.2 m/s elseif D == 29 % Txheeb xyuas yog tias "xub" xub nias r.setDriveVelocity (0) %Nres roomba tsis txav mus tom ntej lossis thim rov qab r.turnAngle (-15, 0.05) %Rotate roomba 45 degrees CW ntawm 0.05 m/s elseif D == 27 %Txheeb xyuas yog tias tus "esc" (khiav tawm) tus yuam sij tau raug nias i = 1 %Hloov tus nqi ntawm qhov sib txawv "i" kom tawm lub voj d = msgbox ('Tawm "Tus Neeg Siv Kev Tswj"') %Qhia rau tus neeg siv paub tias hom kev tawm yog tawm mus rau lwm qhov yog D == 115 %Txheeb xyuas yog tias tus yuam sij "s" tau raug r.setDriveVelocity (0) %Nres roomba los ntawm mus tom ntej lossis rov qab elseif D == 97 %Txheeb xyuas yog tias "a" tau raug nias duab = r.getImage; imwrite (duab, 'image.png') W = Classify (image) K = mode (W) if K == 3 d = msgbox ('Resource found') %Zaub tso tawm yog lub hauv paus cov peev txheej pom tau tos rau (d); %Tos rau tus neeg siv kaw lub npov lus "d" elseif K == 0 d = msgbox ('Tsis Muaj Cov Khoom Siv:(') %Zaub yog cov khoom siv tsis tau pom dua tos rau (d); %Tos rau tus neeg siv kaw lub npov lus "d" kawg lwm d = msgbox ('Tsis yog qhov tseem ceeb siv tau.') %Zaub yog tias tus neeg siv kaw "xaiv teeb tsa" ntawv qhia zaub mov tos rau (d); %Tos rau tus neeg siv kaw lub npov lus "d" xaus tos rau (d); %Tos rau tus neeg siv los kaw lub npov lus "d" xaus kawg kawg lwm tus d = msgbox ('Goodbye') %Hais zoo yog tias cov kev xaiv raug kaw kawg tos rau (d);

Kauj Ruam 3: Xeem

Kev Xeem
Kev Xeem

Thaum koj tau sau cov cai, koj yuav tsum sim koj li Roomba. Txawm hais tias koj cov cai yuav zoo li raug, ntau yam ntawm koj qhov txiaj ntsig, tshwj xeeb tshaj yog rau xim lossis duab, yuav tsum tau hloov pauv kom thiaj li paub qhov khoom uas koj xav kom koj Roomba txheeb xyuas.

Kauj Ruam 4: Soj Ntsuam Pom Kev Pom Kev

Soj Ntsuam Kev Pom Kev Pom Kev
Soj Ntsuam Kev Pom Kev Pom Kev
Soj Ntsuam Kev Pom Kev Pom Kev
Soj Ntsuam Kev Pom Kev Pom Kev

Nws yuav pom tseeb heev txawm tias tsis yog koj tau ua tiav koj li Roomba raws nws qhov kev pom pom.

Cov txiaj ntsig suav nrog:

  • Kev Tshawb Nrhiav Cov Duab: Lub Roomba lub peev xwm los txheeb xyuas qhov sib txawv kom pom cov khoom kom raug
  • Rough Terrain Maneuvers: Zam pob zeb lossis thaj chaw tsaus
  • Phau ntawv hom: Nyob pub thiab muaj peev xwm los tswj lub Roomba
  • Duab: Cov duab ntawm cov zaub mov
  • Pom Lub Neej!: MatLab lub thawv ntawv cim qhia tias koj cov nroj tsuag tau txheeb xyuas cov organic.

Qhov ntawd yog qhov kawg ntawm peb qhov kev qhia, txaus siab rau koj qhov tshiab Mars Expedition Rover!

Pom zoo: