Sei sulla pagina 1di 27

University of Florida Department of Electrical Engineering EEL 5666 Intelligent Machines Design Lab

Mr. Firefly
by Steven La ha !r. Instr"ctor# Dr. $ntonio $. $rroyo December %&' ()))

*able of +ontents

$bstract E,ec"tive S"mmary Introd"ction Integrated System Mobile latform $ct"ation Sensors .ehaviors +oncl"sion Doc"mentation $ppendices

& 5 5 6 6 6 %% %( %& %-

$bstract Mr. Firefly is a robot based on the idea that everyone can use an extra hand around the house or office. This robot will also provide a simple natural interface so that anyone can easily use the robot with little preparation. The robot will also provide an advanced platform for a variety of programs to create a variety of different functions without many hardware changes.

E,ec"tive S"mmary Mr. Firefly is an entertainment and personal assistant robot. The main purpose of Mr. Firefly is to provide a base that can be easily upgraded with different programs to provide various entertainment and personal assistant abilities. Mr. Firefly is outfitted with bump switches, infrared detectors, motion detectors, an RF transmitter, and a speech synthesi er. The bump switches and infrared detectors allow Mr. Firefly to avoid hitting obstacles or to correct himself when he does. This follows !saac "simov#s first and third laws of robotics, to prevent the in$ury of humans from the robot, and to protect the robot#s own existence. The two infrared detector%emitter pairs are placed in a cross&view pattern, attached with a type of 'elcro so they can be ad$usted. The three Motion detectors placed at (2) degrees from each other give the robot a social behavior, it allows him to locate human movement and go toward it. These help it interact with humans. This will be a useful behavior in the case where the robot could be programmed as a pet. !f the robot is to be used li*e a personal assistant it can follow its +master, around to be at his call. The voice synthesi er provides a way for the robot to communicate with its owner. The voice synthesi er can be used to say anything as it ta*es in "-.!! text and outputs near perfect speech. For a pet program it can be used to bar*, or meow, or even chirp. For an assistant program it can say a schedule, and even has the ability to dial /TMF tones, so it could even hold phone numbers given the proper programming. "dditionally there is the RF receiver, voice recognition, and 01/ face modules, which at this point were not added due to some problems with the remote board and programming deadlines. These will allow the robot to respond to human commands, and interact with a face that provides human to almost human interaction.

Introd"ction The design of Mr. Firefly is based around the home or home office. Mr. Firefly is li*e a personal secretary. !t would allow the user to manage phone calls, and to *eep trac* of the day#s events. Mr. Firefly also provides a friendly human to +almost human, interface. ! feel this is most important, because it allows people to get used to the idea of wor*ing with robots without having to tal* to a box. 3erhaps this will even smooth the transition to the possible future of androids. This pro$ect has one main ob$ective, to create a helpful robot that is easy and almost natural to use. There are a few parts that accomplish this ob$ective on this robot pro$ect. The robot should respond to a set of voice commands thus freeing the owner from some form of remote or having to touch the robot. To increase the compatibility of the robot with the user it should also have a voice synthesis system to allow it to spea* to the user increasing the human li*e interface, and a display as a +face,. The robot will also interact with the telephone. This will let the user use the telephone through the robot, hands free, also reducing the need to find a nearby telephone. "lso the pro$ect should allow for other types of software programs to be downloaded to the robot changing it#s ma$or function. 4ne example is by downloading new code it should be able to turn into a robotic pet without need for too many additional sensors if any. Through each part of the pro$ect the coding should be done so the robot will be entertaining in it#s final result, ma*ing it appealing to the general public as well as the user. The integrated system of Mr. Firefly will use a variety of circuits to perform the voice synthesis and recognition as well as the display. The mobile platform will be similar to the Talri* platforms, rolling on two motori ed wheels in a tricycle fashion. "ctuation will be provided through mostly two servos and additional parts to create the various functions. " variety of sensors will allow the robot to move autonomously and behave appropriately. The behaviors will allow the robot to interact with humans in a way so that it acts more as an animal or human than a robot. The robot will also go through a series of experiments to test each of the wor*ing systems and integrate them into the circuit. Integrated system Mr. Firefly#s system will wor* much li*e a star networ*, having one central processor that sends and receives information though the processor. !n this system, for example, the voice synthesis will not have any contact with the voice command system. The main components will be a Motorola 567.(( processor, voice synthesis control system, voice recognition control software, display control system, and sensor interface controls.

RF Transmitter

RF Receiver T93R4 :oard

/isplay Face

'oice Recognition

M-.(( -ingle chip Remote :oard

'oice -ynthesis

-ensors

Mobile platform Mr. Firefly#s platform relies mostly upon the design of the T93ro and Talri* frames. The robot will roll around on 2 primary wheels controlled by servos, with a third nub to balance the robot. The main frame was created using 2 types of plastic, a flexible yellow for the main dis*, and a rigid blac* plastic for the body. The design is similar to the T93ro but larger, and with some modifications.

(Figure 1 - Platform parts)

$ct"ation The ma$ority of the actuation in Mr. Firefly will be to move the robot around and controlling its behaviors. The main drive functions will be performed by two servos controlling 2 wheels. The servos were hac*ed using the !M/0%Me*atronix method for continuous rotation. To try to center the servos ;ad$ust the potentiometers so they are e<ual= ! first tried to let the servo ad$ust itself by moving the servo using the motorp command and then setting it bac* to ). The servo commands probably would have fixed this problem but at the time ! didn#t *now about them. ! ad$usted the potentiometers so that they resistances were balanced at +center,. Sensors The behaviors of Mr. Firefly will depend highly on the various sensors. 'oice recognition will be used to deliver commands to the microcontroller. !nfrared detectors

and 01/#s will be used for collision avoidance, and give approximate distances to nearby ob$ects. :ump switches will be used to determine when the robot has come into contact with some ob$ect. Motion detecting of some sort will be used to guide the robot toward its user or toward the nearest human activity. -haft encoders will be used to try to *eep trac* of how far the robot has traveled for future programming, and possibly used to guide it bac* to a recharging station. :ump -witches ! used 5 bump switches, at about 5) degrees apart. The front one, left, right and all the bac* were separated from each other using the voltage divider mentioned in class ;also pictured below=.

(Figure 2 - Converting bump switches to an analog value)

-witches Front Right 0eft Front and 0eft Front and Right :ac* and any other !nfrared /etector -ensor

0ow "nalog 'alue 8 28 68 ()) 5) 2))

7igh "nalog'alue 3) 88 >8 ()8 ?) 288

(Table 1 - approximate values for bump switches)

For avoiding obstacles ! used a set of 2 infrared detector%emitter pairs. These were created by collimating the !nfrared diodes and gluing them so they face the same direction as the detectors. These have a type of 'elcro attached so they can be attached to the main dis*, but still remain movable. The type of fastener ! used wor*s li*e 'elcro but each side is composed of mushroom shape hoo*s, this allows it to be fastened to itself and is also much sturdier than regular 'elcro, and it has an audible clic* when fastened tight. The values from the detector range from 68 to 288, ! chose to use >) and ()) as limits for when it detects an obstacle. "t >) it turns very gradually, at ()) it turns abruptly and goes in another direction dependent on the angle it ma*es with the wall.

(Figure 3 - nfrare! !etector emitter pair)

Motion /etector -ensor 4ne of my special sensors was a set of 3 motion detectors. @ith the sensors, the robot should be able to navigate toward human movement. @hen it detects movement it will rotate toward the movement and then go forward. !deally without any other people in the area, it should be able to follow the user. This gives it a sociable behavior much li*e a pet or some humans. ! bought the motion detector modules from -*ycraft of 4rlando. They had no pinouts so ! had to use the pinouts of the chips on the inside to find power and ground. The module runs on a 3.3' supply, but has it#s own voltage regulator so it runs on 8' power. The pins turned out to be, from left to right in the picture of the circuit below, ground, signal, and power. ! hoo*ed this up to the analog port directly to see what *ind of response ! would get. The graph below shows the results, which held true for at least 6 feet.

(Figure " - #$-hac%e! &otion !etector output)

The module acted li*e a permanent switch staying at about 2 volts then going to around ero and staying there until reset. This would be good for cases where only one movement is needed to be recorded. 7owever, my robot needed a continuous signal to detect heat without being reset. ! found some pyroelectric detectors are powered by 8' and give out a continuous signal of 2.8' with no motion, and when motion is detected,

the voltage goes to 8' then to )', or vice versa dependent on direction. ! placed an oscilloscope on the various legs of the chips, which would be easiest to connect to, and simpler then having to search through the surface mount and traces on the opposite side. ! tested each of the pins and got various heat related signals, ! chose pin one of the Motorola chip because it seemed to be the best response for what ! needed, and gave a good distance for detecting the heat. To ma*e it easy ! clipped the original signal pin and attached the first pin of the Motorola chip to that signal pin with a soldered wire. This would ma*e the module almost identical as the original, only giving a continuous signal output. /ue to the nature of the T93ro board ! had to modify the wires leading to the detector from the board so, ! could get the proper signal on the proper wire. :elow is a diagram of the circuit after being hac*ed, the gray wire is the hac*ed signal being brought out to the connector. "fter seeing how the signal changed with the two variable resistors, ! choose to *eep them as they were from the factory, all the others limited my range of heat detection. Aotice the 3lastic housing on the pyroelectric detector this gives the detector about (6) degrees of freedom. The chart below shows the values ! received for different distances. This shows that ! get a good range of values, which can be used to show the robot that heat is present. To get the data for the chart ! used a simple analog recording program that sends the data to the terminal window in !.., which has a capture option. ! used excel to ta*e that list of comma separated values and create the graph of data. My program is listed in the appendices as "nalog(.c.

(# 2# 3# 2# 8# &distances from motion detector &

5#

?#

6#

pyroelectric sensor
(Figure ' - &otion !etector circuitr() (Figure ) - *ac%e! motion !etector !ata)

These motion sensors tend to be unpredictable at times. The output depends highly on the settings of the two variable resistors, and since ! have no data, ! set them to be the same as the best wor*ing one. This seems to be with the resistors set at almost ero. RF Transmitter and Receiver !n my final design ! could not get the RF communication wor*ing as ! could not get the remote board wor*ing. The RF modules were from Reynolds 1lectronics

>

;7ttpB%%www.rentron.com=. ! did test the RF modules by hoo*ing the serial data out of the robot board to the transmitter, and connected the receiver module to the serial cable connected to the .4M board to the computer. ! used the analog displaying program on the robot and *ept the speed at >5)) on the board. The two boards were separated by about 3&2 inches but had no antenna. The data was almost exactly the same, at the beginning of every line there were some errors, but at a lower speed and with an antenna the data would probably be a lot better and able to go the distance of 2))C feet ;as per the data sheet=.

(Figure + - ,F mo!ules - from ,e(nol!s .lectronics !atasheets)

'oice Recognition "dditionally without a wor*ing remote board, the voice recognition module could not be used. ! first tried ma*ing my own voice recognition module. .ircuit .ellar !AD had an article in their February (>>6 issue by :rad -tewart. This one claims to offer (5& word voice recognition for around E8. This one uses a 5?7.?)8 and some amplification circuitry. ! had little experience with the ?)8 and could not alter it to be used on the 567.(( so ! decided to try that when ! had more time to wor* on it. ! eventually bought the 'oice /irect 352 from -ensory !nc. ;7ttpB%%www.sensoryinc.com=. This module offers (8&word recognition in stand&alone mode and up to 5) words if controlled with a microprocessor. The stand&alone mode re<uires only a few switches, a spea*er, microphone, and 01/s or some output reading device for eight bits of data. The device also has voice prompts ma*ing it easy to use. $dditional mod"les -peech -ynthesis To create a more realistic robot ! purchased the R.658) 'oice -ynthesi er from R. -ystems ;7ttpB%%www.rcsys.com%=. ! was trying to create a more humanistic interface between the robot and it#s owner. The synthesi er also has many features includingB ? voices, /TMF tone generator, variable pitch, speed, reverb, and on board voice storage. "ll of the controls can be delivered li*e the speech via a serial connection, or an 6&bit !%4 interface. 1ven volume can be ad$usted via these communications. The amount of features made this board very promising in that it could provide much more with minimum programming. The board even has it#s own buffer so it can analy e the speech data and pronounce the words properly, most words it correctly pronounces. There is also a way to change how it pronounces any word.
()

To interface the board, ! connected the serial out of the -.! of the T93R4 board to the -erial input of the voice synthesi er. This meant that ! could say anything simply by using a printf statement in my code. This helped when debugging my system as ! could have it tell me what mode it was in. 4ne problem with loops is that it tends to repeat what it says a few times if not handled properly. "lso when using !.., the speech tends to isolate itself from the other commands, so when designing a demo involving the speech and the motors, all the motor commands ended up running at once and the speech continued over the speech. For my demo with this problem, ! choose to run the motors first and then have it do the tal*ing. 01/ matrix display To provide a better human response to the idea of a robot ! thought the idea of a face would ma*e it more li*e a human. ! got the idea from the 4ctober 2))) issue of Auts and :olts. !n this article, the person creates an 6x6&display face using the Maxim M"F?2(> display driver ;7ttpB%%www.maxim&ic.com=. This can drive 6 seven&segment displays, or an 6x6 matrix. These chips have information in the datasheets that allow it to be hoo*ed up to an -3! system. This made the displays easy to use and provided all the scan coding needed to *eep the display lit. :elow is the wiring diagram, for the opposite side ! switched the columns so ! could get a mirror image and minimi e coding.

(Figure / - 0.1 matrix wiring !iagram)

/ue to time delays, ! did not get around to programming the display so ! left that as a future improvement. !t should be simple to code but at this point, ! felt it was best ! wor* on the sensors before wor*ing on advancements. .ehaviors The ma$or behavior of Mr. Firefly is that of a servant, following his master around responding to commands. !t should be able to answer the telephone on command. !n addition, it should read various groups of information upon command. @hen left alone it should go into sleep mode if no activity is around for it to follow. 1very so often it should wa*e up chec* for activity, then go bac* to sleep until it finds activity.

((

"dditionally ! hope to add the programming to the robot, so that when not needed as a servant and has run out of other entertainment, it can become a pet cat or pet dog in a limited capacity. !n this mode, it would continue to go toward activity, bar*ing or meowing, and responding to certain sensors. This mode would be mostly for the purpose of entertainment and to blend in more than a box $ust following the user around. The +following, behavior also called a +sociable behavior, to perform this ! will use the motion detectors. The robot will get a rough estimate of where movement is by receiving a signal from one of three motion detectors placed at 3 points on the robot. @hen one is triggered it will rotate in that direction some limited amount and continue its normal forward motion. !f a person continues to move the robot should ad$ust itself accordingly. !f the person does not move, yet the robot is moving this should trigger the sensor as well allowing it to locate any person in a room. This robot will not follow $ust it#s user, it will go toward any large heat source. This is one of the problems but assuming there are no radiators in the room, and the robot is limited to a small area this shouldn#t be a problem as it will only be +friendly, to all people not $ust the user. This behavior can easily be used for a program to turn the robot into a pet dog or even a security robot. This behavior has a variety of uses, which will allow changes in the program for many uses. The communication uses the two RF modules to send or receive data depending how it is connectedG they are connected to the -.! lines and the .4M boards. .urrently the robot has collision avoidance, collision detection, through RF can be set up to send data to a computer terminal, and to move toward heat. +oncl"sion "t the end of this term, Mr. Firefly is a partial success. Mr. Firefly can now move around avoiding hitting into obstacles or ad$ust himself when he does hit an ob$ect. Mr. Firefly can also move toward humans in a very rough manner. Mr. Firefly is also able to spea* any programmed words. 3resently he ma*es comments to what happens to him, he says +4uch, when he hits a wall, tells the people around him where he is trying to go toward with sayings li*e +hey you on the right., :asically, for now he acts li*e a tal*ing pet dog, following his master around and +bar*ing, comments. ! hope to further advance this robot to its full potential. !f ! can get the single chip board wor*ing ! should be able to add the RF, and voice recognition. @ith some more programming time, ! should be able to add the 01/ matrix display.

(2

Doc"mentation /eagan, Tim, 3rosthetic -arcasm with 1moticons for -peech, Auts and 'olts, 4ctober 2))) pg. ()&(2. 9.0. 9ones, :. ". -eiger, ". M. Flynn, Mobile Robots !nspiration to !mplementation, -econd 1dition. " D 3eters, Aatic*, M", (>>>. Martin, Fred, The 5.2?) Robot :uilders Huide. M!T, (>>2. Me*atronix T9 3ro Manual, (>>8. Me*atronix M-..(( Manual, (>>8. -tewart, :rad, 0ow .ost 'oice Recognition, .ircuit .ellar !AD, February (>>6. /atasheets for the RF modules, Max?2(> chip, 01/ displays, -peech synthesi er, 'oice direct 352. Special *han/s *o /r. "rroyo /r. -chwart Rand .handler -cott Aortman "ll the fellow !M/0 students Hail and -teve 0a3ha Maxim semiconductors @ithout their help, support, and patience my robot would not have been possible.

(3

$ppendices
"ppendix " /iagrams of the main systems and wiring ;not all wires shown=

(Figure ,emote boar! la(out)

(Figure &ain boar! la(out)

(2

"ppendix : 3rice list of ma$or parts


3art -ervos T93R4 board ;asmb= !R detectors !R emitters M-.(( board 'oice /irect 352 01/s 01/ 6x6 Matrix Max?2(> display chips RF RF%TF Resistors and Misc. "ntenna 3lastic sheets Motion /etectors 3urchased from Me*atronix Me*atronix Me*atronix Me*atronix Me*atronix "ll 1lectronics ;-ensory !nc.= "ll 1lectronics 7ttpB%%www.allelectronics.com 7osfelt 7ttpB%%www.hosfelt.com Maxim&!. 7ttpB%%www.maxim&ic.com Reynolds 1lec. 7ttpB%%www.rentron.com -*ycraft and 1lectronics plus -*ycraft -*ycraft -*ycraft 3rice E().)) E58.)) E3.)) E(.)) E().)) E8).)) E.(8&E.8) E(.)) E).)) E().)) ITJ 2 ( 3 3 ( ( 2 2 2 2 Total E2).)) E58.)) E>.)) E3.)) E().)) E2>.>8 E(.3) E2.)) E).)) E2).))

E(.)) E(.)) E3.))

( 3 3

E(.)) E3.)) E>.))

"ppendix .
.ode for Mr. Firefly "nalog(.c /******************************************************************** * Title: analog1.c * * Programmer: Steven LaPha Jr. * * Date: 10/24/2000 * * Version: 1.0 * * Description: To log the ata receive !rom an" analog * * sensor hoo#e $p to the analog%1& port * * on the t'pro (oar . * ********************************************************************/ /*********************)ncl$ es**************************************/ *incl$ e +t'p(ase.h, *incl$ e +analog.h, *incl$ e +st io.h, /********************-onstants**************************************/ * e!ine sensorval analog%1& /********************.ain program***********************************/ voi main %voi & / int sense0 i0 '0 #1 init2analog%&1 *%$nsigne char*& 03400050304 1 /* t$rn on )6 emitters*/ print!%78nalog Val$es o! Sensor7&1

(8

'511

9hile %1& / sense 5 sensorval1 print!%7: 0;t : 0;n70 '0 sense&1 !or %i501 i+<0001 i==&1 '5'=11 >

> %KKKKKKKKKKKKKKKKKKKKKK1nd "nalog(.cKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% "nalogall.c %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK K TitleB analogall.c K K 3rogrammerB -teven 0a3ha 9r. K K /ateB ()%22%2))) K K 'ersionB (.) K K /escriptionB To log the data recieved from any analog sensor hoo*ed up to the analog;2= K K port on the t$pro board. K K K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK!ncludesKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% Linclude Mt$pbase.hN Linclude Manalog.hN Linclude Mstdio.hN %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK.onstantsKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% Ldefine sense) analog;)= Ldefine sense( analog;(= Ldefine sense2 analog;2= Ldefine sense3 analog;3= Ldefine sense2 analog;2= Ldefine sense8 analog;8= Ldefine sense5 analog;5= Ldefine sense? analog;?= %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKMain programKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void main ;void= O int i, $G initPanalog;=G K;unsigned charK= )x?)))Q)xFF G %K turn on !R emittersK% printf;R"nalog 'alues of -ensor Sn SnR=G printf;R"nalog), "nalog(, "nalog2, "nalog3, "nalog2, "nalog8, "nalog5, "nalog?GSnR=G $Q(G while ;(= O printf;RTd,St Td,St Td,St Td,St Td,St Td,St Td,St Td,St Td SnR, $, sense), sense(, sense2, sense3, sense2, sense8, sense5, sense? =G for ;iQ)G iM2)))G iCC=G $Q$C(G U U %KKKKKKKKKKKKKKKKKKKKK1nd "nalogall.cKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK%

(5

t$pff.h %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK K Title t$pbase.h K 3rogrammer Deith 0. /oty % -teven 0a3ha 9r. K /ate /ecember 2, 2))) K K 'ersion (.( with servo drivers K K /escription K K .ollects include files and general constants into one file. Kmodified by -teven 0a3ha 9r. for Mr. Firefly KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %KKKKKKKKKKKKKKKKKKKKKKKKKKK !ncludes KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% Linclude Manalog.hN Linclude Mcloc*t$p.hN Linclude Mmotort$p.hN Linclude Mservot$p.hN Linclude Mserialtp.hN Linclude Misrdecl.hN Linclude Mvectors.hN %KKKKKKKKKKKKKKKKKKKKKKKK 1nd of !ncludes KKKKKKKKKKKKKKKKKKKKKKKKKKKK% %KKKKKKKKKKKKKKKKKKKKKKKKKKKK .onstants KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% Ldefine 01FTPM4T4R ) Ldefine R!H7TPM4T4R ( Ldefine M"FP-311/ ()) Ldefine V1R4P-311/ ) Ldefine -T"RT Ldefine -@T.7 Ldefine :WM31R Ldefine R!H7TP!R Ldefine 01FTP!R Ldefine RMotion/ Ldefine 0Motion/ Ldefine :Motion/ Ldefine '4!.1 Ldefine R"A/4M Ldefine FR4ATP:WM3 Ldefine R!H7TP:WM3 Ldefine 01FTP:WM3 Ldefine F0P:WM3 Ldefine FRP:WM3 Ldefine :".DP:WM3 Ldefine RM/ Ldefine 0M/ Ldefine :M/ while;:WM31RM()= analog;)= analog;(= analog;2= analog;3= analog;2= analog;8= analog;5= analog;?= T.AT ;:WM31RN8=XX;:WM31RM3)= ;:WM31RN28=XX;:WM31RM88= ;:WM31RN68=XX;:WM31RM>8= ;:WM31RN())=XX;:WM31RM()8= ;:WM31RN5)=XX;:WM31RM?)= ;:WM31RN2))= ;RMotion/M>)= ;0Motion/M>)= ;:Motion/M>)=

