Cov txheej txheem:

Yuav Ua Li Cas Robo-Bellhop: 3 Kauj Ruam
Yuav Ua Li Cas Robo-Bellhop: 3 Kauj Ruam

Video: Yuav Ua Li Cas Robo-Bellhop: 3 Kauj Ruam

Video: Yuav Ua Li Cas Robo-Bellhop: 3 Kauj Ruam
Video: Yuav ua li cas By Nhia Lor [full version] 2024, Kaum ib hlis
Anonim

Los ntawm jeffreyfFollow Ntxiv los ntawm tus sau:

Yuav ua li cas nkag mus rau iRobot Tsim Scholarship mini-contest
Yuav ua li cas nkag mus rau iRobot Tsim Scholarship mini-contest
Yuav ua li cas nkag mus rau iRobot Tsim Scholarship mini-contest
Yuav ua li cas nkag mus rau iRobot Tsim Scholarship mini-contest
Yuav ua li cas LOLCats, Meme miv, Cat macros, lossis miv duab nrog cov lus tso dag
Yuav ua li cas LOLCats, Meme miv, Cat macros, lossis miv duab nrog cov lus tso dag
Yuav ua li cas LOLCats, Meme miv, Cat macros, lossis miv duab nrog cov lus tso dag
Yuav ua li cas LOLCats, Meme miv, Cat macros, lossis miv duab nrog cov lus tso dag
Yuav ua li cas nkag mus rau Etsy thiab Qhia Ntawv Sew Pab Kev Sib Tw
Yuav ua li cas nkag mus rau Etsy thiab Qhia Ntawv Sew Pab Kev Sib Tw
Yuav ua li cas nkag mus rau Etsy thiab Qhia Ntawv Sew Pab Kev Sib Tw
Yuav ua li cas nkag mus rau Etsy thiab Qhia Ntawv Sew Pab Kev Sib Tw

Txog: Kuv nyiam sib cais ib yam thiab xam seb lawv ua haujlwm li cas. Kuv feem ntau tsis txaus siab tom qab ntawd. Xav paub ntau ntxiv txog jeffreyf »

Cov Lus Qhia no qhia yuav siv iRobot Tsim los ua lub tswb nrov li cas. Qhov no tau raug tshem tawm tag nrho nrog kev tso cai los ntawm carolDancer cov lus qhia, thiab kuv muab tso ua qhov piv txwv nkag mus rau peb qhov kev sib tw. Robo-BellHop tuaj yeem yog koj tus kheej tus pab cuam nqa koj lub hnab, khoom noj khoom haus, khaub ncaws, thiab lwm yam, yog li koj tsis muaj rau. Qhov yooj yim Tsim muaj lub thoob txuas rau sab saum toj thiab siv ob lub on-board IR cov ntsuas kom ua raws nws tus tswv IR tus xa tawm. Nrog cov txheej txheem C yooj yim heev, tus neeg siv khoom tuaj yeem ruaj ntseg khoom noj hnyav, ntim khoom ntxhua khaub ncaws ntau, lossis koj lub hnab hmo ntuj mus rau Robo -BellHop thiab muaj tus neeg hlau ua raws koj qab ntawm txoj kev, los ntawm lub khw muag khoom, hauv lub tsev lossis hla lub tshav dav hlau - - Txhua qhov chaw uas tus neeg siv yuav tsum mus. Ua haujlwm yooj yim 1) Ntaus lub pob pib dua kom qhib qhov kev hais kom ua module thiab tshawb xyuas cov cuab yeej cuam tshuam 1a) Ua si LED yuav tsum mus thaum nws pom IR transmitter ua raws koj1b) Ua ntej LED yuav tsum mus thaum neeg hlau yog nyob ze ntawm qhov ze 2) Ntaus khawm dub kom khiav Robo-BellHop niaj hnub 3) Txuas IR tus xa mus rau pob taws thiab xyuas kom nws tau qhib. Tom qab ntawd nqa lub pob tawb thiab mus! 4) Lub tswv yim ntawm Robo-BellHop yog raws li hauv qab no: 4a) Thaum koj taug kev ncig, yog tias pom lub teeb liab IR, tus neeg hlau yuav tsav ntawm qhov nrawm tshaj 4b) Yog tias IR teeb liab tawm ntawm ntau yam (los ntawm kev nyob deb dhau lossis ntse dhau lub kaum ntse ntse), tus neeg hlau yuav hla kev luv luv ntawm qhov qeeb qeeb yog tias lub teeb liab raug khaws dua 4c) Yog tias tsis pom lub teeb liab IR, tus neeg hlau yuav tig sab laug thiab sab xis hauv sim nrhiav lub teeb liab dua 4d) Yog tias pom lub teeb liab IR tab sis tus neeg hlau tsoo qhov teeb meem, tus neeg hlau yuav sim tsav ib puag ncig qhov teeb meem 4e) Yog tias tus neeg hlau tau ze heev rau IR teeb liab, tus neeg hlau yuav tsum nres kom tsis txhob tsoo tus tswv lub luj tshibHardware1 iRobot virtual wall unit - $ 301 IR ntes los ntawm RadioShack - $ 31 DB -9 tus txiv neej txuas los ntawm Xov Tooj Cua - $ 44 6-32 ntsia hlau los ntawm Tsev Depot - $ 2.502 3V roj teeb, Kuv siv D1 ntxhua khaub ncaws los ntawm Lub Hom Phiaj - $ 51 lub log ntxiv rau hauv sab nraum qab ntawm Tsim Neeg Siv Hluav Taws Xob kab xev, xaim thiab cov laug

