Home

Sbob (Señor Bob) - Machine Intelligence Lab

image

Contents

1. wait 400 servo SL2 SR2 int irl check ir IR LEFT if irl gt 0x45 t lclear led Acd_puts go right while irl gt 0x45 t irl check ir IR LEFT servo SL2 SRO j wait 400 servo SL2 SR2 fif no object in front display best distance if sonar value gt distance t servo SL2 SR2 cbi PORTD 4 if record 0x0F00 t if change t Until see red object display this clear ledQ lcd puts I am Sbob the bull change 0 A 9 Takes a while else 50 if change t change 0x01 char records 5 ealculate inches int dist record 0x0DO int temp2 0x4C div t foo div dist temp2 dist foo quot int remain foo rem itoa dist records 10 clear_IcdQ led puts The current record is led puts records if remain gt 0x26 led puts 5 led puts inches change 0 slow down if far away and wait for camera to update if sonar value gt 0x600 amp amp time lt 700 servo SL1 SR1 fif object is close then stop else servo SLO SRO clear lcd led puts Scanning 31 wait time recpos 0 get new confidence value clear ledQ if confidence gt 30 t sbi PORTD 4 see_red 0x01 hit 0x00 ram else clear led led puts That color is BORING cbi PORTD 4 avoid
2. rightreg temp rightreg ealculate 1 4 of the difference and add each during each loop int diffr diffl if leftreg gt left diffl leftreg left gt gt 2 else if leftreg lt left diffl left leftreg gt gt 2 else diffl 0x00 31 if rightreg gt right diffr rightreg right gt gt 2 else if rightreg lt right diffr right rightreg gt gt 2 else diffr 0x00 if there is a difference in register values then run algorithm if diffl diffr t char i 0 while i lt 3 t leftreg leftreg diffl rightreg rightreg diffr l clear_Icd led puts reg L itoa leftreg string output 16 led puts string output led puts reg R itoa rightreg string output 16 led puts string output templ leftreg gt gt 8 tempr rightreg gt gt 8 OCR1BH templ OCRIBL leftreg OCRICH tempr OCRICL rightreg i wait 25 templ left gt gt 8 tempr right gt gt 8 OCRIBH templ OCRIBL left OCRICH tempr 32 OCRICL right wait 25 get camera confidence value from TC command void get new confidence value recpos 0 uart_puts TC r while recpos lt 10 amp amp hit 0x00 confidence uart recv 8 x uart recv 2 wait 50 void get color values int redmax redmin bluemax bluemin greenmin greenmax char redmaxs 5 redmins 5 bluemaxs 5 bluemins 5 greenmaxs 5 greenmins 5 int dist check sonar fif nothing in front then go wit
3. t clear ledQ servo SLO SRO PORTF PORTF misses see red 0x00 int dist calculate distance in inches dist record 0x0DO int temp2 0x4C div t foo div dist temp2 dist foo quot int remain foo rem itoa dist string output 10 mew record if oldrecord gt record t oldrecord record clear lcd led puts You set a new record mi lcd puts string output else 45 if remain 0x26 led puts 5 led puts inches wait 2000 avoid clear ledQ led puts Crap I missed NOOOOO wait 2000 avoid sleep mode if misses 0xF0 servo SL0 SR0 clear lcd led puts I m tired now so going to sleep turn off LED s PORTF PORTF amp 0x0F PORTD PORTD amp 0x0F sbi PORTD 5 wait 2000 clear led led puts ZZZZZZZZZZZZZZ Record Icd_puts string_output if remain gt 0x26 led puts 5 lcd puts inches record 0x0F00 misses 0x00 turn off external interrupts cbi EIMSK 0 int irl check ir IR LEFT int irr check ir IR RIGHT 46 char bump 0x01 scans for movement in front of it while bump amp amp irl lt 0x75 amp amp irr lt 0x75 amp amp sonar_temp gt 0x250 t bump inp PIND bump bump amp 0x01 irl check ir IR LEFT irr check ir IR RIGHT sonar temp sonar value wait 40 j sbi EIMSK 0 cbi PORTD 5 clear led led puts You woke me up wait 2000 servo SL2 SR2 void left track t clear led hed pu
4. make it much more humane since the sport of bullfighting kills the bull to end the competition It would also be interesting to replace the annual Running of the Bulls in San Fermin Spain with a few dozen of these robotic bulls and have the robots chase people who are wearing red through the streets This might conflict with some of Asimov s Laws of Robotics however Integrated System The processor that I chose was the Atmel ATMegal28 because it came highly recommended by the TA s It is a good chip with over 50 I O pins including two UART devices two 16 bit counters 8 interrupt pins and 8 Analog to Digital pins I then used the STK501 development board which fits on top of the STK500 development board as an add on piece of hardware I originally had planned on buying only the STK 500 but the STK501 is required to use the ATMegal28 chip Figure 1 STK501 on top of STK500 with LCD Attached The STK500 and STK501 boards are very user friendly from a hardware standpoint They include port headers two RS232 serial ports LED lights for debugging and plenty of ground and power pins for attaching devices The large disadvantage however is that the development boards are quite expensive and if I had to do it over again I would have gone with a cheaper board The programming aspect was done with AVR GCC Using C as the programming language made programming behaviors much easier and AVR GCC is a powerful compiler with support for string
5. 05 Voltage Regulator circuit In hindsight I might have wanted to use two motors instead of servo s to get more speed in order to make it more challenging to try to avoid it hitting the red object For wheels I used two 2 55 diameter plastic wheels that attached directly to the servo and used rubber bands for traction They performed very well Sensors I used three different types of sensors for obstacle avoiding The first are two IR sensors which were used to detect objects off to the side so that Sbob could avoid them before it brushed along side it A sonar system was then used to detect objects in front of the robot to avoid as well as for measuring distances Finally a simple lever switch was used to detect hits and accidental collisions at the front of Sbob The bump switch is a lever switch purchased from RadioShack that is pulled high normally and goes to ground when it is pushed in It is then tied to External Interrupt 0 on Port E Pin 1 It was debounced in software to prevent extraneous interrupts I used the Sharp GP2D12 IR sensors which were then connected to Port F Pins 0 amp 1 to convert the analog voltage to a digital value using the Analog to Digital 10 Converter As an object becomes closer the voltage rises in an exponential fashion I was then able to use this value to compare against an experimentally found hard coded value to determine if the robot needed to turn to avoid an object The sonar device I us
6. ART set baud to 19200 4 Mhz outp 0x0C UBRROL enable transmitter reciever and receive interrupts outp 0x98 UCSROB 8 data bits UCSROC 0x06 configure camera set up camera for poll and raw mode uart puts PM 11 wait 100 uart puts RM 3 r wait 100 get TC parameters get_color_values make sure middle mass mode on wait 100 uart puts MM I r wait 100 PE7 connected to echo pin PE4 connected to trigger pin void sonar init void outp 0x10 DDRE outp 0x44 0CR3AH top 35 ms outp 0x5C OCR3AL outp 0x00 0CR3BH toggle PB6 when TCNT is here outp 0x10 OCR3BL 25 outp 0x00 TCNT3H clear counter outp 0x00 TCNT3L outp 0x23 TCCR3A clear on compare match set at top for output B TOP set in OCR3A outp 0x9A TCCR3B enable noise canceler second part of TOP set in OCRIA and scale by 8 outp 0x20 ETIMSK enable input capture iterrupt PF1 and PFO connected to IR From Kristen Allen Tnitialize the A D converter void ir init void t outp I lt lt ADEN 1 lt lt ADPS2 ADPS1 ADCSRA Initialize to use 8bit resolution for all channels void led init t set LCD PORT output outp 0xFF DDRA enable 4 bit mode outp 0x00 LCD PORT wait 15 outp 0x03 LCD PORT latch led wait 5 outp 0x03 LCD PORT lateh led wait 100 us wait 1 outp 0x03 LCD PORT lateh led wait 4 1 ms wait 5 o
7. L3 SR3 j else if sonar temp 0x200 amp amp past lt 0x02 t servo SL1 SR1 past 0x01 else 42 t servo SL2 SR2 past 0x02 wait 10 b break case 0x30 led puts 3 Blowing my top misses 0x70 zeros 0 allow two missed readings while zeros lt 2 amp amp hit 0x00 t get new confidence value uno x get new confidence value dos x if confidence 20 t zeros 0 if uno gt right amp amp dos gt right right track else if uno lt left amp amp dos lt left left track else straight track j else zeros wait 50 j break case 0x70 led puts 4 You re FINISHED misses 0xF0 past lt 0x02 43 past 0x00 zeros 0 while zeros lt 2 amp amp hit 0x00 t get new confidence value uno x get new confidence value dos x if confidence 20 t zeros 0 wait 50 if uno gt right amp amp dos gt right right track else if uno lt left amp amp dos lt left left track else t lclear ledQ Acd_puts straight sonar_temp sonar_value if sonar_temp gt 0x400 amp amp past Acd_puts fast servo SL3 SR3 j else if sonar temp 0x200 amp amp t hed puts slow servo SL1 SR1 past 0x01 else Acd_puts regular 44 servo SL2 SR2 past 0x02 j j j else zeros wait 50 j break default led puts If I see this something bad happened wait 1000 JI didn t hit object if hit
8. ORT latch led outp data amp 0x0F 1 lt lt 6 LCD PORT latch led wait 1 From Kristen Allen Function to read a specific channel with the desired reference voltage int check_ir int channel t int first second avg set SV as reference left justified and read pin 0 if channel IR LEFT outp 0x60 ADMUX else outp 0x61 ADMUX sbi ADCSRA ADSC loop until bit is clear ADCSRA ADSC conversion is complete first inp ADCH if channel IR LEFT outp 0x60 ADMUX else outp 0x61 ADMUX sbi ADCSRA ADSC loop until bit is clear ADCSRA ADSC conversion is complete second inp ADCH ave first second gt gt 1 return avg get sonar values without interrupts int check_sonar t int high temp low temp1 temp2 low ICR3L high ICR3H high high 8 temp1 low high wait 40 low ICR3L high ICR3H wait till wait till 29 30 high high 8 temp2 low high temp temp1 temp2 gt gt 1 return temp void display_sonar t char string output 4 itoa sonar value string output 16 clear led led puts string output takes arguements outlined in definitions For example servo SL2 SR2 Then smooths it out by a factor of four void servo int left int right t int temp templ tempr rr Ir leftreg rightreg leftreg OCRIBL temp OCR1BH temp temp lt lt 8 leftreg temp leftreg rightreg OCRICL temp OCRICH temp temp lt lt 8
9. T T 0 5 10 15 20 25 30 35 40 Distance in The special sensor is the CMUcam which is used to determine the color of the object placed in front of Sbob The special sensor report fully expands on the operation and theory behind this device but it works via the serial port on the board Figure 5 Sonar Readings 11 and has a command set to get back data from the camera I found that it works fairly well especially in bright lighting conditions Thanks to new some new lens filters the red saturation that previous reports commented on is almost a complete non issue now It does have trouble correctly recording some colors such as blue however which looked more like a very spotty white Behaviors My goal with this robot was to make it as bull like as possible and to have some fun with it as well As a computer engineer out of the CISE department this was 12 my favorite part of the entire process since once the hardware is done the robots behaviors are entirely left up to the imagination to make as simple or as complicated as you want At start up several initialization functions are called to set up the LCD servos IR sensors sonar and camera If an object is held within 6 of Sbob at start up it attempts to dynamically calculate the camera values time lag and maximum viewing distance of the camera Otherwise it uses the default values configured which work very well in the IMDL lab but not as well in
10. University of Florida EEL 5666 Intelligent Machine Design Lab Anthony Huereca Spring 2004 Sbob Senor Bob Table of Contents Abstract Executive Summary Introduction Integrated System Mobile Platform Actuation Sensors Behaviors Experimental Layout and Results 10 Conclusions 11 Documentation 12 Appendix Parts Code CaS A BR D ma Abstract This paper will describe and lay out the development of Sbob an intelligent autonomous robot Sbob is a bull robot that is designed to ram red objects placed in front of him He includes feedback as to what mode he is currently in as well as distance measurement with sonar to track how close he gets to the object before it is moved out of the away This paper will explain the various sensors used to implement these behaviors and the process of building the robot over the course of the semester Executive Summary Sbob is a robot that mimics the actions and behaviors of a real bull used for bull fighting It wanders around at random avoiding obstacles until a red object is placed in its path It then tries to ram into it while also keeping track of the closest distance that he achieved before the red object was pulled away He can then determine how good the user was at bull fighting For color recognition I decided to use the CMUcam as it has been used in a previous robots to determine colors and object tracking For distance measurement I went with a sonar sensor as they a
11. amera and created two horns that I carved out of Styrofoam It is far better to make a platform too large than too small to give some leeway for wires and any miscalculations I used a simple furniture glide piece for the third contact point which was held with hot glue and used Velcro to hold the batteries in place The sonar was glued into place in the front with wood glue as was the bump sensor Everything else was bolted in with screws and then fit snuggly into slots in the wood Wood glue was used to keep the platform together Finally I put a coat of black spray paint on the wood to give it a more bull like look Actuation I used two hacked servos for movement of the robot They were BP148N standard ball bearing servos with 47 oz in of torgue that were very easy to hack to get continuous motion out of them I used the Fast PWM signal on Timer0 to generate the PWM signal for the servos which came out of Port B pins 6 amp 7 I had some initial problems because I assumed that my chip was running at a different clock speed than it actually was which affected the register values I needed I then ran into a problem with my board crashing and resetting itself when I changed directions which I found out was because I needed the power voltage to the servo to be regulated So I attached a five volt regulator with a 470 capacitor on the input and a 22uF capacitor on the output and finally had a moving robot DS010484 24 Figure 4 LM78
12. ance sonar value get new confidence value j allow some error room distance distance 0x100 j fif no object in front use default values else t time 500 distance 0x0700 xpos 37 j cliQ pe de de de de de de de de de de de de de de de de de de de de de de e x BEHAVIORS the fun stuff dede de de de de de de de de KERR KR e e e e e ke Fe EEE From Kristen Allen approx 1ms 4Mhz void wait int delaytime t while delaytime t delaytime int i for i 850 i i asm nop j j void avoid t back up first if close to object if sonar value lt 0x250 t servo SL2r SR2r wait 300 int irr check ir IR RIGHT int irl check ir IR LEFT do random turn if neither IR sensor reports anything close if irr lt 0x15 amp amp irl lt 0x15 t if TCNTIL amp Ox01 t servo SL2 SR2r else 37 servo SL2r SR2 else if irr gt irl servo SL2r SR2 else servo SL2 SR2r wait 500 servo SL2 SR2 void blink leds t PORTF4 7 LED Bank PORTD4 red PORTD5 green PORTD7 white PORTC STKS500 leds unsigned char foo 0x10 PORTF PORTF amp 0x0F PORTD PORTD 0x0F PORTC 0x00 uart puts L1 Or PORTF PORTF amp 0x0F PORTD PORTD 0x0F 38 PORTC 0x00 wait 100 foo 0x10 PORTF PORTF foo PORTD PORTDIfoo wait 200 foo foo lt lt 1 PORTF PORTFIfoo PORTD PORTDIfoo wait 200 foo foo lt lt 1 PORTF PORTF foo PORTC PORTC uart pu
13. bluemax 50 j clear led led puts R itoa redmin redmins 10 led puts redmins led puts itoa redmax redmaxs 10 led puts redmaxs led puts G itoa greenmin greenmins 10 led puts greenmins led puts itoa greenmax greenmaxs 10 led puts greenmaxs led puts B itoa bluemin bluemins 10 led puts bluemins led puts itoa bluemax bluemaxs 10 led puts bluemaxs wait 3000 call once so can just call TC later on recpos 0 uart puts TC uart puts redmins uart puts uart puts redmaxs uart puts uart puts greenmins uart puts uart puts greenmaxs uart puts uart puts bluemins uart puts uart puts bluemaxs uart_puts r wait 300 if dist lt 0x400 t calculate time lag and max recognizable distance sei wait 200 char foo2 5 clear led led puts Lift object out of the way while sonar value lt 0x800 wait 200 clear ledQ led puts Put object in front int conf 0x00 while sonar value gt 0x800 clear led led puts Looking for recognition 35 time 1 char sout 5 get new confidence value while confidence lt 200 t time get new confidence value j time time 75 get new confidence value xpos x get new confidence value xpos xpos x gt gt 1 clear led led puts Move away get new confidence value while confidence gt 100 t dist
14. ed was the Devantech SRFO4 ultrasonic rangefinder It is fairly simple to operate and works by calculating the time between a pulse being sent out to the sonar device and then a rising pulse read in by the processor I used the 16 bit Timer3 to send out a 15 uSec pulse and then used the input capture unit to record the timer value when the output pulse was received and issue an interrupt I used a running average of 3 old average new value 4 to help maintain a steady value that isn t affected by random jumps in readings and also compared each new value against the previous value and threw out any readings that suddenly jumped I found that the device is remarkably stable and will give the same readings at the same distance consistently It is also very accurate which came in useful for calculating the distances to the object The closer an object is the less time that passes by before the input capture unit is activated The table and chart below show the very linear operation of this device which was useful then in being able to convert the timer values into inches Inches Timer Value 1 313 2 361 3 443 4 514 5 593 6 650 7 735 8 795 9 885 10 950 11 1042 12 1136 13 1201 14 1275 15 1346 16 1444 17 1496 18 1565 19 1652 20 1728 21 1813 22 1889 23 1975 24 2001 27 2257 30 2488 33 2706 36 2974 Sonar 3500 3000 y 76 08x 207 75 R 0 999 2500 o 2000 Z S 1500 1000 500 0 T
15. h default parameters for red Else get them interactively if dist lt 0x0400 t int redcomp greencomp bluecomp make windows size smaller so don t have huge amounts of data uart puts SW 25 50 55 90 r wait 500 done 0x00 recpos 0 enable interrupts so can get data back sei recpos 0 clear ledQ led puts Analyzing Object 35 get frame uart_puts DF r while done clear led attempting to calculate TC color parameters redmin lt int uart recv 3 redmax redmin greenmin intjuart recv 4 greenmax greenmin bluemin int uart recv 5 bluemax bluemin int i 6 while i lt recpos t if uart recv i 0x02 i redcomp uart_recv i greencomp uart recv i bluecomp uart recv i if redcomp lt redmax 5 amp amp redcomp gt redmax redmax redcomp else if redcomp gt redmin 5 amp amp redcomp lt redmin redmin redcomp if greencomp greenmax 5 amp amp greencomp gt greenmax greenmax greencomp else if greencomp gt greenmin 5 amp amp greencomp lt greenmin greenmin greencomp if bluecomp lt bluemax 5 amp amp bluecomp gt bluemax bluemax bluecomp else if bluecomp gt bluemin 5 amp amp bluecomp lt bluemin bluemin bluecomp if redmax lt 30 redmax 30 34 if greenmax lt 30 greenmax 30 if bluemax lt 30 bluemax 30 set window back to full size uart_puts SW r j else t redmin 100 redmax 240 greenmin 16 greenmax 50 bluemin 16
16. many useful things in the course of building Sbob that can t be found in any textbook At the first sign of something acting up be sure to check the battery level Or if the board will not turn on make sure that the batteries are not low Also don t solder battery leads while they re attached to the battery pack I melted two metal connector springs on two different packs this way including one that started smoking quite heavily I finally learned my lesson on the third one though Everything also takes three times as long to do as it would seem it should A person cannot afford to procrastinate in this course and with that in mind do not take this class with any 15 other time intensive course Debugging skills are incredibly important Make sure all the code is developed separately and that each part works before putting them together Finally I created a website to provide more pictures and details about the creation of Sbob which can be found at http binaryfusion net sbob 16 Documentation Atmel ATMegal28 Documentation http www atmel com dyn resources prod documents doc2467 pdf AVR STK501 Documentation http www atmel com dyn resources prod documents DOC2491 PDF AVR STK500 Documentation http www atmel com dyn resources prod documents doc1925 pdf AVRFreaks http www avrfreaks com AVRCalc http www avrfreaks com Tools showtools php ToolID 292 AVR GCC Library Reference http www avrfreaks ne
17. ne SL3 0x03A0 k de de de de de de de de de de de de RRR RR RRR RRR RRR RRR EA x Global Variables GARAK gets responses from camera volatile unsigned char uart recv 1000 position to put into recieve array volatile int recpos tells when screen dump is done volatile char done used for bump interrupt volatile char see_red hit used for debouncing external interrupt volatile char exint only update LCD when needed so doesn t flicker char change number of misses unsigned char misses best distance volatile int oldrecord record behavior variables int distance time xpos color tracking variables volatile unsigned char confidence 21 volatile unsigned char x sonar variables volatile int prev sonar_ value ede de de de de de de de KKK KKK ke ke RE INTERRUPT ROUTINES dede de de de de de de de de de de de de e de e Fe Ve de de de SE HUART recieve interrupt SIGNAL SIG UARTO RECV t get data unsigned char foo UDRO uart recv recpos foo this part for screen dump finish signal if foo 0x03 done 0x01 bump switch interrupt PDO SIGNAL SIG INTERRUPTO t used for debouncing after pressed if exint t exint 0x01 if hit after attacking red object celebrate if see red t reset variables hit 0x01 misses 0x00 record 0x0F00 PORTF PORTF amp 0x0F see_red 0x00 22 clear ledQ led puts You just got pwnd celebra
18. njection Mold 6 00 pair Mark III Robot Store http www junun org MarkIII Store jsp Sonar Davantech SRF04 34 50 Acroname http www acroname com IR Sharp GP2D12 11 50 each Acroname http www acroname com Bump Switch SPDT Lever Switch 3 RadioShack LCD Microprocessor Lab LCD Screen Free Bright Red Green and White LEDs 10 est RadioShack Protoboard Radio Shack Large Squares 4 each RadioShack Nuts and bolts 4 Home Depot Furniture Glide Piece 2 Home Depot Red Fabric and Poster Board for target and Styrofoam for Horns 4 Walmart Black Spray Paint Free Home Wires Solder Wood Toggle Switch Lots of female headers 5V Regulator Hot Glue Free IMDL Lab 18 Code BRRRRRRRRRRRRRRRRER KKK k Sbob x Anthony Huereca a IMDL Spring 2004 x Autonomous bull robot x ATMega128 4MHz dede de de de de KERR KR e e e Fe Fe de e include lt avr signal h gt include lt avr interrupt h gt include lt avr io h gt include lt inttypes h gt include lt stdlib h gt include lt string h gt define LCD PORT PORTA define IR_RIGHT 0 define IR_LEFT 1 servo register definitions define SR3r 0x03A0 define SR2r 0x0368 define SR1r 0x0320 define SRO 0x02EE define SR1 0x02B3 define SR2 0x0255 define SR3 0x0200 define SL 3r 0x0200 define SL2r 0x0255 define SL1r 0x02B3 19 20 define SLO 0x02EE define SL1 0x0321 define SL2 0x036B defi
19. other places such as my dorm room There is more detail about this in the CMUcam special sensor report Once the initialization is done then it sits and waits for the front bump switch is pressed to begin moving This is a very good idea since it allows you to not have to worry about the robot running away while programming it with a cord attached to the computer Sbob then begins basic obstacle avoidance If the IR sensors sense something above their threshold then it will turn to avoid it until it no longer senses anything If the bump switch is hit while not in attack mode it will treat it as an accidental collision and reverse and rotate to avoid the object while a white LED is lit to symbolize it surrendering If the sonar detects an object below its threshold then it will slow down or stop depending on how far away the object is and if it is not red then will rotate for a time and then continue forward again Red or the color being looked for is detected by calling the track color command TC and looking at the confidence value If it is above 30 then the object is determined to be red and it begins the charge routine that varies based on the number of misses If there are no misses then it simply speeds up a little bit and continues on a straight line until it either hits the object or it is pulled out of the way It detects a miss by using the confidence value from the TC command and finding 13 when it falls below 20 Afte
20. r moment and could then be used to figure out the problem areas where it might be getting stuck or behaving badly After some initial coding work writing to it was as easy as a regular C print statement Mobile Platform The platform was created out of the balsa wood that IMDL provides and then cut out on the T Tech machine It was designed in AutoCAD 2000 with which I had no previous experience with A crash course lesson was given in class however and I was able to pick up guite easily The hardest part of the platform design is to think about all the issues that will come up as sensors and devices are added It has to be designed to have enough room to put the devices in the places that need it Measuring the exact dimensions of a device and looking at datasheet diagrams is crucial in this part of construction and having rough sketches of what it should look like also help Figure 2 Initial Body Design Sketches My design was fairly straightforward consisting of a lower level for the batteries and servo motors and then an upper box to hold the development board The AutoCad drawings for the top and sides can be seen below Figure 3 AutoCad Drawings It took me two revisions to get the platform I wanted as I had to add some holes for the LED cable and power switch and make the bottom holes larger for the servo s I wanted to make it look like at least somewhat like a bull and thus created a head for the c
21. r the first miss it slows down before until just before it hits the object at which point it speeds back up in an effort to fake out the matador The third time it will begin tracking the red object and try to follow it as it moves around by looking at the medium X values from the TC commands Finally the fourth time it varies it s speed while also trying to follow the red object If it misses again then it goes into a sleep mode since I figure a real bull would be tired of chasing all that red It gets out of it by waving an object in front of it and then it begins fresh again Experimental Layout and Results Many mini experiments were performed during the creation process to make the development process run smoothly The code for each sensor and device was written separately on its own and tested thoroughly before combining it with other parts of the program This ensured that that the two major demos of the course obstacle avoidance and the final demo were programmed smoothly and I could focus on the grand overall behavior scheme instead of fixing buggy sensor code In the beginning I had planned on using the mean color value of the camera image to detect when a red object was placed in front of Sbob by taking the mean color value and seeing if the red channel value rose as an object was placed in front of it This did not work out very well as the object had to be held very close to the camera and many non red objects would al
22. re the most accurate Sbob uses the sonar sensor to discover that an object is in its path and then uses the CMUcam to determine if the object is red If it is then Sbob begins tracking how far away it is and moves toward the object This will continue until Sbob either hits the object and turns in a circle to celebrate its victory or else the object is lifted up or moved out of the way and Sbob will have to try again It detects successful attacks through a bump switch located at the front of his nose Sbob also changes its attacking behavior to make it harder on the matador based on the number of misses Obstacle avoidance is achieved via the sonar sensor located at the front and two angled IR sensors also at the front Introduction Sbob grew out of the idea of a ramming robot Louis a TA for this semester suggested color analysis for use as the special sensor and hence make it into a bull that only attempts to run into red objects I continued on this idea with a distance measuring system to see how close the robot could travel to the object before the matador pulled it away Sbob could be used in a variety of ways in real world applications It can be used as a toy for children who watch bull fighting on TV but whose parents understandably do not want them to try it out on a real bull A much larger version of this robot could even be used as practice bulls so that matadors could safely practice their bull fighting skills as well as
23. s and some advanced mathematics I wrote the code in Programmer s Notepad and then used AVR Studio to download the compiled hex file onto the microprocessor The STK500 uses a serial cable to connect the computer to the processor so no extra hardware was needed Another advantage of using AVR GCC is there are many coding examples and helpful websites for it Most of my code was written from scratch but having examples was useful in looking up how to call various functions and in just getting started initially The code was written in sections and each device was tested and programmed separately before integrating them together This helped with debugging which is a crucial skill for this course Power was an issue in the beginning since the board requires at least 10 volts of power but was accomplished by putting an eight pack and two pack of AA batteries in series with each other and then hot gluing the two packs together This produced a voltage of about 12 5 volts using 10 NiMH batteries A toggle switch was then added to turn the robot on and off with leads going to the board power servo voltage regulator and CMUcam A LCD was also required for everyone s robot which helped immensely with debugging problems I was able to output the various values of registers and variables I had created to the LCD to ensure that I was getting the data I was expecting It also came in useful to output where exactly I was in the program at any particula
24. so cause the value to rise I then played around with the TC command more and found that it worked very well and the confidence value was a very good indicator of detecting color 14 Conclusions This has been the most time consuming frustrating expensive and stressful class I have ever taken It has also been by far the most rewarding cool and interesting class that I will probably ever take I had been looking forward to this course ever since hearing Dr Schwartz talk about it in Digital Logic 3701 and it has lived up to its expectations of being a fun but very challenging course I was able to accomplish all the goals I had set out for my robot to do and I am very happy in how it tumed out All things red fear the presence of this robotic bull I learned a lot and it has been the best possible kind of experience one in which is hands on and teaches that the real world does not behave like theory says it should Louis William and Max were awesome TA s and I d also like to thank Dr Arroyo and Dr Schwartz for their expertise and advice Future things I would like to implement include the dynamic color configuration as explained in the CMUcam sensor report I would also like to add an avoid color that if Sbob saw it he would go in reverse and essentially try to stay away from it Things I would do differently if I had to start over include using motors instead of servos to make it more challenging for the matador I learned
25. t A VRGCC libcref php AVR Bugs http claymore engineer gvsu edu egr326 AtmelA VR Sharp GP2D12 IR Reference Sheet http www junun org Marklll datasheets GP2D12 15 pdf Devantech SRF04 Ultrasonic Range Finder Reference Sheet http www robot electronics co uk htm srfO4tech htm Circuit Diagram for Voltage Regulator http www national com ds LM LM341 pdf Servo PWM Control http handyboard com faq display php key dcservo Kristen Allen s Wait LCD and A D Conversion Code 17 Appendix Parts Some comments While the STK500 and STK501 are very nice boards in the end it is not worth paying almost double what you can get with the Mavric II board Acroname is more expensive but all the parts I ordered from them came with very nice custom made manuals and were the most impressive of all the websites It s not really worth an extra 3 4 but it is impressive Also I originally ordered the CMUcam from Acroname but it comes as a kit which means it comes in a lot of little pieces that need to be put together I returned it and bought a pre assembled and tested one from Seattle Robotics Board STK500 Digikey ASTK500 ND 79 STK501 Digikey ASTK501 ND includes ATMega128 chip 79 DigiKey http www digikey com Camera CMUcam 109 Seattle Robotics http www seattlerobotics com Servos Balsa Products BP148N Standard Torque 10 50 each Mark III Robot Store http www junun org MarklII Store jsp Wheels I
26. te j accidental hit else t change 0x01 control LED lights on back cbi PORTD 4 cbi PORTD 5 sbi PORTD 7 clear Icd led puts I m sorry avoid cbi PORTD 7 j j else t wait 100 exint 0x00 sonar interrupt SIGNAL SIG_INPUT_CAPTURE3 t int high low temp1 temp2 prevhigh low ICR3L high ICR3H high high lt lt 8 templ low high prevhigh prev 0x0600 protect against random missed echo s 23 if temp1 prevhigh t take average temp2 sonar value 3 temp1 sonar value temp2 2 if sonar value lt record amp amp see red record sonar value prev templ pe de de de de de de de de de de de de de de KK KK de de de de e x SENSOR INIT FUNCTIONS x ee ke he he ee ee ee ee ee RUE PB6 is Right Servo PB7 is Left Servo void servo_init outp 0xC0 DDRB enable output pins outp 0x27 OCR1AH top for Fast PWM outp 0x10 OCRIAL outp 0x02 0CR1BH toggle PB6 low when TCNT is here 1 5ms outp Oxee OCRIBL outp 0x02 0CR1CH toggle PB7 low when TCNT is here 1 5ms outp Oxee OCRICL outp 0x00 TCNTIH clear counter outp 0x00 TCNTIL outp Ox2B TCCRIA clear on compare match set pin high at top for output Band C TOP set in OCRIA outp Ox1A TCCRIB second part of TOP set in OCRIA and scale clock by 8 j 24 PEO connected to Transmit pin on CMUcam PE1 connected to Recieve pin on CMUcam void camera_init t t Set up board U
27. ts L1 1 r wait 200 foo foo lt lt 1 PORTF PORTFIfoo PORTD PORTDIfoo wait 200 PORTF PORTF amp Ox0F PORTD PORTD amp Ox0F void celebrate t reverse servo SL2r SR2r wait 300 spin servo SL2 SR2r int i 0 while i lt 4 blink leds i uart puts L1 Or PORTF PORTF amp 0x0F PORTD PORTD 0x0F PORTC 0x00 servo SL2 SR2 most important behavior void ram t int conf char zeros past unsigned char uno dos char right xpos 7 char left xpos 7 char string output 5 clear led blink leds make motors stutter servo SLir SRir wait 50 servo SL1 SR1 wait 50 servo SL1r SR1r wait 50 sbi PORTD 4 PORTF PORTF misses begin moving forward servo SL2 SR2 int sonar temp sonar value switch misses t case 0 led puts 1 What s this increment miss counter for next time and speed up 40 41 misses 0x10 servo SL3 SR3 conf 0x50 continue until lose red tracking while conf gt 20 amp amp hit 0x00 t get new confidence value conf confidence get new confidence value conf conf confidence 1 wait 10 j break case Ox10 led puts 2 Sorta Mad misses 0x30 past 0x00 conf 0x50 while conf gt 20 amp amp hit 0x00 t get new confidence value conf confidence get new confidence value conf conf confidence 1 sonar temp sonar value if sonar temp 0x400 amp amp past t servo S
28. ts going to the left servo SL0 SR2 void right track clear led Acd_puts going to the right servo SL2 SRO void straight track t clear led Acd_puts going forward servo SL2 SR2 void main void t set record to high value initially record 0x0F00 oldrecord record char bump 0x01 change 0x01 misses 0x00 see red 0x00 hit 0x00 debug output outp 0xFF DDRC LED lights outp 0xF0 DDRD outp 0xF0 DDRF turn on front lights outp 0x00 PORTC led init led puts SBOB is getting ready sonar init camera init ir init servo init get initial value for sonar interrupt sonar value check sonar prev sonar value 47 48 clear led led puts Welcome to SBOB 5 t char sout 5 int dist2 distance 0x0D0 int temp2 0x4C div t foo div dist2 temp2 dist2 foo quot itoa dist2 sout 10 led puts D led puts sout led puts in itoa time sout 10 led puts T led puts sout led puts ms wait for bump switch to be hit while bump bump inp PIND bump bump amp 0x01 bump interrupt init sbi EICRA 1 sbi EIMSK 0 exint 0x01 wait 300 start interrupts and GO sei while 1 t turns off any stray LED s PORTD PORTD 0x0F int irr check ir IR RIGHT if irr gt 0x45 t 49 clear led ed puts go left while irr gt 0x45 t irr check ir IR RIGHT servo SLO SR2
29. utp 0x02 LCD PORT latch led four bit mode enabled now configure LCD set up 2 line mode wait 2 outp 0x02 LCD PORT latch led outp 0x0C LCD PORT latch led set up cursor and blink wait 2 outp 0x00 LCD_PORT latch led outp 0x0C LCD PORT latch led clear home wait 2 outp 0x00 LCD_PORT latch led outp 0x01 LCD PORT latch led wait 2 k de de de de de de de de de de de de de KK de de do e e e e e e e e e e x SENSOR FUNCTIONS x ee he he he ee ee ee eee ee ee ee RE 26 kek UART WRI basically LCD code void uart_puts const char s t register char c while c s uart write c j j taken from Atmel User Manual void uart write unsigned char data t while UCSROA amp 1 lt lt UDRE0 UDRO data xx kkk LCD KARA LCD code taken from Source Kristen Allen Author Chad Sylvester Original Author Peter Fleury pfleuryagmx ch http jump to fleury void latch ledQ t sbi LCD PORT 4 cbi LCD PORT 4 j void clear led t 27 clear home wait 2 outp 0x00 LCD PORT lateh led outp 0x01 LCD PORT latch led wait 2 writes a string to the LCD void led puts const char s t register char c while c s led write c j writes a specific character to the LCD void led write unsigned char data t outp data gt gt 4 amp 0x0F 1 lt lt 6 LCD P

Download Pdf Manuals

image

Related Search

Related Contents

Audiovox VM9114 Owner's Manual  Corel Ventura - PC220.CHP  福祉用具貸与・介護予防福祉用具貸与・特定福祉用具販売・特定介護  DSP-2040 - DAS Audio  Alcatel OneTouch ONE TOUCH 639 Quick Start Manual  0333-CPD-292031 DO 4003  SOLIS Triple Fan Plus 738  JVC KD-AR870 Installation Manual    Votre avis nous interesse  

Copyright © All rights reserved.
Failed to retrieve file