K K K K K K K

(?

%K 1nable 4.2 interrupt and all servo operations K% Ldefine -1R'4-P4A -1TP:!T;TM-D(,)x()= %K/isable 4.2 interruptB -tops all servo holding tor<ues, useful for energy savingsK% Ldefine -1R'4-P4FF .01"RP:!T;TM-D(, )x()= Ldefine !R1P4A K;unsigned char K=;)x?)))= Q )x)? Ldefine !R1P4FF K;unsigned char K=;)x?)))= Q )x)) %KKKKKKKKKKKKKKKKKKKKKKKK 1nd of .onstants KKKKKKKKKKKKKKKKKKKKKKKKKKKK% mrflyf3.c %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KTitleB mrflyf.c K3rogrammerB K/ateB K'ersionB3.) K K/escriptionBmain program for Mr. Firefly. K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %KKKKKKKKKKKKKKKKKKKKKKKK!ncludesKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% Linclude Mt$pff.hN Linclude Mstdio.hN %KKKKKKKKKKKKKKKKKKKKKKKK.onstantsKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% int MotorR, Motor0, !RR7,!RR0, !R07, !R00G int iG int 0!R, R!RG int sayG int processG %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKMain programKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void main ;void= O %KKKKKKKKKKKKKKKKKKKKKKKK!nitsKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% initPanalog;=G K;unsigned charK= )x?)))Q)x)? G %K turn on !R emittersK% initPmotort$p;=G initPcloc*t$p;=G %KKKKKKKKKKKKKKKKKKKKKKKKprogramKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %% configure;=G if ;-@T.7N())= O %% demo speech -T"RTG sayQ8G while;sayYQ)= O sayQ8G K -teven 0a3ha 9r. K (2%2%2))) K