Kauj Ruam 1: Npog IR Sensor

Txuas daim kab xev hluav taws xob los npog txhua qhov tab sis qhov me me ntawm IR sensor nyob rau ntawm xub ntiag ntawm Tsim Neeg Hlau. Tshem tawm chav phab ntsa virtual thiab rho tawm lub rooj sib tham me me nyob rau ntawm xub ntiag ntawm chav tsev. Qhov no yog qhov nyuaj me ntsis vim tias muaj ntau ntau cov ntsia hlau zais thiab cov yas ntim. IR transmitter nyob ntawm lub rooj tsav xwm. Npog IR tus xa tawm nrog ib daim ntawv ntawm cov ntaub so ntswg kom tsis txhob cuam tshuam IR. Txuas lub rooj sib tham ntawm lub pluaj lossis cov hlua khi uas tuaj yeem qhwv ncig koj pob taws. Xaim cov roj teeb rau hauv pawg thawj coj saib kom koj tuaj yeem muaj lub roj teeb nyob hauv qhov chaw yooj yim (Kuv tau ua nws kom kuv tuaj yeem tso cov roj teeb rau hauv kuv lub hnab ris).

Xaim tus thib 2 IR ntes mus rau DB-9 txuas thiab ntxig rau hauv Cargo Bay ePort tus pin 3 (teeb liab) thiab tus pin 5 (hauv av). Txuas tus thib 2 IR ntes mus rau sab saum toj ntawm qhov tam sim no IR sensor ntawm Tsim thiab npog nws nrog ob peb txheej ntawm cov ntaub so ntswg kom txog thaum tus thib 2 IR ntes tsis pom tus emitter ntawm qhov deb uas koj xav kom Tsim Neeg Hlau kom nres kom los tsoo koj. Koj tuaj yeem sim qhov no tom qab koj tau nyem lub khawm Pib dua thiab saib ua ntej LED mus ntxiv thaum koj nyob ntawm qhov chaw nres tsheb.

Kauj Ruam 2: Txuas lub Pob tawb

Txuas lub pob tawb siv tus ntsia hlau 6-32. Kuv nyuam qhuav ntsia lub pob tawb mus rau sab saum toj ntawm Tsim Neeg Hlau. Kuj swb hauv lub log tom qab kom koj tso qhov hnyav nyob tom qab ntawm Tsim Neeg Hlau.

Sau tseg: - Tus neeg hlau tuaj yeem nqa lub nra me ntsis, yam tsawg 30 lbs. - Qhov me me zoo li yog qhov nyuaj tshaj plaws txog nws kom nqa tau txhua lub nra - IR yog kev npau taws heev. Tej zaum siv cov duab pom zoo dua tab sis nws kim dua