(6

spea*;say=G while ;sayQQ8=OUG sayQ5G spea*;say=G while ;sayQQ5=OUG sayQ?G spea*;say=G while;sayQQ?=OUG sayQ6G spea*;say=G while;sayQQ6=OUG wait;2))=G sayQ)G wait;()))=G U U -T"RTG motors;3),3)=G setmotor;=G configure;=G while ;(= O %% sensors;=G behavior;=G setmotor;=G spea*;say=G wait;2)=G

U U %KKKKKKKKKKKKKKKKKKKKK1nd 3rogramKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %KKKKKKKKKKKKKKKKKKKKKKFunctions KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %%sets motor speed to be even void motors;int ml, int mr= O if ;mlN)= Motor0QmlC52G else Motor0QmlG if ;mrM)= MotorRQmr&52G else MotorRQmrG U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void configure;void= O !RR0Q>)G !R00Q>)G !RR7Q())G !R07Q())G U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void smooth;int $, int *=

(>

O int iG if ;$N)= O Motor0QMotor0K$%;$C(=G for;iQ)GiM8)GiCC=G U if ;*N)= O MotorRQMotorRK*%;*C(=G for;iQ)GiM8)GiCC=G U U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void setmotor;void= O motorp;01FTPM4T4R,MotorR=G motorp;R!H7TPM4T4R, Motor0=G U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %%not fully wor*ing, wor* in progress void rotate;int angle= O int iG if ;angleN)= O motors;8),&8)=G for ;iQ)G iMangleGiCC=G motors;3),3)=G U else O angleQ&angleG motors;&8),8)=G for ;iQ)G iMangleGiCC=G motors;3),3)=G U U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void spea*;int says= O int i,xG xQ(G %%front bumper if ;saysQQ(= O printf;R4uch that hurts. SnR=G saysQ)G sayQ)G U %%right bumper if ;saysQQ2= O printf;R1xcuse me. SnR=G

2)

saysQ)G sayQ)G U %%left bumper if ;saysQQ3= O printf;R7ey watch out. SnR=G saysQ)G sayQ)G U %%bac* bumper if ;saysQQ2= O printf;R4ooops. SnR=G saysQ)G sayQ)G U %% demo if ;saysQQ8= O printf;RHood afternoon 0adies, Hentlemen, and fellow robots.SnR=G wait;())=G printf;RThis is !.M./.0., Fall 2))). SnR=G wait;8)=G printf;RMy Aame is Mister Fire&fly. SnR=G wait;8)=G printf;RMy robot is -teven 0aphay $unior. SnR=G wait;8)=G printf;RMy robot builds people li*e me, stays up late, procrastinates, but is the smartest robot ! *now. Sn R=G wait;8)=G printf;R.ourse ! only *now one robot. haaaa haaaa haaaaa. SnR=G wait;3)=G printf;R1nough about my robot, now on to what ! can doY Sn R=G wait;()))=G wait;())=G motorsinst;3),3)=G wait;()))=G motorsinst;),)=G wait;()))=G motorsinst;),2)=G wait;3)=G motorsinst;),&2)=G wait;()))=G motorsinst;),)=G wait;())=G motorsinst;2),)=G wait;()))=G motorsinst;),)=G wait;3)=G motorsinst;2),&2)=G wait;()))=G motorsinst;),)=G wait;())=G printf;R "s you can see, ! move around on my own free will.SnR=G wait;())=G

2(

printf;R! can move left, right, bac*wards, and forwards.SnR=G wait;())=G printf;R!Zve also been, dec*ed out, in all these state of the art, electronic gi mos. SnR=G wait;2))=G saysQ)G sayQ)G U if ;sayQQ5= O printf;R4ne of my gi mos, that is still being wor*ed on, is a voice recognition unit. SnR=G wait;5)=G printf;R!t will then allow me to understand from, (8 to 5), human wordsR=G wait;2))=G printf;R That reminds me of a $o*e. SnR=G wait;5)=G printf;R" robot, trained to obey all human commands was sitting in a court room. SnR=G wait;5)=G printf;RThe $udge said, 4rder in the .ourtroom. SnR=G wait;5)=G printf;R The robot <uic*ly got up and said, ! will have an oil sha*e and a bolt sandwich, hah hah SnR=G wait;3))=G printf;R 7ey if you donZt li*e the $o*es, you write them next time.SnR=G wait;2))=G saysQ)G sayQ)G U if ;sayQQ?= O printf;R! am also e<uiped with 3 motion detectors, these tell me roughly where humans are in the room. SnR=G wait;2))=G printf;RAot that ! always want to be around humans. 9ust *idding.Sn R=G wait;())=G printf;R"ctually ! am a little blind sometimes, so donZt feel offended if ! ignore you. SnR=G wait;(8)=G printf;R!tZs $ust that your magnifisance tends to overwhelm me. SnR=G wait;8))=G printf;R "h ThatZs better, Than*s.SnR=G wait;())=G saysQ)G sayQ)G U if ;sayQQ6= O printf;R /id ! forget to mention you have beautiful eyes[ 4.D. enough with the suc*ing up. :ac* to tal*ing about me. SnR=G wait;2))=G printf;R"s you can tell ! have a voice synthesi er on board, that or !Zm possesed, hmmmmm. :44Y Huess not. SnR=G wait;2))=G printf;R-till in the wor*s, is an R.F connection between me, and the remote that has the voice synthesis. SnR=G

22

wait;3))=G printf;R4n the remote control -teven is pointing out, man is that a wierd loo*ing remote. SnR=G wait;2)))=G printf;R! bet ! could build a better one SnR=G wait;2))=G printf;R"nyways, on the remote is the voice recognition module, a processor board to wor* with the signals, and an RF module to send the data to me. SnR=G wait;3))=G printf;R!n the future ! hope -teven will add more to me, and ma*e me even better. SnR=G wait;8))=G printf;R"nd A4@ what youZve all been waiting for Time to watch me in action SnR=G wait;()))=G saysQ)G sayQ)G U if ;sayQQ>= O printf;R 7ey you on the right SnR=G wait;())=G saysQ)G sayQ)G U if ;sayQQ()= O printf;R/onZt thin* youZre going to get rid of me by staying on my left side SnR=G wait;())=G saysQ)G sayQ)G U if ;sayQQ((= O printf;R@hat are you doing behind me[ SnR=G wait;())=G saysQ)G sayQ)G U if ;sayQQ(2= O printf;R!Zm following you. SnR=G wait;())=G saysQ)G sayQ)G U saysQ)G wait;()=G U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% %%sets motor speed to be even instantly void motorsinst;int ml, int mr= O

23

if ;mlN)= motorp;),mlC52=G else motorp;),ml=G if ;mrM)= motorp;(,mr&52=G else motorp;(,mr=G U %KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK% void behavior;void= O int iG %%.ollision detection behavior if;:WM31RN()= O if ;R!H7TP:WM3= O while;R!H7TP:WM3= O motors;&3),&()=G for;iQ)GiM8))GiCC=G U sayQ2G U if ;01FTP:WM3= O while;01FTP:WM3= O motors;&(),&3)=G for;iQ)GiM8))GiCC=G U sayQ3G U if ;:".DP:WM3= O while;:".DP:WM3= O motors;2),&2)=G for;iQ)GiM8))GiCC=G U sayQ2G U if ;FR4ATP:WM3= O while ;FR4ATP:WM3= O motors;&3),&3)=G for;iQ)GiM8))GiCC=G U sayQ(G U

22

U else O %%.ollision avoidance behavior if;01FTP!R N!R00 \ R!H7TP!RN!RR0= O if ;01FTP!R M !R07= O %%left low if ;R!H7TP!RM!RR7= O %%left low, right low %%low turn if;01FTP!RNR!H7TP!R= O motors;;Motor0&()=,;MotorRC()==G for;iQ)GiM2))GiCC=G U else O motors;;Motor0C()=,;MotorR&()==G for;iQ)GiM2))GiCC=G U U else O %%left low, right high %% hard right motors;;Motor0C2)=,;MotorR&2)==G for;iQ)GiM2))GiCC=G U U else O %%left high if ;R!H7TP!RM!RR7= O %%left high, right low %%hard left motors;;Motor0&2)=,;MotorRC2)==G for;iQ)GiM2))GiCC=G U else O %%left high, right high %%hard turn if ;01FTP!RNR!H7TP!R= O motors;;Motor0&2)=,;MotorRC2)==G for;iQ)GiM2))GiCC=G U else

28

O motors;;Motor0C2)=,;MotorR&2)==G for;iQ)GiM2))GiCC=G U U U U else O if;RM/ \ 0M/ \ :M/= O if ;RM/ X Y0M/= O sayQ>G while;RM/= O motors;2),&2)=G for;iQ)GiM2)))GiCC=G U U if ;0M/ X YRM/= O sayQ()G while;0M/= O motors;&2),2)=G for;iQ)GiM2)))GiCC=G U U if ;:M/ X YRM/ X Y0M/= O while;:M/= O sayQ((G motors;&8),8)=G for;iQ)GiM5)))GiCC=G U U if ;RM/ X 0M/ X Y:M/= O sayQ(2G motors;2),2)=G for;iQ)GiM()))GiCC=G U U else O motors;2),2)=G U U U U

25

%KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK%

2?

Potrebbero piacerti anche