Kauj Ruam 3: Rub tawm Cov Cai Code

Download tau qhov Source Code
Download tau qhov Source Code

Cov cai hauv qab no, thiab txuas nrog hauv cov ntawv nyeem:

/********************************************************** ******************** follow.c ** -------- ** sau ntawm Tsim Cov Qauv Module ** npog tag nrho tab sis qhib me me rau ntawm xub ntiag ntawm IR sensor ** Tsim yuav ua raws lub phab ntsa virtual (lossis ib qho IR xa tawm ** lub zog quab yuam kev teb) thiab cia siab tias yuav zam dhau cov teeb meem hauv tus txheej txheem ***************** ********************************************************** ****** **/#suav nrog cuam tshuam.h>#suav nrog io.h>#suav nrog#suav nrog "oi.h"#txhais qhov tseeb 1#txhais FALSE 0#txhais FullSpeed 0x7FFF#txhais SlowSpeed 0x0100#txhais SearchSpeed 0x0100#txhais ExtraAngle 10#txhais SearchLeftAngle 125#txhais SearchRightAngle (SearchLeftAngle - 1000) #define CoastDistance 150#txhais TraceDistance 250#txhais TraceAngle 30#txhais BackDistance 25#txhais IRDetected (~ PINB & 0x01) // states#define Ready 0#txhais raws li 1#txhais WasFollowing #define SearchingLeft 3#txhais SearchingRight 4#txhais TracingLeft 5#txhais TracingRight 6#txhais BackingTraceLeft 7#txhais BackingTraceRight 8 // Ntiaj teb hloov pauv olintable uint16_t timer_cnt = 0; volatile uint8_t timer_on = 0; volatile uint8_t sensors_flag = 0; volatile uint8_t sensors_index = 0; volatile uint8_t sensors_in [Sen6Size]; volatile uint8_t sensors [Sen6Size]; volatile tsis pom kev = 0t; volatile uint8_t inRange = 0; // Functionsvoid byteTx (uint8_t tus nqi); void delayMs (uint16_t time_ms); void delayAndCheckIR (uint16_t time_ms); void delayAndUpdateSensors (unsigned int time_ms); void initialoid (void) baud (uint8_t baud_code); void drive (int16_t nrawm, int16_t radius); uint16_t randomAngle (tsis muaj dab tsi); void defineSongs (tsis muaj dab tsi); int main (void) {// state variableuint8_t state = Ready; int found = 0; int wait_counter = 0; // Teeb tsa Tsim thiab moduleinitialize (); LEDBothOff; powerOnRobot (); byteTx (CmdStart); baud (Baud28800); byteTx (CmdControl); byteTx (CmdFull); // teeb tsa i/o rau IR thib ob sensorDDRB & = 0x01; ua. // teeb tsa cov khoom xa khoom ePort tus pin 3 los ua lub tswv yimPORTB | = 0x01; // teeb tsa cov khoom thauj ePort pin3 rub tawm qhib // program loopwhile (TRUE) {// Nres ib qho kev ceev faj ceev ceev (0, RadStraight); // teeb tsa LEDsbyteTx (CmdLeds); byteTx (((sensors (SenVWall))?) LEDPlay: 0x00) | (inRange? LEDAdvance: 0x00)); byteTx (sensors [SenCharge1]); byteTx (64); IRDetected? LED2On: LED2Off; inRange? LED1On: LED1Off; // nrhiav tus neeg siv khawm, txheeb xyuas oftendelayAndUpdateSensors (10); delayAndCheck (10); yog (UserButtonPressed) {delayAndUpdateSensors (1000); // nquag siv sijhawm (! (UserButtonPressed) && (! Sensors [SenCliffL]) && (! Sensors [SenCliffFL]) && (! Sensors [SenCliffFR]) && (! sensors [SenCliffR])) {byteTx (CmdLeds); byteTx (((sensors (SenVWall])? ? LED2On: LED2Off; inRange? LED1On: LED1Off; hloov (xeev) {cov ntaub ntawv Npaj: yog (sensors [SenVWall]) {// kos rau qhov sib thooj rau leaderif (inRange) {tsav (0, RadStraight);} ntxiv {/ tsav ncaj nraim (SlowSpeed, RadStraight); xeev = Ua raws;}} ntxiv {// tshawb rau beamangle = 0; nrug = 0; tos_counter = 0; pom = FALSE; tsav (SearchSpeed, RadCCW); xeev = SearchingLeft;} tawg; rooj plaub Nram qab no: yog (sensors [SenBumpDrop] & BumpRight) {nrug = 0; angle = 0; tsav (-SlowSpeed, RadStraight); xeev = BackingTraceLeft;} lwm qhov yog (sensors [SenBumpDrop] & BumpLeft) {nrug = 0; kaum = 0; tsav (-SlowSpeed, RadStraight); xeev = BackingTraceRight;} lwm qhov yog (sensors [SenVWall]) {// kos rau sib thooj rau leaderif (inRange) {tsav (0, RadStraight); xeev = Npaj;} lwm tus {// tsav ncaj nraim (FullSpeed, RadStraight); xeev = Ua raws;}} lwm yam {// nyuam qhuav poob lub teeb liab, ua mus qeeb ib cycledistance = 0; tsav (SlowSpeed, RadStraight); xeev = WasFollowing;} tawg; rooj WasFollowing: yog (sensors [SenBumpDrop] & BumpRight) {nrug = 0; angle = 0; tsav (-SlowSpeed, RadStraight); xeev = BackingTraceLeft;} lwm tus yog (sensors [SenBumpDrop] & BumpLeft) {nrug = 0; lub kaum ntse ntse = 0; tsav (-SlowSpeed, RadStraight); xeev = BackingTraceRight;} lwm qhov yog (sensors [SenVWall]) {// txheeb xyuas qhov sib thooj rau tus thawj coj (inRange) {tsav (0, RadStraight); xeev = R eady;} lwm yam {// tsav ncaj nraim (FullSpeed, RadStraight); xeev = Ua raws;}} lwm qhov yog (nrug> = CoastDistance) {tsav (0, RadStraight); xeev = Npaj;} lwm yam {tsav (SlowSpeed, RadStraight);} tawg; rooj SearchingLeft: yog (pom) {yog (lub kaum sab xis> = ExtraAngle) {tsav (SlowSpeed, RadStraight); xeev = Hauv qab no;} lwm yam {tsav (SearchSpeed, RadCCW);}} ntxiv yog (sensors (SenVWall)) {pom = TRUE; kaum sab xis = 0; yog (inRange) {tsav (0, RadStraight); xeev = Npaj;} lwm qhov {tsav (SearchSpeed, RadCCW);}} lwm qhov yog (lub kaum sab xis> = SearchLeftAngle) {tsav (SearchSpeed, RadCW); tos_counter = 0; xeev = SearchingRight;} lwm qhov {tsav (SearchSpeed, RadCCW);} tawg; rooj SearchingRight: yog (pom) {yog (-angle> = ExtraAngle) {tsav (SlowSpeed, RadStraight); xeev = Ua raws;} lwm yam {tsav (SearchSpeed, RadCW);}} lwm qhov yog (sensors [SenVWall]) {pom = TRUE; lub kaum ntse ntse = 0; yog (inRange) {tsav (0, RadStraight); xeev = Npaj;} ntxiv {tsav (SearchSpeed, RadCCW);}} lwm qhov yog (tos_counter> 0) {tos_counter -= 20; tsav (0, RadStraight);} ntxiv yog (lub kaum sab xis = Tshawb nrhiav RightAngle) {tsav (0, RadStraight); tos_counter = 5000; lub kaum = 0;} lwm tus {tsav (SearchSpeed, RadCW);} tawg; rooj TracingLeft: yog (sensors [SenBumpDrop] & BumpRight) {nrug = 0; kaum = 0; tsav (-SlowSpeed, RadStraight); xeev = BackingTraceLeft;} lwm tus yog (sensors [SenBumpDrop] & BumpLeft) {tsav (0, RadStraight); xeev = Npaj;} lwm qhov yog (sensors [SenVWall]) {// kos rau qhov sib thooj rau tus thawj coj (hauvRange) {tsav (0, RadStraight); xeev = Npaj;} lwm tus {// tsav ncaj nraim (SlowSpeed, RadStraight); xeev = Ua raws;}} lwm qhov yog (! (nrug> = TraceDistance)) { tsav (SlowSpeed, RadStraight);} lwm qhov yog (! (-angle> = TraceAngle)) {tsav (SearchSpeed, RadCW);} lwm qhov {nrug = 0; kaum = 0; tsav (SlowSpeed, RadStraight); xeev = Npaj; } tawg; rooj TracingRight: yog (sensors [SenBumpDrop] & BumpRight) {tsav (0, RadStraight); xeev = Npaj;} lwm qhov yog (sensors [SenBumpDrop] & BumpLeft) {nrug = 0; angle = 0; tsav (- SlowSpeed, RadStraight); xeev = BackingTraceRight;} lwm qhov yog (sensors [SenVWall]) {// txheeb xyuas qhov sib thooj rau leaderif (inRang e) {tsav (0, RadStraight); xeev = Npaj;} ntxiv {// tsav ncaj nraim (SlowSpeed, RadStraight); xeev = Ua raws;}} lwm qhov yog (! (nrug> = TraceDistance)) {tsav (SlowSpeed, RadStraight);} lwm qhov yog (! (lub kaum sab xis> = TraceAngle)) {tsav (SearchSpeed, RadCCW);} lwm qhov {nrug = 0; kaum = 0; tsav (SlowSpeed, RadStraight); xeev = Npaj;} tawg; rooj BackingTraceLeft: yog (sensors [SenVWall] && inRange) {tsav (0, RadStraight); xeev = Npaj;} lwm qhov yog (lub kaum sab xis> = TraceAngle) {nrug = 0; lub kaum ntse ntse = 0; tsav (SlowSpeed, RadStraight); xeev = TracingLeft; } lwm tus yog (-distance> = BackDistance) {tsav (SearchSpeed, RadCCW);} lwm yam {tsav (-SlowSpeed, RadStraight);} tawg; rooj BackingTraceRight: yog (sensors [SenVWall] && inRange) {tsav (0, RadStraight); xeev = Npaj;} lwm qhov yog (-angle> = TraceAngle) {nrug = 0; kaum = 0; tsav (SlowSpeed, RadStraight); xeev = TracingRight;} lwm qhov yog (-distance> = BackDistance) {tsav (SearchSpeed, RadCW);} lwm tus {tsav (-SlowSpeed, RadStraight);} tawg; default: // stopdrive (0, RadStraight); xeev = Re ady; so;} delayAndCheckIR (10); delayAndUpdateSensors (10);} // pob tsuas lossis tus neeg siv lub pob tshawb pom, tso cai ua kom ruaj khov (piv txwv li, khawm kom tso tawm) tsav (0, RadStraight); delayAndUpdateSensors (2000);}}} // Serial tau txais kev cuam tshuam los khaws cov txiaj ntsig sensorSIGNAL (SIG_USART_RECV) {uint8_t temp; temp = UDR0; yog (sensors_flag) {sensors_in [sensors_index ++] = temp; yog (sensors_index> = Sen6Size) sensors_flag = 0;}} // Timer 1 cuam tshuam mus rau lub sijhawm qeeb hauv msSIGNAL (SIG_OUTPUT_COMPARE1A) {yog (timer_cnt) timer_cnt-; elsetimer_on = 0;} // Xa ib lub byte hla tus lej portvoid byteTx (uint8_t tus nqi) {thaum (! (UCSR0A & _BV () UDRE0)) UDR0 = tus nqi;} // Ncua sijhawm rau lub sijhawm tshwj xeeb hauv ms yam tsis tau hloov kho qhov tseem ceeb sensor tsis txhob ncua ms (uint16_t time_ms) {timer_on = 1; timer_cnt = time_ms; thaum (timer_on);} // Ncua sijhawm rau lub sijhawm tshwj xeeb hauv ms thiab kos thib ob IR detectorvoid delayAndCheckIR (uint16_t time_ms) {uint8_t timer_val = 0; inRange = 0; timer_on = 1; timer_cnt = time_ms; thaum (timer_on) {yog (! (Timer_val == timer_cnt)) {inRange + = IRDetected; timer_val = timer_cnt;}} inRange = (inRange> = (time_ms >> 1));} // Ncua sijhawm rau lub sijhawm teev tseg hauv ms thiab hloov kho qhov tseem ceeb tsis txhob ncuaAndUpdateSensors (uint16_t time_ms) {uint8_t temp; timer_on = 1; timer_cnt = time_ms; thaum (timer_on) {yog (! sensors_flag) {rau (temp = 0; temp Sen6Size; temp ++) sensors [temp] = sensors_in [temp]; // Hloov tshiab khiav tag nrho ntawm qhov deb thiab angledistance += (int) ((sensors [SenDist1] 8) | sensors [SenDist0]); kaum sab xis += (int) ((sensors) [SenAng1] 8) | sensors [SenAng0]); byteTx (CmdSensors); byteTx (6); sensors_index = 0; sensors_flag = 1;}}} // Initialize Lub Siab Tswj & aposs ATmega168 microcontrollervoid initialize (void) {cli (); // Teeb I/O pinsDDRB = 0x10; PORTB = 0xCF; DDRC = 0x00; PORTC = 0xFF; DDRD = 0xE6; PORTD = 0x7D; // Teeb tsa timer 1 los tsim kev cuam tshuam txhua 1 msTCCR1A = 0x00; TCCR1B = (_BV) (WGM12) | _BV (CS12)); OCR1A = 71; TIMSK1 = _BV (OCIE1A); // Teeb tsa qhov chaw nres nkoj txuas nrog rx cuam tshuam UBSR0 = 19; UCSR0B = (_BV (RXCIE0) | _BV (TXEN0) | _BV (RXEN0))); UCSR0C = (_BV (UCSZ00) | _BV (UCSZ01)); // Qhib kev cuam tshuam cuam tshuam ();} tsis muaj zog OnRobot (tsis muaj dab tsi) {// Yog Tsim & aposs lub zog raug kaw, tig nws onif (! RobotIsOn) {thaum (! RobotIsOn) {RobotPwrToggleLow; delayMs (500); // Ncua hauv lub xeev noRobotPwrToggleHigh; // Tsawg rau siab hloov mus rau toggle powerdelayMs (100); // Ncua hauv lub xeev noRobotPwrToggleLow;} delayMs (3500); // Ncua rau kev pib}} // Hloov tus nqi baud ntawm ob qho Tsim thiab modulevoid baud (uint8_t baud_code) {yog (baud_code = 11) {byteTx (CmdBaud); UCSR0A | = _BV (TXC0); byteTx (baud_code);/ / Tos kom txog thaum kis tau tiav (! (UCSR0A & _BV (TXC0))); cli (); // Hloov pauv baud tus nqi registerif (baud_code == Baud115200) UBRR0 = Ubrr115200; lwm tus yog (baud_code == Baud57600) UBRR0 = Ubrr57600; lwm yog (baud_code == Baud38400) UBRR0 = Ubrr38400; lwm yog (baud_code == Baud28800) UBRR0 = Ubrr28800; lwm yam yog (baud_code == Baud19200) UBRR0 = Ubrr19200; lwm yam yog (baud_code == Baud14400) UBRR0 = UbrR0 = lwm yam yog tias (baud_code == Baud9600) UBRR0 = Ubrr9600; lwm tus yog (baud_code == Baud4800) UBRR0 = Ubrr4800; lwm yam yog (baud_code == Baud2400) UBRR0 = Ubrr2400; lwm yam yog (baud_code == Baud1200) UBRR0 = Ubrr12 baud_code == Baud600) UBRR0 = Ubrr600; lwm qhov yog (baud_code == Baud300) UBRR0 = Ubrr300; sei (); delayMs (100);}} // Xa Tsim cov lus txib raws li qhov nrawm thiab tsis siv lub vojvoog (int16_t nrawm, int16_t radius) {byteTx (CmdDrive); byteTx ((uint 8_t) ((tshaj tawm >> 8) & 0x00FF)); byteTx ((uint8_t) (tshaj tawm & 0x00FF)); byteTx ((uint8_t) ((radius >> 8) & 0x00FF)); byteTx ((uint8_t) (radius & 0x00FF));}

Pom zoo: