Home
EE 477 Final Report
Contents
1. ECE 477 Final Report Spring 2008 Digikey Assmann Elec Inc AWHW10G 0202 T R Conn Header 10 Low Pro 10 pins 0 59 1 0 59 Mouser Vishay CRCW12061K80JNEA Resistor 1 8K 1206 0 08 2 0 16 Mouser Vishay CRCW120610KOFKEA Resistor 10K 1206 0 10 1 0 10 Mouser Vishay CRCW12061K00FKEA Resistor 1 0K 1206 0 10 1 0 10 Digikey CUI Inc PJ 006A Conn PWR JACK 0 45 1 0 45 Digikey Samtec Inc BBL 132 G E Conn Header 100 32 pins 6 58 3 19 74 Mouser Apem MJTP1230B Pushbutton 0 16 1 0 16 Digikey Panasonic ECE A1CN220U Cap Elect 22uF 0 24 1 0 24 Digikey Panasonic ECE A1CN470U Cap Elect 47uF 0 31 1 0 31 Digikey Panasonic ECE A1CN101U Cap Elect 100uF 0 43 1 0 43 Lynxmotion Lynxmotion GHM 07 Gear Head Motor 16 50 4 66 00 Lynxmotion Lynxmotion MMT 01 Aluminum Motor Mount 7 95 2 15 90 Lynxmotion Lynxmotion NFT 07 Foam Tire 5 36 2 10 72 Lynxmotion Lynxmotion HUB 06 Mounting Hub 8 00 2 16 00 Pro Plastics GE Lexan 9034 Plexiglass 36 x36 x0 125 55 00 1 55 00 Hobby City Polyquest 2S Lipoly 2200mAh 7 4 V battery 55 00 1 55 00 Logitech Logitech QuickCam Orbit AF Camera 129 99 129 99 TOTAL 1382 27 ECE 477 Final Report Spring 2008 Appendix F Software Listing Change Log kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk KKKKKKKKKKKKKKKKKKKKKKK Date Rev Author Message 2008 04 24 147 nelson11 changed Idle timeout message to e
2. include lt sys types h gt define SERIAL DEVICE dev ttyS1 define SERIAL BAUD B115200 define SERIAL BUF SIZE 256 define SERIAL CLOSED 0 define SERIAL OPEN 1 define SERIAL OK 0 define SERIAL ERROR 1 define SERIAL FATAL 2 define SERIAL MAX PATH 32 class COMAR class CSerial private COMAR parent int sd state char device u int8 t buf buf head buf tail pthread t thread id pthread mutex t state lock static void serialThread void int serial open int serial close int serial initialize public CSerial COMAR Parent const char Device NULL CSerial void registerCallback int Callback TODO Setup callbacks bool operator l endif SERIAL H H HH Subvehicle OMAR trunk network h ifndef N define N TWORK H TWORK H Fl El include lt netinet in h gt include lt sys types h gt F 107 Spring 2008 ECE 477 Final Report include pthread h define NET PORT 60000 define NET OK 1 define NET ERROR 0 define NET OPEN 1 define NET CLOSED 0 define NET BUF LEN 4096 class COMAR class CNetwork private COMAR parent int sockfd state buf_head buf_tail char buffer pthread t thread id pthread mutex t state lock struct sockaddr in addr int network open int network close int netw
3. if bits 24 Write out top two pixels rgb 0 LIMIT b yTL rgb 1 LIMIT g yTL rgb 2 LIMIT r yTL rgb 3 LIMIT b yTR rgb 4 LIMIT gtyTR rgb 5 LIMIT r yTR else if bits 16 Write out top two pixels rgb 0 LIMIT b yTL gt gt 3 amp Ox1F LIMIT g yTL lt lt 3 amp OxEO rgb 1 LIMIT g yTL gt gt 5 amp 0x07 LIMIT r yTL amp OxF8 rgb 2 LIMIT b yTR gt gt 3 amp OxlF LIMIT g yTR lt lt 3 amp OxEO rgb 3 LIMIT g yTR gt gt 5 amp 0x07 LIMIT r yTR amp 0xF8 convert a YUV420P to a rgb image int v4l yuv420p2rgb unsigned char rgb out unsigned char yuv in int width int height int bits const int numpix width height F 123 ECE 477 Final Report const unsigned int bytes bits gt gt 3 int h w y00 yol y10 yll u v unsigned char pY yuv in unsigned char pU pY numpix unsigned char pV pU numpix 4 unsigned char pOut rgb out if rgb out yuv in return 1 for h 0 h lt height 2 h 2 for w 0 w lt width 2 w t 2 yOO pY yOl pY 1 y10 pY width yll pY width 1 u pU 128 v pV 128 v4l copy 420 block y00 y01 y10 bits pY 2 pout bytes lt lt 1 pY width pout width bytes return 0 convert a YUV4
4. ifndef CAMERA H _ define CAMERA H _ include lt pthread h gt include lt stdio h gt define CAM DEVICE dev video0 define CAM MAX PATH 32 define CAM WIDTH 640 define CAM HEIGHT 480 define CAM DEPTH 3 define CAM SHUT SPD 52000 TODO Experiment w cam shutter speed define CAM GAIN 33000 TODO Experiment w cam gain define CAM DELAY 82000 Camera takes 82ms to capture define CAM FRAMERATE 4 Approximate framerate define CAM OK 1 define CAM ERROR 0 define CAM OPEN 1 define CAM CLOSED 0 class COMAR class CCamera COMAR parent char device int cd state input norm shutter speed gain width height depth size pthread t thread id pthread mutex t state lock int camera initialize int camera open int camera close static void cameraThread void arg public CCamera COMAR Parent NULL const char Device NULL CCamera bool operator F 132 ECE 477 Final Report Spring 2008 l void put image jpeg FILE out char image int width int height int quality int palette fendif CAMERA H kb Subvehicle OMAR trunk slam h ifndef SLAM H define SLAM H class CSLAM l endif SLAM H k Subvehicle OMAR trunk omar h ifndef OMAR H define OMAR H include serial h include camera h include network h include imageRec h include slam h class COMAR CSerial pSer
5. rgb 0 LIMIT b yBL rgb 1 LIMIT g yBL rgb 2 LIMIT r yBL rgb 3 LIMIT b yBR rgb 4 LIMIT g yBR rgb 5 LIMIT r yBR else if bits 16 Write out top two pixels rgb 0 LIMIT btyTL gt gt 3 amp Ox1F LIMIT g yTL lt lt 3 amp OxEO rgb 1 LIMIT g yTL gt gt 5 amp 0x07 LIMIT r yTL amp OxF8 F 122 ECE 477 Final Report Spring 2008 rgb 2 LIMIT b yTR gt gt 3 amp Ox1F LIMIT gtyTR lt lt 3 amp OxEO rgb 3 LIMIT g yTR gt gt 5 amp 0x07 LIMIT r yTR amp OxF8 Skip down to next line to write out bottom two pixels rgb 2 rowPixels rgb 0 LIMIT b yBL gt gt 3 amp Ox1F LIMIT g yBL lt lt 3 amp OxEO rgb 1 LIMIT g yBL gt gt 5 amp 0x07 LIMIT r yBL amp OxF8 rgb 2 LIMIT b yBR gt gt 3 amp OxlF LIMIT g yBR lt lt 3 amp OxEO rgb 3 LIMIT g yBR gt gt 5 amp 0x07 LIMIT r yBR amp OxF8 we static inline void v4l copy 422 block int yTL int yTR int u int v int rowPixels unsigned char rgb int bits const int rvScale 91881 const int guScale 22553 const int gvScale 46801 const int buScale 116129 const int yScale 65536 Int v 18 B g guScale u gvScale v rvScale v b buScale u H I yTL yScale yTR yScale
6. Enable the UART for sending and receiving sbi UCSRB RXEN sbi UCSRB TXEN tx read tx write 0 Set baud rate registers UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx interrupt Sbi UCSRB RXCIE UART tx interrupt SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write Cbi UCSRB UDRIE return UDR tx_buff tx_read tx read tx read 1 gt TX BUFF SIZI Fl o tx read 1 void put char uint8 t c uint8 t tmp write ch tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full if tmp write tx read sbi UCSRB UDRIE return tx buff tx write c tx write tmp write Enable Tx interrupt to start sending Sbi UCSRB UDRIE return void put short uintl6 t s put char uint8 t s amp OxFF F 51 ECE 477 Final Report put char uint8 t s 8 void put_str char str uint32 t d ze H while str i char NULL put char str i itt Subvehicle Motorcontroller adc c ifndef ADC H define ADC H include lt avr interrupt h gt include lt avr io h gt include adc h uint8 t uval lval void adc init void ADCSRA 0x00 PORTA 0x00 DDRA OxFE port a is input others are output ADMUX 0xC0 port0 enabled
7. PORTC amp 1 lt lt 2 amp 1 lt lt 3 delay ms 10 return KR KKK Ck Ck kk kk kk e ke e Update PID function XCkCkckckckckckck ck ck ck ke e ke x amp Spring 2008 1 lt lt 5 amp 1 lt lt 4 intl6 t update PID uintl6 t heading desired uintl16 t curr heading long int pid long int P 0 long int D 0 long int dt char s 200 0 curr time timer cnt 65535 TCNT1 dt curr time prev time calculate heading error for proportional heading error long int heading desired long int curr heading P D pid P D delay ms 32 gain prop heading error gain deriv heading error prev heading error dt snprintf s 200 d 4d h 4d head err 81d prev head err 81d dt 81d P 81d D 81dNr heading desired curr heading heading error prev heading error dt P D put str s prev heading error heading error F 139 ECE 477 Final Report Spring 2008 prev time curr time return pid i Subvehicle Sensor board trunk MControl h ifndef MControl bh define MControl h include avr interrupt h include lt avr io h gt include util delay h void go forward void go reverse void turn left void turn right void brake int16 t update PID uintl16 t heading desired uintl6 t curr heading endif Subvehicle Sensor board trunk i2c c include avr interru
8. Defined by two unit vectors x 1000 with a common center no floating points used due to no fpu typedef struct od Attitude verti 3d center verti 3d forward verti 3d up od Attitude typedef struct od GPScoord whatever is in a gps coordinate int remove me od GPScoord typedef struct od HeliState od Attitude attitude od GPScoord location od HeliState ECE 477 Final Report Spring 2008 Functions endif OD COMMON H Se eof Subvehicle refs od od ImageProcess test c od ImageProcess test c Description Building Recognition Main E include lt stdio h gt include od ImageProcess h ifdef HAVE OPENCV HIGHGUI H const int num files 7 const char file list img figl2 jpg img figll jpg img fig2 jpg img fig6 jpg img fig4 jpg img fig5 jpg img fig6 jpg int main IplImage source final od DB maindb int i if odCreateWindows printf Error creating windows Aborting n return OD ERROR for i 0 i lt num files i source cvLoadImage file list i 1 if source NULL printf Error Opening Image s n file list i continue final odAnalyzelmage source 100 0f amp maindb odShowWindows source final cvWaitKey O cvReleaselmage amp source cvReleaselImage amp final odDestroyWindows main
9. F 91 ECE 477 Final Report Spring 2008 Skip down to next line to write out bottom two pixels rgb 2 rowPixels rgb 0 LIMIT b yBL gt gt 3 amp OxlF LIMIT g yBL lt lt 3 amp e rgb 1 LIMIT g yBL gt gt 5 amp 0x07 LIMIT r yBL amp OxF8 rgb 2 LIMIT b yBR gt gt 3 amp OxlF LIMIT g yBR lt lt 3 amp LR rgb 3 LIMIT g yBR gt gt 5 amp 0x07 LIMIT r yBR amp 0xF8 static inline void v4l copy 422 block int yTL int yTR int u int v int rowPixels unsigned char rgb int bits const int rvScale 91881 const int guScale 22553 const int gvScale 46801 const int buScale 116129 const int yScale 65536 int y gy b g guScale u gvScale v r rvScale v b buScale u yTL yScale yTR yScale if bits 24 Write out top two pixels rgb 0 LIMIT b yTL rgb 1 LIMIT g yTL rgb 2 LIMIT r yTL rgb 3 LIMIT b yTR rgb 4 LIMIT g yTR rgb 5 LIMIT r yTR else if bits 16 Write out top two pixels rgb 0 LIMIT b yTL gt gt 3 s OxlF LIMIT gtyTL lt lt 3 s OxEO rgb 1 LIMIT g yTL gt gt 5 amp 0x07 LIMIT r yTL amp OxF8 rgb 2 LIMIT b yTR gt gt 3 amp Ox1F LIMIT g yTR lt lt 3 amp OxEO rgb 3 LIMIT g yTR gt g
10. UART tx interrupt SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write cbi UCSRB UDRIE return UDR tx buff tx read tx read tx read 1 gt TX BUFF SIZE 0 tx read 1 void put char uint8 t c uint8 t tmp write tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full if tmp write tx read F 34 ECE 477 Final Report sbi UCSRB UDRIE return tx buff tx write c tx write tmp write Enable Tx interrupt to start sending Sbi UCSRB UDRIE return void put short uintl6 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put_str char str uint32 t i 0 while str i char NULL put char str i jb Ht tt Subvehicle Sensors trunk HMC6352 uart h ifndef _ MY UART define MY UART include avr interrupt h include avr io h define TX BUFF SIZE 256 ifndef BAUD If different baud rate is desired do define BAUD BEFORE include uart h in your source define BAUD 51 9600 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTE sfr BV bit endif ifndef cbi define cbi sfr bit SFR BYTE sfr amp BV bit endif Initialize UART MUST BE CALLED void uart init Write 8 bit value to UART void put char uint8
11. pthread mutex lock amp pN state lock while pN state NET OPEN pthread mutex unlock amp pN state lock timeout tv sec 0 timeout tv usec 10000 FD ZERO amp nrfds FD SET pN sockfd amp nrfds selectRetVal select pN sockfd 1 amp nrfds NULL NULL amp timeout switch selectRetVal case 1 LOG FATALLOG Something terrible has happened to the network connection s strerror errno pN network close break case 0 timeoutCnt if timeoutCnt 500 LOG WARNINGLOG No client connected to network in the last us timeoutCnt 100 break default timeoutCnt 0 cSock 1 if cSock accept pN sockfd struct sockaddr amp pN addr socklen t amp cLen 1 OG ERRORLOG accept failed in network s strerror errno else LOG INFOLOG Client connected to network pthread mutex lock amp pN state lock while cSock gt 0 amp amp pN state NET OPEN pthread mutex unlock amp pN state lock timeout tv sec 0 timeout tv usec 10000 FD ZERO amp nrfds FD SET cSock amp nrfds selectRetVal select cSock 1 amp nrfds NULL NULL amp timeout switch selectRetVal case 1 LOG FATALLOG Something terrible has happened to the network connection s strerror errno pN network close F 136 ECE 477 Final Report break case 0 timeoutCnt if timeoutCnt 50
12. TWINT wait for TWINT flag set indicates start sent check start sent correct if TWSR amp OxF8 START return ERROR put str START ERRORWMnNr return OK end send start KRKKKK send addr t uint8 t addr FEA ck ck ck ckck kk ck kk ke ke ke e e x amp f int send addr t uint8 t addr send addr TWDR addr TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT to start transmission of addresss wait for ACK while TWCR amp 1 TWINT check status slave sent ack received if TWSR amp OxF8 TW MT SLA ACK return ERROR return OK end send addr k send addr r uint8 t addr KOKCkck ck ck ck ckck KK e x x f int send addr r uint8 t addr send addr TWDR addr 0x01 TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MR SLA ACK return ERROR put str ADDR SENT ERROR WnNr return OK end send addr F 47 ECE 477 Final Report KKK KKK Ck Ck kk Ck kk kk kk kk kk KK KKK k kk int send data uint8 t data KCKCKCKCkCKCkCkCkCkCkCkCkCkCkCk Ck kk k Ck kk kk k Ck ck kk ck ck kk int send data uint8 t
13. define PWC WB INDOOR 0 define PWC WB OUTDOOR 1 define PWC WB FL 2 define PWC WB MANUAL 3 define PWC WB AUTO 4 Used with VIDIOCPWC SG AWB Auto White Balance Set mode to one of the PWC WB values above red and blue are the respective gains of these colour components inside the camera range 0 65535 When mode PWC WB MANUAL manual red and manual blue are set or read otherwise undefined read red and read blue are read only KA struct pwc_whitebalance int mode int manual red manual blue R W int read red read blue R O l control speed and control delay are used in automatic whitebalance mode and tell the camera how fast it should react to changes in lighting and with how much delay Valid values are 0 65535 e struct pwc wb speed int control speed int control delay uH F 68 ECE 477 Final Report Used with VIDIOCPWC SG LED struct pwc leds int led_on Led on time range int led_off Led off time range l Image size used with GREALSIZE struct pwc imagesize int width int height Defines and structures for Motorized Pan amp Tilt define PWC MPT PAN 0x01 define PWC MPT TILT 0x02 define PWC MPT TIMEOUT 0x04 for status Set angles when absolute 1 the angle is absolute and the driver calculates the relative offset for you This can o
14. else printf Device Memory n printf Size d n devicebuffers devnum size printf Frames d n devicebuffers devnum frames for i20 i devicebuffers devnum frames i printf Frame d p n i devicebuffers devnum offsets i success int Activate MMap int devnum char err 255 attempt if devicebuffers devnum size gt 0 videobuffers devnum unsigned char mmap NULL devicebuffers devnum size PROT READ MAP SHARED device devnum 0 debugcode printf mmap Memory Buffer p n videobuffers devnum if videobuffers devnum unsigned char 1 sprintf err mmap failed d n errno devicebuffers devnum size 0 failure err success int Deactivate Map int devnum attempt if devicebuffers devnum size gt 0 munmap videobuffers devnum devicebuffers devnum size devicebuffers devnum size 0 videobuffers devnum NULL success int MSync int devnum int buffer F 77 ECE 477 Final Report Spring 2008 char err 255 attempt if devicebuffers devnum size 0 failure Device Buffer Size lt 0 n if ioctl device devnum VIDIOCSYNC amp buffer lt 0 sprintf err MSync Error din errno failure err success int MCapture int devnum int buffer struct video mmap vm
15. i N I odCameraMove 6000 4500 peed 52000 EDS TO LOOK AT TH D Pictur gain amp 330 00 F SHUTT T ER SPEED AND GAIN VARIABL Fl We image odCameraTak odCameralmageToJPl return 0 main eof EGFile image ime s roo hutter speed gain t bin test jpg 100 Subvehicle refs od od ImageProcess h od ImageProcess h ifdef HAV define INF ObjectDetection define OD WIN SOURCE define OD WIN FINAL define OD WIN 3 define OD WIN 4 ifndef OD IMAGEPROCESS define OD IMAGEPROCESS include lt opencv cv h gt include math h include od common h include od dbase h i OP int odCreateWindows void odDestroyWindows void odShowWindows include lt opencv highgui h gt Handling each image using OpenCV Source Image Final Image Process 1 Process 2 1000 0 ENCV_HIGHGUI_H Ipllmage source IplImage final Spring 2008 int odDBtoCvSeq Overview od DB db CvSeq flines CvMemStorage fline storage endif HAVE OPENCV HIGHGUI H IplImage odLoadImage void src Ipllmage odAnalyzelImage int odAnalyzeLines CvSeq lines float _ inline odVectorLength2D CvPoint line od DB IplImage source float thresh od DB maindb db flo
16. ERROR ERROR ERROR data addr uint8 t reg if send_start ERROR send stop return ERROR if send addr t addr ERROR send stop return ERROR if send data reg ERROR send stop return ERROR if send_repeat send stop ERROR F 141 Spring 2008 ECE 477 Final Report return ERROR if send addr r addr ERROR send stop return ERROR if get nack data ERROR send stop return ERROR send_stop return TWDR end i2c read addr reg uint8 t hmc transmit uint8 t addr uint8 t data int status 0 if send start ERROR send_stop return ERROR if send addr t addr ERROR send stop return ERROR if send_data data ERROR send_stop return ERROR send_stop return OK end i2c transmit addr data uintli6 t hmc read uint8 t addr uintl6 t data 0 if send_start ERROR send_stop return ERROR if send addr r addr send stop return ERROR if get ack data send_stop return ERROR ERROR ERROR F 142 Spring 2008 ECE 477 Final Report Spring 2008 data TWDR lt lt 8 if get nack data ERROR send stop return ERROR data TWDR send_stop return data
17. MAX1858 Online Document 2003 October cited Feb 14 2008 http datasheets maxim ic com en ds MAX1858A MAX1876A pdf 24 Maxim IC MAX3370 Online Document 2006 December cited Feb 14 2008 http datasheets maxim ic com en ds MAX3370 MA X337 1 pdf 25 Motorola System Design and Layout Techniques for Noise Reduction in MCU Based System Online Document 1995 cited February 20 2008 http cobweb ecn purdue edu dsml ece477 Homework CommonRefs AN 1259 pdf 35 ECE 477 Final Report Spring 2008 26 27 28 29 30 Linear Technology LT1083 Online Document cited April 24 2008 http www linear com pc downloadDocument do navId H0 C1 C1003 C1040 C1055 P1 283 D3741 Fairchild LM78XX 3 Terminal 1A Positive Volage Regulator Online Document 2006 May cited February 20 2008 http www fairchildsemi com ds LM LM7805 pdf National Semiconductor LM3940 Online Document 2007 July cited February 20 2008 http www national com ds cgi LM LM3940 pdf Jones M Tim Inside the Linux Scheduler June 30 2006 http www 128 ibm com developerworks linux library l scheduler ca dgr Inx wO9LinuxScheduler Linux Kernel Gains New Real Time Support Oct 12 2006 http www linuxdevices com news NS9566944929 html 36 ECE 477 Final Report Spring 2008 Appendix A Individual Contributions A 1 Contributions of Michael Cianciaru
18. 4 Data Types SHass assis S45 Sessa SSS ae es SSS EE SSS Se a Sea Seas F 101 ECE 477 Final Report Spring 2008 typedef struct od VertLink verti 3d vert struct od VertLink next od VertLink typedef struct od ObjLink od Object obj struct od ObjLink next od ObjLink typedef struct od VLinkServer od VertLink head tail links to head and tail of available links int nclinks The current number of links in the server int ntlinks The total number of links created od VLinkServer typedef struct od OLinkServer od ObjLink head tail links to head and tail of available links int nclinks The current number of links in the server int ntlinks The total number of links created od OLinkServer typedef struct od DB od Object objects od VertLink verticesDB od VLinkServer VLS od OLinkServer OLS od DB The initial size of the vertex and object link servers Also their increments as they increase due to overflow define OD INIT VLS SIZE 5000 define OD INIT OLS SIZE 1000 define OD INIT VLS INC 500 define OD INIT OLS INC 100 PUNCULONS 555 555 525 nn T jo SS SSS 5 R55 Pec aS Sasa see int odInitDB od DB db int odDestroyDB od DB db Creates the link server in the DB This is a circular linked list int odCreateVLinkServer od DB db Used to destroy the links in the link server at the end of the pro
19. LEDs on off blink int range 0 65535 define VIDIOCPWCSLED IOW v 205 struct pwc leds define VIDIOCPWCGLED IOR v 205 struct pwc leds Contour sharpness int lt 0 auto 0 65536 fixed define VIDIOCPWCSCONTOUR IOW v 206 int define VIDIOCPWCGCONTOUR IOR v 206 int Backlight compensation 0 off otherwise on define VIDIOCPWCSBACKLIGHT IOW v 207 int define VIDIOCPWCGBACKLIGHT IOR v 207 int Flickerless mode 0 off otherwise on define VIDIOCPWCSFLICKER IOW v 208 int define VIDIOCPWCGFLICKER IOR v 208 int Dynamic noise reduction 0 off 3 high noise reduction define VIDIOCPWCSDYNNOISE IOW v 209 int define VIDIOCPWCGDYNNOISE IOR v 209 int Real image size as used by the camera tells you whether or not there s a gray border around the image define VIDIOCPWCGREALSIZE IOR v 210 struct pwc imagesize Motorized pan amp tilt functions define VIDIOCPWCMPTRESET IOW v 211 int define VIDIOCPWCMPTGRANGE IOR v 211 struct pwc mpt range F 70 ECE 477 Final Report define VIDIOCPWCMPTSANGLE IOW v 212 struct pwc mpt angles define VIDIOCPWCMPTGANGLE IOR v 212 struct pwc mpt angles define VIDIOCPWCMPTSTATUS _IOR v 213 struct pwc mpt status fendif THHEHEHE Subvehicle refs od otherlibs v4l h v4l h Copyright C 2001 Rasca Berlin This program is free software you can
20. gt gt 8 x buffer is empty Fl M i o tx read 1 tx write 1 tmp write tx read return UDRIE tx buff tx write c tx write tmp write Enable Tx interrupt sbi UCSRB UDRIE to start sending F 24 Spring 2008 ECE 477 Final Report return void put short uintl16 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put_str char str uint32 t i 0 while str i char NULL put char str i LFE ii Subvehicle Sensors trunk srf02 uart h ifndef MY UART define MY UART include lt avr interrupt h gt include lt avr io h gt define TX BUFF SIZE 256 ifndef BAUD If different baud rate is desired do fdefine BAUD BEFORE include uart h in your source define BAUD 51 9600 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTE sfr BV bit endif ifndef cbi define cbi sfr bit SFR BYTE sfr amp BV bit endif Initialize UART MUST BE CALLED void uart init Write 8 bit value to UART void put char uint8 t c Write 16 bit value to UART void put short uintl6 t s Write string of length len to UART void put str char str endif MY UART ii Subvehicle Sensors trunk srf02 i2c h ifndef I2C H define I2C H include lt avr interrup
21. return ERROR if send addr t addr return ERROR if send data reg return ERROR if send repeat return ERROR if send addr r addr return ERROR ERROR ERROR ERROR ti RROR ERROR if get_ack_data return ERROR data 0 TWDR if get ack data return ERROR data 0 TWDR lt lt 8 ERROR ERROR ER if get ack data return ERROR data 1 TWDR ERROR if get ack data return ERROR ERROR data 1 TWDR lt lt 8 if get ack data return ERROR data 2 TWDR if get nack data return ERROR data 2 TWDR lt lt 8 ERROR ERROR send stop return OK end i2c read accel send repeat int send repeat EK KK KK KK KK ke ke e ex TWCR 0 1 lt lt TWSTA 1 lt lt TWINT 1 lt lt TWEN repeat start code wait for repeat start sent while TWCR amp 1 lt lt TWINT check repeat start sent correct if TWSR amp OxF8 TW REP START return ERROR put str REP START ERRORMn Nr return OK end send repeat send start int send start CKCkCk Ck k kc k kc kckckckck AK AZ AA K Kk ke exe ke F 11 ECE 477 Final Report Spring 2008 send start TWCR 0 1 lt lt TWINT 1 lt lt TWSTA 1 lt lt TWEN send start condition wait f
22. return OD OK odAnalyzeLines F 99 ECE 477 Final Report Spring 2008 float odVectorAngle2D CvPoint lineA CvPoint lineB float dotproduct lengthproducts CvPoint lineC 2 lineC 0 x lineA 0 x lineC 0 y lineA 0 y lineC 1 x lineB 1 x lineB 0 x lineA 0 x lineC 1 y lineB 1 y lineB 0 y lineA 0 y dotproduct float lineA 1 x lineC 1 x float lineA 1 y lineC 1 y lengthproducts odVectorLength2D lineA odVectorLength2D lineC return float acos dotproduct lengthproducts odVectorAngle2D int odDBtoCvSeq Overview od DB db CvSeq flines CvMemStorage fline storage return OD OK odCreateCVSeq float inline odVectorLength2D CvPoint line return float sqrt loat f line 1 x line 0 x line 1 x line 0 x line 1 y line 0 y line 1 y line 0 y odVectorLength2D eof ti Subvehicle refs od od CVWindowManagement c od CVWindowManagement c ObjectDetection window management for OpenCV xy ifdef HAVE OPENCV HIGHGUI H include od common h include od ImageProcess h int odCreateWindows Hm cvNamedWindow OD WIN SOURCE cvNamedWindow OD WIN FINAL 1 return OD OK odCreateWindows void odDestroyWindows cvDestroyWindow OD WIN SOURCE cvDestroyWindow OD WIN FINA
23. CCamera pCam CNetwork pNet public COMAR COMAR endif OMAR H dibi Subvehicle OMAR trunk imageRec cpp include imageRec h dibi Subvehicle OMAR trunk network cpp include lt stdlib h gt include lt sys socket h gt include lt sys stat h gt include lt sys select h gt include lt unistd h gt include lt netdb h gt include lt string h gt include errno h include Logger h F 133 ECE 477 Final Report include network h CNetwork CNetwork COMAR Parent arent Parent ockfd 1 tate NET CLOSED uffer NULL 00 0 0 UG uf head buf tail thread mutex init amp state lock 0 NULL if network initialize NET OK return buffer new char NET BUF LEN if buffer NULL LOG DEBUGLOG network close return printf buffer x n CNetwork CNetwork printf buffer x n network close printf buffer x n Failed to allocate network receive buffer unsigned int buffer unsigned int buffer unsigned int buffer if buffer NULL delete buffer int CNetwork network initialize int ret NET OK if ret network open NET OK return ret ret pthread create If ret ts 0 i LOG DEBUGLOG network close return NET ERROR return NET OK
24. ECE 477 Final Report Spring 2008 void adc init void ADCSRA 0x00 PORTA 0x00 DDRA OxFE port a is input others are output ADMUX 0xC0 port0 enabled ADCSRA 0x83 enabled start auto trigger interrupt flag interupt enabled prescalars SFIOR 0x00 free running mode set auto trigger to interupt flag ADCSRA 1 lt lt ADEN ADCSRA 1 lt lt ADSC return void adc_isr void lval uint8 t ADCL uval uint8 t ADCH return uintl6 t read adc void uintl6 t i uint8 t x ADCSRA 1 lt lt ADSC while ADCSRA amp ADSC ADSC x ADCL i 0x0003 amp ADCH i lt lt 8 i i 0x00FF amp x return i endif ADC H k Subvehicle Sensors trunk GP2Y0A700K uart h ifndef MY UART define MY UART include lt avr interrupt h gt include lt avr io h gt define TX BUFF SIZE 256 ifndef BAUD If different baud rate is desired do fdefine BAUD BEFORE include uart h in your source define BAUD 51 9600 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTI endif Fl sfr BV bit ifndef cbi define cbi sfr bit SFR BYTI endif Fl sfr amp BV bit Initialize UART MUST BE CALLED void uart_init Write 8 bit value to UART F 9 ECE 477 Final Report void put char uint8 t c Write 16 bit value t
25. MSync int devnum int buffer MCapture int devnum int buffer Set Size int devnum int width int height Get Frame Rate int devnum Set Frame Rate int devnum int fps Read Image int devnum unsigned char dst Select Input int devnum int number Get Width int devnum Get Height int devnum Set Led int devnum int on time int off time void Dump Current Settings int devnum void Query Pan Tilt Status int devnum void Reset Pan Tilt int devnum int what reset pan bit 0 and or tilt bit 1 void Set Pan Or Tilt Or Zoom int devnum char what int value void Set Framerate int devnum int framerate 0 63 void Flash Settings int devnum void Restore Settings int devnum void Restore Factory Settings int devnum void Set Compression Preference int devnum int pref 0 3 void Set Automatic Gain Control int devnum int pref 0 65535 void Set Shutter Speed int devnum int pref 1 65535 void Set Automatic White Balance Mode int devnum char mode auto manual indoor outdoor fl void Set Automatic White Balance Mode Red int devnum int val 0 65535 void Set Automatic White Balance Mode Blue int devnum int val 0 65536 void Set Automatic White Balance Speed int devnum int val 1 65536 void Set Automatic White Balance Delay int devnum int val 1 65536 void Set LED On Time int devnum int val 0 2550
26. Table G 4 Sensor Subsystem EN Failure Mode Possible Causes Failure Effects Method of Detection Criticality Magnetometer VCC out of range Failure to determine Not driving straight Failure Magnetic interference compass heading Failure to turn in Failure to drive straight correction direction Failure to determine new direction D2 Sonar Failure VCC out of range failure to detect objects Crash into walls objects High False 40 kHz sound and walls Possible battery explosion interference Possible fire D3 IR Failure VCC out of range Failure to map room No room mapping Incorrect ADC AVCC Failure to navigate room Ambient light interference properly Accelerometer VCC out of range Failure to determine False room map Failure position in room Pull resistor VCC out of range short All sensors fail Omar would stop failure Level VCC out of range 3 3V sensor would fail Omar would stop Medium translators Short fail ADC inductor VCC out of range IR sensors would fail Room mapping would fail Low fails Short Bad ADC input value
27. The main subsystems that will be used on the microcontroller will be the ADC rc PWM and UART The IR sensors will each use a channel of the ADCs that are located on port A of the ATmega32 There is also the possibility that the current sensors from the motor controllers will be read on the ADC The rest of the sensors that are being used will be using I C that only requires the SCL and SDA pins located on port C of the ATmega32 When communicating with the various devices connected to this port it will send out the address of which device to communicate with and will do so at 100 kHz This protocol allows the ATmega to communicate with over 100 devices using seven bit addresses The 16 bit PWM with is located on port D will be used to control the servo 9 that will act as a turret that will rotate the camera and IR sensors 26 ECE 477 Final Report Spring 2008 When the servo is not being used the 16 bit timer will be used to create timestamps for any control loops that are being used instead of creating a PWM signal The other two 8 bit PWMs located on port D and port B will be used to control the motor controller and more specifically the speed at which to drive the motors Along with the PWM a few more general purpose I O pins used as logical outputs and be interpreted by the H Bridge 8 to determine which way to drive the motors Lastly the serial UART output on port D will be used for communication between the ATmega32 11 and the Gum
28. endif ifndef cbi define cbi sfr bit SFR BYTE sfr amp BV bit endif Initialize UART MUST BE CALLED void uart init Write 8 bit value to UART void put char uint8 t c Write 16 bit value to UART void put short uintl6 t s Write string of length len to UART void put str char str endif MY UART ii Subvehicle Sensors trunk LIS3L i2c h ifndef I2C H define I2C H include lt avr interrupt h gt include avr io h include stdio h F 17 Spring 2008 ECE 477 Final Report Spring 2008 include util twi h define F CPU 800000UL include util delay h define START ERROR 1 define ADDR SENT ERROR 2 define DATA SENT ERROR 3 define ADDR REC ERROR 4 define DATA REC ERROR 5 define DATA NACK REC ERROR 6 define SENT OK 7 define OK 0 define ERROR 1 define START 0x08 void i2c init int i2c transmit uint8 t addr uint8 t reg uint8 t data int8 t i2c read uint8 t addr uint8 t reg uint8 t i2c read accel uint8 t addr uint8 t reg intl6 t data send repeat int int send start void send stop int send addr t uint8 t addr int send addr r uint8 t addr int send data uint8 t data int get ack data int get nack data endif I2C H ii Subvehicle Sensors trunk srf02 i2c c include lt avr interrupt h gt include lt a
29. int CNetwork network open int optval 1 pthread mutex lock amp s amp thread id NULL networkThread void this Failed to start network helper thread tate lock if state NET CLOS ED pthread mutex unloc LOG DEBUGLOG return NET ERROR if sockfd socket AF INET k amp state lock Network already open SOCK STREAM IPPROTO TCP 1 pthread mutex unlock amp state lock F 134 Spring 2008 ECE 477 Final Report LOG DEBUG return NF memset amp addr addr sin_family AF_INET addr sin_port htons NE addr sin addr s addr if setsoc 0G m kop ERROR Network failed to allocate socket s 0 sizeof struct sockaddr in T PORT htonl INADDR ANY t sockfd SOL SOCKET SO R pthread mutex unlock amp state lock LOG DEBUG return NE if bind sockfd 0G m ERROR EUSEADDR amp optval Network failed to set socket options s struct sockaddr amp addr pthread mutex unlock amp state_ lock LOG DEBUGLOG return NE state m NET OPEN Network failed to bind to socket ERROR pthread mutex unlock amp state lock LOG INFOLOG return NET OK int CNetwork network close pthread mut
30. int i attempt for i 0 i lt devcount i Get Capabilities i Get Picture i Get Window i Get MMap i success int Get Capabilities int devnum attempt if ioctl device devnum VIDIOCGCAP amp devicecapabilities devnum lt 0 failure IOCTL Error n else F 75 ECE 477 Final Report Spring 2008 print prin f Device Capabilites n tf Name s n devicecapabilities devnum name printf Type d n devicecapabilities devnum type printf Channels d n devicecapabilities devnum channels printf Audio Channels d n devicecapabilities devnum audios printf Max Width d n devicecapabilities devnum maxwidth printf Min Width d n devicecapabilities devnum minwidth printf Max Height d n devicecapabilities devnum maxheight printf Min Height d n devicecapabilities devnum minheight success int Get Picture int devnum attempt if ioctl device devnum VIDIOCGPICT amp devicepictures devnum lt 0 failure IOCTL Error n else printf Device Picture n printf Brightness d n devicepictures devnum brightness printf Hue d n devicepictures devnum hue printf Colour d n devicepictures devnum colour printf Contrast d n devicepictures devnum contrast printf Whiteness d n devicepictures devnum white
31. return ERROR return OK end send addr KRKKKK send addr r uint8 E addr KCKCk k ck ck ck kckckock ck kk ke ke e e A x amp f int send addr r uint8 t addr send addr TWDR addr 0x01 TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MR SLA ACK return ERROR put str ADDR SENT ERROR WnNr F 31 ECE 477 Final Report return OK end send addr KKK RK KK Ck kk kk Ck kk kk kk AK AXi kc k KKK k k kk S int send data uint8 t data kk kk k k k k ok OK k k kok ok kk kk Rok ek kk kk I I I kk eee int send data uint8 t data send data TWDR data TWCR 0 1 lt lt TWINT 1 TWEN clear TWINT bit to wait for ACK Spring 2008 start data transmission while TWCR amp 1 TWINT wait for TWINT flag set data sent ACK received check status MT DATA ACK if TWSR amp OxF8 TW MT DATA ACK return ERROR put str DATA SENT ERROR n r return OK end send data fx x KK KKK send stop void send stop send STOP condition TWCR 0 1 lt lt TWINT XCkCk ck ck ckckckck ck kk
32. values above red and blue are the respective gains of these colour components inside the camera range 0 65535 When mode PWC WB MANUAL manual red and manual blue are set or read otherwise undefined read red and read blue are read only ey struct pwc_whitebalance int mode int manual_red manual_blue R W int read red read blue ZS R O l control speed and control delay are used in automatic whitebalance mode and tell the camera how fast it should react to changes in lighting and with how much delay Valid values are 0 65535 SE struct pwc wb speed int control speed int control delay l Used with VIDIOCPWC SG LED struct pwc leds int led_on Led on time range 0 25000 int led off Led off time range 0 25000 uH Image size used with GREALSIZE struct pwc imagesize int width int height Defines and structures for Motorized Pan amp Tilt define PWC MPT PAN 0x01 define PWC MPT TILT 0x02 define PWC MPT TIMEOUT 0x04 for status Set angles when absolute 1 the angle is absolute and the driver calculates the relative offset for you This can only be used with VIDIOCPWCSANGLE VIDIOCPWCGANGLE always returns absolute angles EA struct pwc mpt angles int absolute write only int pan degrees 100 int tilt de
33. 1 1 width height bytes width height bytes bytes bytes 8 EAD PROT WRITE MAP SHARED deu Di vid mmap format VIDEO PALETTE YUV420P F 62 Spring 2008 ECE 477 Final Report Spring 2008 vid mmap frame 0 vid mmap width width vid mmap height height if ioctl dev VIDIOCMCAPTURE amp vid mmap 1 perror VIDIOCMCAPTURE fprintf stderr args width d height d palette d n vid mmap width vid mmap height vid mmap format munmap map vid buf size return NULL if ioctl dev VIDIOCSYNC amp vid mmap frame 1 perror VIDIOCSYNC munmap map vid buf size return NULL size vid_buf size convmap malloc width height bytes v4l yuv420p2rgb convmap map width height bytes 8 memcpy map convmap size t width height bytes free convmap return map write ppm image to stdout file void put image ppm FILE out char image int width int height int x unsigned char p unsigned char image unsigned char buff 3 fprintf out P6 n d S d n d n width height 255 for x 0 x lt width height x buff 0 p 2 buff 1 p 1 buff 2 p 0 fwrite buff 1 3 out p 3 fflush out void put image jpeg FILE out char image int width int height int quality int palette int y x lin
34. ADCSRA 0x83 enabled start auto trigger interrupt flag enabled prescalars SFIOR 0x00 free running mode set auto trigger to interupt flag ADCSRA 1 lt lt ADEN ADCSRA 1 lt lt ADSC return void adc isr void lval uint8 t ADCL uval uint8 t ADCH return uintl6 t read adc void uintl6 t i uint8 t x ADCSRA 1 lt lt ADSC while ADCSRA amp ADSC ADSC x ADCL i 0x0003 amp ADCH i 8 i i 0x00FF amp x return i endif ADC H kb Subvehicle Motorcontroller uart h 4444 F 52 interupt Spring 2008 ECE 477 Final Report ifndef MY UART define MY UART include lt avr interrupt h gt include avr io h define TX BUFF SIZE 256 ifndef BAUD If different baud rate is desired do define BAUD BEFORE include uart h in your source define BAUD 51 9600 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTI endif Fl sfr BV bit ifndef cbi define cbi sfr bit SFR BYTI endif Fl sfr amp BV bit Initialize UART MUST BE CALLED void uart_init Write 8 bit value to UART void put_char uint8 t c Write 16 bit value to UART void put_short uintl t s Write string of length len to UART void put str char str endif MY UART 4 Subvehicle Motorcontroll
35. Spring 2008 ECE 477 Final Report Spring 2008 delay us 80 sonar3 i i2c read SR 2 lt lt 8 sonar3 i i2c read SR 3 avg data i i 1 8 sonar sum3 sonar suml sonar sum2 0 for x 0 x lt sonar avg size x t sonar suml sonarl x sonar sum2 sonar2 x sonar sum3 sonar3 x sonar suml sonar avg size sonar sum2 sonar avg size sonar sum3 sonar avg size if sonar avg size 8 sonar avg sizett delay ms 7 curr heading get compass DEBUG print sonar values if DEBUG delay ms 32 snprintf s 200 He 5d tot 44x cnt 3d d 4u h 4u LS 3x RS 3x s dir speed gain throttle thresh count heading desired curr heading OCR0 OCR2 state put str s fendif KKK KKK KKK state machine start k kkkkkkkk if state GO set speeds and direction forward if state GO throttle if sonar suml gt THROTTLE THRESH offset amp amp sonar sum2 gt THROTTLE THRESH offset amp amp sonar sum3 gt THROTTLE THRESH offset if thresh count lt 5 throttle 7 throttle gt gt 3 offset THRESH STEP thresh_count else if thresh count gt 0 throttle 8 throttle 7 throttle offset THRESH STEP thresh count Speed gain update PID heading desired curr heading F 147 ECE 477 F
36. assert tmp3 assert tmp4 assert final corners malloc sizeof CvPoint2D32f corners count assert corners cvCvtColor source tmpl CV BGR2GRAY cvSmooth tmpl tmp2 CV MEDIAN 3 3 0 cvZero tmpl cvCanny tmp2 tmpl float thresh float thresh 1 8 3 Corner Retrieval cvZero tmp3 cvZero tmp4 cvCopy tmpl tmp2 NULL cvGoodFeaturesToTrack tmpl tmp4 tmp3 corners amp corners count 001 3 NULL 3 0 0 04 Line Retrieval line storage cvCreateMemStorage 0 assert line storage lines cvHoughLines2 tmpl line storage CV HOUGH PROBABILISTIC 1 CV PI 720 30 15 3 odAnalyzeLines lines maindb fline storage cvCreateMemStorage 0 odDBtoCvSeq Overview maindb amp flines fline storage TEST CODE lines flines for i 0 i lt lines gt total i line CvPoint cvGetSeqElem lines i cvLine final line 0 line 1 CV RGB 0 0 255 1 8 0 Contour and Polygon Retrival CvSeq contours current result CvMemStorage contour storag 0 cvCreateMemStorage F 98 ECE 477 Final Report Spring 2008 assert contour storage cvFindContours tmp2 contour storage amp contours sizeof CvContour CV RETR TREE CV LINK RUNS cvPoin
37. attempt if device devnum 0 return 1 E00 failure IOCTL error n gt gt PWC FPS SHIFT if ioctl device devnum VIDIOCGWIN amp vwin lt 0 failure IOCTL error n vwin flags vwin flags amp PWC FPS MASK fps lt lt PWC FPS SHIFT if ioctl device devnum VIDIOCSWIN amp vwin lt 0 failure IOCTL error n success int Read_Image int devnum unsigned char dst unsigned char src Int h attempt if devicebuffers devnum size lt 0 failure Error buffersize lt 0 n printf MCapture starting n Capture devnum 0 printf MSync starting n Sync devnum 0 printf videobuffers Sx n printf devicebuffers x n printf otherl x printf other x src videobuffers devnum n videobuffers devnum devicewindows devnum widt HARD CODED IN printf Sd memcpy dst THIS SHOULD NOT B int src src 640 480 4 i LIK i THIS success int Save Image char filename unsigned char data int channels datasize size t channelsize FILE outfile attempt F 79 int videobuffers int devicebuffers devicebuffers devnum offsets 0 devicebuffers devnum offsets 0 h devicewindows devnum height int x int y ECE 477 Final Report Spring 2008 if data NULL failure Unallocated Data
38. else F 105 ECE 477 Final Report Spring 2008 int main printf Not active without highgui n return 0 alternate main endif HAVE OPENCV HIGHGUI H eof Subvehicle refs od od SearchPath test c od SearchPath test c ObjectDetection Search path test main E include od SearchPath h int main main eof ti Subvehicle refs od od SearchPath h od SearchPath h ObjectDetection Create a search path to find the logo ifndef SEARCH PATH H define SEARCH PATH H include od common h include od dbase h typedef struct od Path od HeliState target struct od Path next struct od Path prev od Path Given a database with the objects contained this will create a good idealy optimal flight path for searching the head of the path is the first element the next target is the next element in the doubly linked list path may or may not be allocated since this function will be called many times It is also used to update the path as new information in the db is known This returns how many commands are in the path 0 for any error encountered int odCreatePath od DB db od Path path F 106 ECE 477 Final Report endif SEARCH PATH H eof HH Subvehicle OMAR trunk serial h ifndef SERIAL H define SERIAL H include stdlib h
39. failures are due to voltages greater than 5V and less than 3 3 V Between 3 3V and 5V OMAR would run except at under 5V some sensors may not function accurately Incorrect VCC may be 16 ECE 477 Final Report Spring 2008 caused by battery failure or LDO failure This would be considered a medium criticality since it would either damage components or the objective would not be accomplished The FMECA table can be found in table B 1 of appendix B The second subsystem is the drive subsystem The schematic is shown in appendix A table A 2 The only 2 failure modes for the motors are the windings and brushes failing The cause of this could be wear on the brushes or the windings breaking The effects would be that OMAR would stop moving and this would stop the whole project Medium criticality would classify these failures because OMAR would not achieve its goal The FMECA table is located in appendix B table B 2 The third subsystem is the software subsystem and its supporting components The schematic is shown in appendix A figure A 3 The main components of the software subsystem are discrete capacitors resistors and inductors along with the microcontroller The first failure is that the microcontroller could lose communication with either the Gumstix or the sensors This could be caused by either dead ports incorrect VCC or failed connections This would be considered medium criticality since either one would cause OMAR to stop The only othe
40. i2c error ERROR if send addr r addr ERROR i2c error ERROR if get data ERROR i2c error ERROR range TWDR send stop return range int i2c transmit uint8 t addr uint8 t data i2c error OK int status 0 if send_start ERROR i2c error ERROR if send addr t addr ERROR i2c error ERROR if send data 0 ERROR i2c error ERROR if send data data ERROR i2c error ERROR send stop F 19 Spring 2008 ECE 477 Final Report Spring 2008 return OK end i2c transmit addr data uint8 t i2c read uint8 t addr uint8 t reg 326 efbror OK uint8 t data 0 if send start ERROR i2c error ERROR if send addr t addr ERROR i2c error ERROR if send data reg ERROR i2c error ERROR if send repeat ERROR i2c error ERROR if send addr r addr ERROR i2c error ERROR if get data ERROR i2c error ERROR data TWDR send stop return data end i2c read addr reg k k k send repeat OCkCk k ck kckckckckckckokckok kk sk ke ke ke ex x int send repeat i2c error OK TWCR 0 1 lt lt TWSTA 1 lt lt TWINT 1 lt lt TWEN repeat start code wait for repeat start sent while TWCR amp 1 lt lt TWINT check repeat start sent correct if TWSR amp OxF8 TW REP START i2c error ERROR
41. return SERIAL ERROR return SERIAL OK int CSerial serial open struct termios sdattrs pthread mutex lock amp state lock Make sure the port isn t already opened if state SERIAL CLOSED pthread mutex unlock amp state lock LOG ERRORLOG Serial port already open return SERIAL ERROR Open serial port sd open device 0 O RDWR O NOCTTY if sd 1 Failed to open serial port pthread mutex unlock amp state_ lock LOG ERRORLOG Failed to open serial port on s device return SERIAL ERROR Set serial port attributes memset ssdattrs 0 sizeof sdattrs sdattrs c cflag 0 CS8 CLOCAL CREAD sdattrs c_cc VMIN 1 cfsetispeed amp sdattrs SERIAL BAUD cfsetospeed amp sdattrs SERIAL BAUD tcflush sd TCIFLUSH tcsetattr sd TCSANOW amp sdattrs Set port as open state SERIAL OPEN pthread mutex unlock amp state lock LOG INFOLOG Serial opened on s device return SERIAL OK F 113 Spring 2008 ECE 477 Final Report int CSerial serial close pthread mutex lock amp state lock Make sure the port isn t already closed if state SERIAL CLOSED Close port close sd Stop thread state SERIAL CLOSED pthread mutex unlock amp state lock Wait for thread to return if thread id pthread join thread id N
42. server gt h addr list size 0 while addrlist size NULL printf s n addrlist s fendif memset amp addr 0 sizeof addr addr sin family addr sin port addr sin addr AF INET htons port if bind sockfd struct sockaddr amp addr sizeof addr printf error failed to bind port d s n port return 1 if connect sockfd struct sockaddr amp addr sizeof addr printf error failed to connect to s s n host return 1 printf connection open to s on dWMn host port memset amp buffer 0 sizeof buffer while 1 DREES ju fflush stdin fflush stdout fgets buffer sizeof buffer stdin fflush stdin fflush stdout if strncmp buffer quit 4 0 break size strlen buffer buffer size 1 0 printf read string of size d s n size buffer F 109 server h addrtype server h length ize struct in addr server gt h addr list 1 strerror errno Le DA 4 strerror errno ECE 477 Final Report Spring 2008 switch send sockfd buffer size 0 case 1 perror send failedin return 1 break case 0 printf server disconnected n return 1 break default putc Mn stdin printf bye n close sockfda return 0 THEE Subvehicle OMAR trunk main cpp include lt unistd h gt include lt signal h gt include Logger h include omar h in
43. static volatile uint8 t tx_write static volatile uint8 t tx buff TX BUFF SIZE void uart init Enable the UART for sending and receiving sbi UCSRB RXEN sbi UCSRB TXEN tx read tx write 0 Set baud rate registers UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx in terrupt sbi UCSRB RXCIE UART tx interrupt F 7 Spring 2008 ECE 477 Final Report Spring 2008 SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write Cbi UCSRB UDRIE return UDR tx buff tx read tx read tx read 1 gt TX BUFF SIZE 0 tx read 1 void put char uint8 t c uint8 t tmp write tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full if tmp write tx read sbi UCSRB UDRIE return tx buff tx write c tx write tmp write Enable Tx interrupt to start sending Sbi UCSRB UDRIE return void put short uintl6 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put str char str uint32 t len uint32 t i for i 0 i lt len i put char str i dibi Subvehicle Sensors trunk GP2Y0A700K adc c ifndef ADC H define ADC H include lt avr interrupt h gt include lt avr io h gt include adc h uint8 t uval lval F 8
44. tmp head uint8 t get char uint8 t tmp tail rx buffer empty if rx head rx tail return char NULL tmp tail rx tail rx tail rx tail 1 RX BUFF SIZE M return rx buff tmp tail uint8 t get str char buff uint8 t size uint32 t i 0 while buff i get char char NULL amp amp i lt size gebe return i UART tx interrupt SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write cbi UCSRB UDRIE return UDR tx_buff tx_read tx read tx read 1 gt TX BUFF SIZE 0 tx read 1 void put char uint8 t c uint8 t tmp write i tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full if tmp write tx read Sbi UCSRB UDRIE return tx buff tx write c F 38 ECE 477 Final Report Spring 2008 tx write tmp write Enable Tx interrupt to start sending Sbi UCSRB UDRIE return void put short uintl6 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put_str char str uint32 t i 0 while str i char NULL put char str i itt ii Subvehicle Sensors trunk servo uart h ifndef _ MY UART define MY UART include lt avr interrupt h gt include lt avr io h gt define TX BUFF SIZI define RX BUFF SIZI 256 256 ifndef BAUD If different
45. uintl6 t get sonar uint8 t addr uint8 t check 0 uintl6 t range 0 check i2c transmit addr 0 0x51 range i2c read addr 2 range range 8 range i2c read addr 3 return range uint8 t i2c transmit uint8 t addr uint8 t reg uint8 t data if send_start ERROR send stop return ERROR if send addr t addr ERROR send stop return ERROR if send data reg ERROR send stop F 44 ECE 477 Final Report return ERROR if send_data data send stop return ERROR send stop return OK end i2c transmit addr uint8 t i2c read uint8 t uint8 t data 0 ERROR data addr uint8 t reg if send_start ERROR send_stop return ERROR if send addr t addr send stop return ERROR if send data reg send stop return ERROR if send repeat E send stop return ERROR if send addr r addr send stop return ERROR if get nack data send stop return ERROR data TWDR send stop return data end i2c read addr re uint8 t hmc transmit uin int status 0 if send start E send stop return ERROR ERROR ERROR ERROR ERROR ERROR g t8 t addr uint8 t data RROR F 45 Spring 2008 ECE 477 Final Report if sen
46. void go reverse PORTC 1 lt lt 2 1 lt lt 4 PORTC amp 1 lt lt 3 amp 1 lt lt 5 return KKK RK KK KK kk KK KK k Turn Left Function Makes 4 5 go reverse Makes 6 7 go forward KCKCKCkCk kk ck ck ck ck ck ck ckckckck ko kk void turn left PORTC 1 lt lt 3 1 lt lt 4 PORTC amp 1 lt lt 2 amp 1 lt lt 5 return KKK RK RK KKK KKK ek Turn Right Function Makes 4 5 go forward Makes 6 7 go reverse KCKCKCkCk kk ck I ko kk void turn right PORTC 1 lt lt 2 1 lt lt 5 PORTC amp 1 lt lt 3 amp 1 lt lt 4 return KKK KK Ck KK KK KK kk Brake Function KCKCKCkCk kk k ck ck ck ck ck ck ck kk F 42 Spring 2008 ECE 477 Final Report void brake PORTC amp 1 lt lt 2 amp 1 lt lt 3 amp 1 lt lt 5 amp 1 lt lt 4 delay ms 10 return KKK RK Ck kk kk kk ke ke ek ek Update PID function Ck ck ck ck ckckckck ck ok ck ke x ke x x uintli6 t update PID uinti16 t heading desired uintl6 t pid uintl6 t P 0 uintl6 t D 0 int dt dt timer cnt 65535 TCNTIH lt lt 8 TCNT11 heading get compass 0x42 calculate heading error for proportional heading error heading desired heading P gain prop heading error if dt 0 D gain deriv heading error prev heading error dt
47. 20mm 67 6mm X 27 6mm Gumstix Proprietary Breakout 60 and 120 pin DIMM200 connectors 10 ECE 477 Final Report Spring 2008 4 0 Patent Liability Analysis In this project there are two main features that could infringe on active patents For one case of infringement a patent would need to claim the ability to autonomous control the body of the robot and move it around an area while getting input from sensors about the area This is essential the main idea of the project and thus the most important design feature to look up for infringement For another case of infringement a claim would need to specifically discuss how the robot takes in signals from sensors and computes the necessary data for mapping a room while providing the robot with signals to avoid obstacles in the room In OMAR s case a microcontroller takes in all the signals from the sensors and transfers the data to a processing device That device then maps the room and plots a path for the robot to take It then sends data back to the microcontroller and tells it how to move around in the area 4 1 Results of Patent and Product Search The first patent that closely resembled OMAR was number 6515614 filed on Oct 11 2001 titled Autonomous moving apparatus having obstacle avoidance function 14 The patent is for an autonomous moving apparatus that moves to a destination while detecting and avoiding an obstacle It includes devices to detect obstacles and move
48. ALIVE RETARDED 2008 04 08 100 nelson11 added silent install target to stop the motors while we debug 2008 04 08 99 rtoepfer changed 3 sonar sensors on the front scans 3 sensors and detects objects speed throttles at different object distances turns in right direction to avoid walls 2008 04 08 98 rtoepfer changed moved a 3 lines to the beginning of timer init that were in main they set the Data directions for PORTC D and 1 other 2008 04 08 97 rtoepfer changed changed makefile to define F CPU 8000000UL used for delay h 2008 04 07 96 rtoepfer Modified initial test of going until sonar senses wall then turn then go It currently senses walls but doesnt turn enough then it gets within the sonars minimum distance and hits the wall Need to try different object distance thresholds 2008 04 07 95 rtoepfer Modified added timer o 2008 04 07 94 rtoepfer Modified copied timer h from Motorcontrol repo originally was only for testing the servo Now included for motorcontrol 2008 04 07 93 rtoepfer Modified added support functions for UART RX added signal handler uint8 t get char and uint8 t get str buff size 2008 04 07 92 rtoepfer added initial add of code for controlling motors 2008 04 07 291 nelson11 added changes to reflect inclusion of client 2008 04 07 90 nelson11 removed Binary file from last commit 2008 04 07 89 nelson11 added Test client for network service VERY simple 2008 04 07 88 nelson11 change
49. CPU 800000UL delay h gt ERROR 1 Subvehicle Motorcontroller i2c h include lt avr interrupt h gt ENT ERROR 2 F 54 Spring 2008 ECE 477 Final Report define DATA SENT ERROR 3 define ADDR REC ERROR 4 define DATA REC ERROR 5 define DATA NACK REC ERROR 6 define SENT OK 7 define OK 0 define ERROR 1 define START 0x08 QUU void i2c init uintl6 t get compass uint8 t addr void get accel uint8 t addr uintl16 t data uintl6 t get sonar uint8 t addr uint8 t hmc transmit uint8 t addr uint8 t data uintli6 t hmc read uint8 t addr uint8 t i2c transmit uint8 t addr uint8 t reg uint8 t data uint8 t i2c read uint8 t addr uint8 t reg x f int send repeat int send start void send stop int send addr t uint8 t addr int send addr r uint8 t addr int send data uint8 t data int get data int get ack data int get nack data f endif I2C H HHtt Subvehicle refs od od LoadImage test c od LoadImage test c ObjectDetection odLoadImage test fil k int main return 0 main eof ERAN Subvehicle refs od camtest c camtest c ze A finclude lt sys time h gt include od Camera bi int main struct timeval time F 55 Spring 2008 ECE 477 Final Report char image int shutter s SOMEON
50. Chemically it is safe to dispose of this type of battery in the normal trash However if the battery isn t improperly discharged first shorting the leads or puncturing the pack could result in fire or explosion Proper instructions for a safe discharge method should be included in 20 ECE 477 Final Report Spring 2008 the user s manual as well as a word of encouragement hinting at the importance of following them 7 0 Packaging Design Considerations One of the main concerns for the packing design is that the vehicle will be carried by the helicopter 3 kilometers worth of GPS way points and then be shot into the building Because of these constraints the sub vehicle must be fairly small as the helicopter that is carrying it is not that large OMAR must also be very light weight since the helicopter has a payload of less than 25 pounds Lastly OMAR must be very robust since it must withstand the impact of be shot into the building by the helicopter Due to that fact that this is an ECE design project no concern with the operation of insertion into the building will be taken It will be assumed that the vehicle has landed upright inside the building and proceed from there 7 1 1 Commercial Product Packaging There are a very limited number of commercial products that are designed for the intended use of this project Most of the work being done in this field is for government use Autonomous navigation room mapping and image recogn
51. Ck kk kCk kk kk kk kk kk KK k k kk int send data uint8 t data F 12 ECE 477 Final Report Spring 2008 KCKCKCKCKCKCkCkCkCkCkCk Ck A kk kk kk k k kk ck k ck ck ck ck kk f int send data uint8 t data send data TWDR data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data transmission wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT flag set data sent ACK received check status MT DATA ACK if TWSR amp OxF8 TW MT DATA ACK return ERROR put str DATA SENT ERROR WnNr return OK end send data ckckckckckck kk k H kkkxkxkxkxkxkxkxkkkxkxkkxkxk e send stop void send stop send STOP condition TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWSTO return OK RK KKK KKK int get_data XCkckckckckck He x int get nack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data read send NACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK return ERROR put str DATA REC ERROR An Nr return OK RK KKK KKK int get data akaaft int get ack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWE
52. and sends it to the embedded computer just like the machine vision and navigational subsystem The embedded computer will continuously take in the data and map the room and then send data back to the microcontroller to give it a path to follow just like the navigational subsystem The only difference between the patent s claim and OMAR is that the project won t be handling moving obstacles Its functionality only covers detecting still obstacles Even with this small difference literal infringement exists between the patent and the project The last patent number 6539284 provided a basic design for an autonomous apparatus and could move and detect obstacles It had four main components a processing device memory to communicate with the processing device a mobility structure that moves the apparatus which is controlled by the processing device and at least one sensor for measuring an amount of movement This design matches OMAR because the processing device is the embedded computer which already has memory on it Then the computer gives out commands to move OMAR Also the body of OMAR will have an accelerometer to measure movement The only difference between the two designs is that the patent claims that the memory should have instructions to direct the apparatus to move within a predetermined safe area OMAR moves in any area it isn t predetermined Although this difference occurs between the two designs there are many similarities that br
53. annual International Aerial Robotic Competition IARC Its primary function is to provide autonomous reconnaissance within an unexplored room It is going to be a land based wheel driven vehicle which will use an array of range finders and proximity sensors to autonomously navigate and map out a room while avoiding obstacles In addition to that it will also have a camera which will take still images OMAR will continue to navigate this room until a specified logo is identified and relayed wirelessly back to a base station in this case a laptop computer OMAR has been able to achieve autonomous navigation and logo detection but was unable to complete room mapping Regardless of the results it is still fully capable of completing the intended mission ECE 477 Final Report Spring 2008 1 0 Project Overview and Block Diagram OMAR is the Outstanding Mobile Autonomous Robot Its goal is to act as a reconnaissance sub vehicle for the Purdue IEEE Student Branch s entry in the International Aerial Robotics Competition IARC The competition consists of four stages 1 Autonomously fly a 3km course of GPS way points 2 Locate a marked building in a group of buildings 3 Enter the building locate and photograph a control panel 4 Complete stages 1 3 in less than 15 minutes OMAR role will be in the third stage entry and reconnaissance of the building Reconnaissance in this case consists of locating and photographing a control panel on a wall
54. board trunk main c include lt avr interrupt h gt include avr io h include i2c h include uart h include timer h include MControl h define DEBUG 0 F 145 ECE 477 Final Report define STOP 0 define GO 1 define LEFT 2 define RIGHT 3 define REVERSE 4 define THRESHOLD 50 define THROTT E THRESH 200 define SONAR SIZE 8 define SC OxE define SL OxE6 define SR OxE2 define THRESH STEP 25 int main char s 200 uinti6 t sonarl SONAR SIZ uinti6 t sonar2 SONAR SIZ uintl6 t sonar3 SONAR SIZ Di Dp D Cy Oo Eris ER unsigned int sonar suml unsigned int sonar sum2 0 unsigned int sonar sum3 0 uint8 t state STOP uint8 t i 0 uint8 t x 0 uint8 t sonar avg size 1 int left speed 0 int right speed 0 uint8 t throttle OxFF int16 t speed gain 0 int8 t thresh count 0 uintli6 t curr heading 0 uintl6 t heading desired 0 uint8 t offset 0 init uart and i2c uart init timer init i2c init sei delay ms 32 brake timer start while 1 send acquire get data i2c transmit SC 0 0x51 delay us 80 0 0 0 sonarl i i2c read SC 2 8 sonarl i i2c read SC 3 i2c transmit SL 0 0x51 delay us 80 sonar2 i i2c read SL 2 lt lt 8 sonar2 i i2c read SL 3 i2c transmit SR 0 0x51 F 146
55. data send data TWDR data wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT flag set received check status MT DATA ACK if TWSR amp OxF8 TW MT DATA ACK return ERROR put str DATA SENT ERROR inNr return OK end send data fk x e KKK send stop FE ck kk ke x ke x x6 void send stop send STOP condition TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWSTO return OK KKK KKK KK int get data akaaft int get data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to NACK wait for ACK sent while TWCR amp 1 lt lt TWINT wait for TWINT flag set check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK return ERROR put str DATA REC ERROR An Nr return OK KKK KKK KKK TRE get data XCkckckckckck ck kk ke ke ke x int get nack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to NACK wait for ACK sent while TWCR amp 1 lt lt TWINT wait for TWINT flag set check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK F 48 TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to Spring 2008 start data transmission data sent ACK start data read
56. db gt VLS ntlinks Temp db gt VLS head od VertLink for i 1 i OD INIT VLS SIZE i Temp gt next malloc sizeof assert Temp gt next NULL Temp Temp gt next a Temp gt next NULL db gt VLS nclinks db gt VLS ntlinks db gt VLS tail Temp 1 end fo return 1 eof int _odDestroyVLinkServer od_DB int i od VertLink Temp while db gt VLS head NULL Temp Temp db gt VLS head N ULL db gt VLS nclinks db gt VLS ntlinks return 1 Subvehicle refs od od LoadImage c Hi od LoadImage c ObjectDetection include od ImageProcess h include stdio h db db gt VLS head db gt VLS head gt next free Temp IplImage odLoadImage void src Iplimage dst return dst odLoadImage eof load our output image from the F 96 camera into an IplImage Spring 2008 ECE 477 Final Report tit Subvehicle refs od od main c t include od common h int main return 0 main eof ZEIEN Subvehicle refs od od dbase test c include od dbase h include lt stdio h gt i nt main int check od_DB db db gt objects NULL db gt ver db V db 0 jS ticesDB NULL NULL iS NULL check _odCr
57. down to 5 0 and 3 3 volts Power traces will be 70 mil since ample space exists which will help make the power lines less resistant 25 The digital section covers the microcontroller and most of the traces to the headers These traces will be 12 mil and the headers will be placed all around the microcontroller to shorten path lengths to limit the chance of EMI 25 Two level translators are necessary for the accelerometer and magnetometer since they run at 3 3 volts while the other 27 ECE 477 Final Report Spring 2008 sensors run at 5 0 volts Those two components have bypass capacitors for each of the two power signals coming in which is recommended by the manufacturer to be 0 1uF per capacitor 24 The analog section covers the ADC lines that go from the microcontroller to the IR sensors and motor controller These lines need to be clear from power lines to reduce noise and interference 25 This will be accomplished by placing nothing else around or routing nothing else through that area 9 1 PCB Layout Design Considerations Microcontroller The microcontroller has three pins for power and another line to power the ADC converter Bypass capacitors placed between power and ground will help reduce the load on power lines and remove unwanted glitches The manufacturer advises to put a LC circuit on the power for the ADC converter to help reduce noise 11 The capacitors and inductor need to be placed as close to the microcontroller to
58. dummy 1 error exit VIDIOCPWCGCONTOUR printf Sharpness d n dummy if ioctl device devnum VIDIOCPWCGBACKLIGHT amp dummy 1 error exit VIDIOCPWCGBACKLIGHT printf Backlight compensation mode if dummy 0 printf off n else printf on n if ioctl device devnum VIDIOCPWCGFLICKER amp dummy 1 printf Anti flicker mode if dummy 0 printf off n else printf on n else not supported Anti flicker mode if ioctl device devnum VIDIOCPWCGDYNNOISE amp dummy 1 printf Noise reduction mode d dummy if dummy 0 printf none else if dummy 3 printf high printf Mn else not supported Noise reduction mode if ioctl device devnum VIDIOCPWCMPTGRANGE amp pmr 1 not_supported Pan tilt range else printf Pan min Sd max Sd n pmr pan min pmr pan max printf Tilt min d max din pmr tilt min pmr tilt max printf Zoom min d max d n pmr zoom min pmr zoom max pma absolute 1 if ioctl device devnum VIDIOCPWCMPTGANGLE amp pma 1 not_supported Get pan tilt position F 83 ECE 477 Final Report Spring 2008 else printf Pan degrees 100 Sd n pma pan printf Tilt degrees 100 d n pma tilt printf Zoom d n pma zoom void Query Pan Tilt Status int devnum struct pwc mpt status pms
59. employed This part is capable of sourcing a maximum of 30A in both forward and reverse with a Vccmax of 41V Each motor requires 2 5 3 0A at the maximum VIN of 12V Each motor controller will be required to drive two motors in series at VIN of 7 4 11 1V The constant current supplied by each motor controller should be 4 6A with no more than 20 254 inrush current which is well within the specifications for the device The VNH2SP30 E 8 also requires a power MOSFET for reverse voltage protection The ST STD60NF3LL 12 was spotted in a similar circuit online and meets the requirements for this application so it will be utilized ECE 477 Final Report Spring 2008 3 1 5 Power Constraints With the intended use of OMAR being autonomous reconnaissance it should be a standalone system which means it will have to be battery powered The rules of the competition dictate that the four phases must be completed in less than 15 minutes which has been made the minimum battery life of the rover There are a lot of electrical components on the rover however many of them use a lot of power except for the motors and the servo The battery should be able to handle the inrush current of the motors which has been estimated to be no more than 30 amps The H bridges 8 and power MOSFETS 12 that will drive the motors will probably need a little heat dissipation which will be accounted for by using heat sinks It will also be more than likely contained in an open air en
60. enemy to become aware of the militaries intentions or cost soldiers their lives OMAR will most likely be very expensive to meet the militaries requirements and because it will most likely only have 1 chance to succeed it needs to be extremely reliable Safety is not necessarily a large concern with OMAR There should be no end user interaction if it is used for its intended purpose OMAR will be fully autonomous and is not intended to return to the user Human interaction is only possible in 2 situations One possibility is with the enemy and safety may not be as big of a concern The other situation is during testing and safety may be of concern if the user must come in contact with OMAR 5 1 Reliability Analysis Omar has quite a few parts that will need reliability and safety consideration Each part of OMAR is necessary to complete our objective but not all parts are necessary for partial completion The magnetometer accelerometer and IR sensors are necessary for the room mapping objective but not for the image recognition The microcontroller sonar and motors however are necessary to complete any of the stated 5 PSSC s Because there are so many components in this project that will need reliability calculations only 3 components will be chosen as examples 14 ECE 477 Final Report Spring 2008 The 3 devices that we believe are most likely to fail are the voltage regulators microcontroller and the motors All 3 of these componen
61. f int send addr r uint8 t addr send addr TWDR addr 0x01 TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MR SLA ACK return ERROR put str ADDR SENT ERROR WnNr return OK end send addr KKK RK KK Ck kk kk Ck kk kk kk kk kk Z kk KK k kk kk e int send data uint8 t data XKCKCKCKCKCKCkCkCkCkCkCkCkCkCkCk Ck k kCk Ck kk kk kk ck k ck ck ck ck kckck sk ck int send data uint8 t data send data TWDR data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data transmission wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT flag set data sent ACK received check status MT DATA ACK if TWSR amp OxF8 TW MT DATA ACK return ERROR put str DATA SENT ERROR inNr return OK end send data RRR dece RK D Ze de de dek Jeder de de dede dece de de de de send stop void send stop send STOP condition TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWSTO return OK e ese se he desees 1 D We Se Sete ie cw he de sede Se se A int get data F
62. getting the needed parts for it A 2 Contributions of Josh Wildey Josh Wildey was the only EE on the team so he mainly worked with the circuitry and the hardware He made all of made all of the initial schematics with the help from Mike since he was the one making the PCB Initially a switching power supply was going to be used but it was later decided to use LDOs because they were much simpler and left little room for error The motor controller came was bought to be able to get OMAR moving before the PCB was made Josh also made the initial chassis for OMAR to test the motor controller The chassis is very similar to that in Appendix B with minor fluctuations in the measurements Once there was a platform to test on he wrote code for the microcontroller to interface it with the motor controller The motor controller needed a total of 6 inputs from the microcontroller Two of them were the PWM signals that came from the 8 bit timers and the other four were GPIOs from the ATmega which specified direction The JTAG programming interface had to be disabled to use port C for GPIO pins for the motor controller After getting OMAR moving Josh started looking over the code that RJ had written that interfaced all of the sensors and the communication code After getting familiar with RJ s code he wrote a proportional derivative loop that would be used to make OMAR drive straight by varying the speed of the motors Initial testing was done with the loo
63. high resolution timers priority inheritance and generic interrupt layer enhancements in version 2 6 18 Linux is considered to be a soft real time system 29 30 To take advantage of the process scheduler the software will need to be extensively threaded and its niceness needs set low to give it high priority The software running on the Gumstix embedded computer will need to perform a couple of compute heavy tasks mapping and object detection service several potentially high latency devices network USB and UART as well as respond quickly to requests from the microcontroller To ensure all of this work goes on harmoniously the application will be event driven using callbacks and heavily threaded C is the chosen language for its encapsulation and data protection properties The POSIX threading library is employed for parallelization and synchronization Development takes place on Linux work stations using a GNU arm linux toolchain provided by Gumstix 29 ECE 477 Final Report Spring 2008 The motor controller and servo are both utilizing the timers that are set for fast PVM mode The fast PWM mode was chosen because it uses a single slope operation which provides twice the frequency capabilities of the phase correct PWM mode The frequency of the PWM was chosen to be 3 9 kHz because the maximum frequency that the motor controller is 20 KHz and 3 9 kHz worked out best for the pre scaling options from the system clock The timer also nee
64. if get nack data ERROR return ERROR data TWDR send stop return data end i2c read addr reg RK KK KK send repeat CkCkCk ck kckckckckckckckck ok kok ek ke ke ke ex x int send repeat TWCR 0 1 lt lt TWSTA 1 lt lt TWINT 1 lt lt TWEN repeat start code wait for repeat start sent while TWCR amp 1 lt lt TWINT F 30 ECE 477 Final Report Spring 2008 check repeat start sent correct if TWSR amp OxF8 TW REP START return ERROR put str REP START ERRORMn Nr return OK end send repeat KRKKKKK send_start CKCkCk Ck k kc k KK KK KK KK KK e int send start send start TWCR 0 1 lt lt TWINT 1 lt lt TWSTA 1 lt lt TWEN send start condition wait for start sent while TWCR amp 1 TWINT wait for TWINT flag set indicates start sent check start sent correct if TWSR amp OxF8 START return ERROR put str START ERRORWMnNr return OK end send start KRKKKK send addr t uint8 t addr KCKCkck ck ck ck ckck KK e x x f int send addr t uint8 t addr send addr TWDR addr TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT to start transmission of addresss wait for ACK while TWCR amp 1 lt lt TWINT check status slave sent ack received if TWSR amp OxF8 TW MT SLA ACK
65. if ioctl device devnum VIDIOCPWCMPTSTATUS amp pms 1 error exit VIDIOCPWCMPTSTATUS printf Status dWMn pms status printf Time pan d n pms time pan printf Time tilt dWn pms time tilt void Reset Pan Tilt int devnum int what if ioctl device devnum VIDIOCPWCMPTRESET what 1 error exit VIDIOCPWCMPTRESET void Set Pan Or Tilt Or Zoom int devnum char what int value struct pwc_mpt_angles pma pma absolute 1 if ioctl device devnum VIDIOCPWCMPTGANGLE amp pma 1 error exit VIDIOCPWCMPTGANGLE if what SET PAN pma pan value else if what ET TILT pma tilt value else if what SET Z00M pma zoom value if ioctl device devnum VIDIOCPWCMPTSANGLE amp pma 1 error exit VIDIOCPWCMPTSANGLE void Set PanTilt int devnum int pan int tilt struct pwc mpt angles pma pma absolute 1 if ioctl device devnum VIDIOCPWCMPTGANGLE amp pma 1 error exit VIDIOCPWCMPTGANGLE pma pan pan pma tilt tilt if ioctl device devnum VIDIOCPWCMPTSANGLE amp pma 1 error exit VIDIOCPWCMPTSANGLE void Get PanTilt int devnum int pan int tilt struct pwc mpt status pms F 84 ECE 477 Final Report if ioctl device devnum VIDIOCPWCMPTSTATUS amp pms 1 error exit VIDIOCPWCMPTSTATUS pan pms time pan tilt pms
66. if pCam delete pCam if pNet delete pNet 4 Subvehicle OMAR trunk messages h messages h defines interface with microcontroller ifndef MESSAGES H define MESSAGES H endif MESSAGES H FRAN Subvehicle OMAR trunk camera cpp KOR K RK KK KK KK KK KK kk ek This code is based off of refs od od Camera c Ck ck ck ck kk kk ck ck ockck AKA AKA Z A KA kk kk kk Many of the functions are from vidcat c from the w3cam project Copyright C 1998 2001 Rasca Berlin This program is free software you can redistribute it and or modify F 126 Spring 2008 ECE 477 Final Report c Foundation Inc 675 Mass Ave X X F F F F F X X ox include lt sys time h gt include lt stdio h gt include lt stdlib h gt include lt string h gt include lt unistd h gt include lt linux types h gt include lt linux videodev h gt include lt sys types h gt include lt sys ioctl h gt include lt sys mman h gt include fcntl h include camera h include Logger h ifdef cplusplus extern C include lt jpeglib h gt include pwc ioctl h include v41 n Spring 2008 t under the terms of the GNU General Public License as published by he Free Software Foundation either version 2 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT AN
67. in in if de en in de de de de de de de de de de clude lt avr interrupt h gt clude avr io h tdio h til twi h PU PU 800000UL til delay h fine START ERROR 1 fine ADDR SENT ERROR 2 D ATA SENT ERROR 3 fine ADDR REC ERROR 4 clude s clude u ndef F C fine F C dif clude u fine fine fine fine O DATA REC ERROR 5 fine DATA NACK REC ERROR 6 SE K ENT OK 7 0 fine ERROR OxFF fine START 0x08 void i2c init uin tl6 t get compass void get accel uint8 t addr uintl16 t data inline void send acquire uin uin uin uin uin in in vo in in in in in in C ck ek ck CT ck ECT sot tl6 t hmc read uint8 t addr t8 t i2c transmit uint8 t addr uint8 t reg uint8 t data t8 t i2c read uint8 t addr uint8 t reg send repeat send start d send stop send addr t uint8 t addr send addr r uint8 t addr send data uint8 t data get data get ack data get nack data t8 t get sonar uint8 t addr t8 t hmc transmit uint8 t addr uint8 t data endif I2C H F 154 Spring 2008 ECE 477 Final Report Spring 2008 Appendix G FMECA Worksheet KSE G 1 FMECA Power ie Failure Made Mode Possible Possible Causes Failure Failure Effects Method Method of Detection Detection Criticality Output 0
68. n if outfile fopen filename wtb failure Couldn t create output file n channels 1 datasize 1 channelsize x y fwrite amp x 2 1 0utfile fwrite amp y 2 1 outfile fwrite amp channels 2 1 0utfile fwrite amp datasize 2 1 0utfile fwrite data 1 channelsize outfile fclose outfile success int Select Input int devnum int number struct video channel arg char err 255 attempt if device devnum lt 0 failure Error Bad Device Num n arg channel number if ioctl device devnum VIDIOCGCHAN amp arg lt 0 sprintf err Select Input Error dWMn errno failure err if ioctl device devnum VIDIOCSCHAN amp arg lt 0 sprintf err Select Input Error d n errno failure err success int Set Led int devnum int on time int off time struct pwc_leds leds attempt if device devnum lt 0 failure Error Bad Device Num n leds led on on time leds led off off time if ioctl device devnum VIDIOCPWCSLED amp leds 0 return 1 success void error exit char what ioctl fprintf stderr Error while doing ioctl s s n what_ioctl strerror errno commented out some versions of the driver seem to return unexpected errors F 80 ECE 477 Final Report exit 1 void not_supported char what printf s is not supported by the combinatio
69. n width if height gt vid caps maxheight height lt vid caps minheight height min height vid caps maxheight height max height vid caps minheight fprintf stderr readjusting height to d n height return 0 check the requested palette and adjust if possible seems not to work int v4l check palette int fd int palette struct video picture vid pic if palette return 1 if ioctl fd VIDIOCGPICT amp vid pic 1 perror ioctl VIDIOCGPICT return 1 vid pic palette palette if ioctl fd VIDIOCSPICT amp vid pic 1 try YUV420P f fprintf stderr failed n vid pic palette palette VIDEO PALETTE YUV420P if ioctl fd VIDIOCSPICT amp vid pic 1 F 89 ECE 477 Final Report Spring 2008 perror ioctl VIDIOCSPICT to YUV ok try grayscale Tu vid pic palette palette VIDEO PALETTE GREY if ioctl fd VIDIOCSPICT amp vid pic 1 perror ioctl VIDIOCSPICT to GREY return 1 return 0 check if driver supports mmap ed buffer int v4l check mmap int fd int size struct video mbuf vid buf if ioctl fd VIDIOCGMBUF amp vid buf 1 return 1 if size size vid_buf size return 0 mute sound if available int v41 mute sound int fd struct video capability vid caps struct video audio vid aud if ioctl fd
70. no longer pass the address the address is static 2008 04 10 110 rtoepfer changed change get_compass to no longer need the address passed address is static 2008 04 10 109 jwildey Modified more of the PID loop still not done yet though 2008 04 10 108 rtoepfer changed dont forget to comment the print statements this code seems to work well except the extreme angle 2008 04 09 107 rtoepfer changed adde value to detect incorrect acceleration 2008 04 09 106 rtoepfer changed changed i2c c to not error out when it errors i think main was probably changed to read different address not important 2008 04 09 105 rtoepfer added initial add of servo code 20Hz frequency change OCR1A to vary duty cycle goes from 650 2450 then reverses Boundaries seem to be greater than the servo extremes LDO gets really hot need to change the max min values for OCR1A to match servo boundaries 2008 04 09 104 rtoepfer removed deleted files that TRENT STUPIDLY inserted Still trying to teach trent unix he will get there 2008 04 09 103 rtoepfer added initial add of Low range IR code Reads values from the adc Currently using the 2 56V internal AREF Trent says it works but the values dont match the ones in teh manual 2008 04 08 102 rtoepfer changed added states for left and right seems to work fairly well Corner case where it approaches a wall at a small angle still hits the wall 2008 04 08 101 rtoepfer fixed SILENT NOT SLIENT TRENT ARE U
71. not write to the Free Software Foundation Inc 59 Temple Place Suite 330 Boston MA 02111 1307 USA s This is pwc ioctl h belonging to PWC 8 10 Changes 2001 08 03 Alvarado Added ioctl constants to access methods for changing white balance and red blue gains 2002 12 15 G H Fernandez Toribio VIDIOCGREALSIZE These are private ioctl commands specific for the Philips webcams They contain functions not found in other webcams and settings not specified in the Video4Linux API The define names are built up like follows VIDIOC VIDeo IOCtl prefix PWC Philps WebCam G optional Get S optional Set the function V The frame rate is encoded in the video window flags parameter using the upper 16 bits since some flags are defined nowadays The following defines provide a mask and shift to filter out this value In Snapshot mode the camera freezes its automatic exposure and colour balance controls x7 define PWC FPS SHIFT 16 define PWC FPS MASK 0x00FF0000 define PWC_FPS_FRMASK 0x003F0000 define PWC FPS SNAPSHOT 0x00400000 struct pwc_probe char name 32 int type pwc_whitebalance mode values define PWC WB INDOOR 0 define PWC WB OUTDOOR 1 define PWC WB FL 2 define PWC WB MANUAL 3 define PWC WB AUTO 4 Used with VIDIOCPWC SG AWB Auto White Balance F 115 ECE 477 Final Report Spring 2008 Set mode to one of the PWC WB
72. out char image palette int y x line width JSAMPROW row ptr 1 struct jpeg compress struct cjpeg struct jpeg error mgr jerr char line line char malloc width 3 if line return cjpeg err jpeg std error amp jerr jpeg create compress amp cjpeg cjpeg image width width cjpeg image height height cjpeg input components 3 cjpeg in color space JCS RGB jpeg set defaults amp cjpeg jpeg set quality amp cjpeg quality TRU cjpeg dct method JDCT FASTEST jpeg stdio dest amp cjpeg out jpeg start compress row ptr 0 JSAMPLE if palette VIDEO PALETTE GREY line width width for y 0 y lt height ytt row ptr 0 JSAMPLE image int width jpeg write scanlines amp cjpeg row ptr 1 image line width else line width width 3 for y 0 y lt height ytt for x 0 x lt line width x 3 line x image x 2 line x 1 image x 1 line x 2 image x jpeg write scanlines amp cjpeg row ptr 1 image line width jpeg finish compress amp cjpeg F 131 int height int quality Spring 2008 int ECE 477 Final Report Spring 2008 jpeg destroy compress amp cjpeg free line fendif dibi Subvehicle OMAR trunk slam cpp include slam h Subvehicle OMAR trunk camera h
73. portability Intel s OpenCV library handled the image detection algorithm and is open source The SLAM mapping and localization ended up being scrapped as for it to be in any way accurate required large amounts of memory and grid ECE 477 Final Report Spring 2008 computing far from real time and nowhere near deployable on a robot of OMAR s size The rest of the code came from the standard C libraries Trent also had some non technical contributions He wrote the Software Design Analysis paper as well as the Environmental and Ethical Considerations paper He also setup an SVN repository on a Purdue IEEE Student Branch server for concurrent versioning of all of the software projects To complement this he setup an on line source browser using viewvc that allowed for viewing of source code with syntax highlighting and version differences all from the comfort of a web browser A 4 Contributions of Robert Toepfer During the conceptual design stage of the project Robert was responsible for a few different things First Robert found a decent web template to use for our website and laid out the basic structure for our website Aside from the basic setup of the website Robert researched many of the different components to be used Robert first looked into the various options for a high speed embedded computer to do the image recognition and room mapping For this application X scale processors were considered since they had much higher clock speeds
74. put str REP START ERROR n r return OK end send repeat KRKKK KK send start kb int send start i2c error OK send start TWCR 0 1 lt lt TWINT 1 lt lt TWSTA 1 lt lt TWEN send start condition wait for start sent while TWCR amp 1 TWINT wait for TWINT flag set indicates start sent check start sent correct if TWSR amp OxF8 START i2c error ERROR put str START ERRORWMn Nr return OK end send start KRKKKK send addr t uint8 t addr KCKCkck ck ck ck ck KK e x x f F 20 ECE 477 Final Report Spring 2008 int send addr t uint8 t addr i2c error OK send addr TWDR addr TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT to start transmission of addresss wait for ACK while TWCR amp 1 TWINT wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MT SLA ACK i2c error ERROR put str ADDR SENT ERROR n r return OK end send addr KRKKKK send addr r uint8 t addr KCKCkck ck ck ck ckck KK e x amp f int send addr r uint8 t addr i2c error OK send addr TWDR addr 0x01 TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK whi
75. redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Foundation Inc 675 Mass Ave Cambridge MA 02139 USA 0 F X F 0 o Xo F X X XR F F HF X ifndef VAL H define VAL H define INPUT DEFAULT m define NORM DEFAULT 1 ifndef TRU ti ond define TRUE 1 endif ifndef FALSE define FALSE 0 endif int v4l set input int fd int input int norm int v4l check size int fd int width int height int v4l check palette int fd int palette int v4l mute sound int fd int v4l check mmap int fd int size int v4l yuv420p2rgb unsigned char unsigned char int int int int v4l yuv422p2rgb unsigned char unsigned char int int int fendif Ht tt Subvehicle refs od otherlibs philipscamera h philipscamera c This file is part of PhilipsWebCamLib it under the terms of the GNU General Public License as published by he Free Softwa
76. robust making more suitable than the Pioneer 3 AT 19 for OMARs design The first packaging and design specification to consider is the tank drive system The tank drive system allows it to disperse its weight across a larger surface area allowing it to traverse just about any kind of terrain The triangular tracks in the front allow the tank to climb stairs This tank drive system with the triangular wheels is more expensive and not necessary for OMAR since OMAR is only mapping the inside of a building and the terrain will not vary The rest of the packaging specs on the PackBot 20 are the laser range finder camera and sonar sensors The laser range finder is capable of 360 scanning and thus can be mounted anywhere on top of the tank as long as it has clear vision Again laser ranger scanners are too large and expensive so OMAR will not be using one The idea of scanning 360 seems to be more efficient so this will be incorporated into the design The single camera is on the front of the vehicle close to the bottom This seems to be inefficient since the camera will only be able to take pictures from a low angle OMAR will be using the single camera design mounted Finally there are 2 or 3 sonar sensors mounted on the very front of the PackBot 20 OMAR will copy this design and have 2 or 3 sonar sensors on the front 23 ECE 477 Final Report Spring 2008 7 2 Project Packaging Specifications As mentioned before OMAR needs to be ve
77. send data sent NACK sent start data read send data sent NACK sent ECE 477 Final Report Spring 2008 return ERROR put str DATA REC ERRORMn Nr return OK RK KKK KKK int get data XCkckckckckck ck kk ke e e x x int get ack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA ACK return ERROR put str DATA REC ERROR An Nr return OK k Subvehicle Motorcontroller main c include lt avr interrupt h gt include lt avr io h gt include timer h include lt util delay h gt include MControl h include i2c h include uart h include avr wdt h int main int i 0 int j 0 char s 100 uintl6 t accel data 3 0 timer init uart init sei wdt disable DDRC OxFF enable PC2 7 as logic level outputs for motorcontroller DDRB 1 3 enable PB3 as output for PWM signal DDRD 1 7 enable PD7 as output for PWM signal hmc transmit 0x42 0x57 i2c transmit 0x3A 0x20 0xB7 brake snprintf s 60 Heading 5u n n r get compass 0x42 put str s timer start go reverse F 49 ECE 477 Final Rep
78. t c Write 16 bit value to UART void put short uintl6 t s Write string of length len to UART F 35 Spring 2008 ECE 477 Final Report VO i i i i i d i d d d d d d d d d d vo in ui in in vo in in in in in in e i i i i S i s i in id put str char str endif MY UART Subvehicle Sensors trunk HMC6352 i2c h fndef I2C H define I2C H nclude avr interrupt h nclude avr io h nclude lt stdio h gt nclude util twi h efine F CPU 800000UL nclude util delay h efine START ERROR 1 efine ADDR SENT ERROR 2 efine DATA SENT ERROR 3 efine ADDR REC ERROR 4 efine DATA REC ERROR 5 efine DATA NACK REC ERROR 6 efine SENT OK 7 efine OK 0 efine ERROR 1 efine START 0x08 id i2c init t hmc transmit uint8 t addr uint8 t data ntl6 t hmc read uint8 t addr t send repeat send start d send stop send addr t uint8 t addr send addr r uint8 t addr send data uint8 t data get data get ack data get nack data ct ct ct ct ct tect ndif I2C H Subvehicle Sensors trunk servo main c nclude lt avr interrupt h gt nclude lt avr io h gt nclude lt stdlib h gt nclude lt string h gt nclude lt stdio h gt nclude lt util delay h gt nclude timer h nclude uart h t main ti
79. t timer cnt void timer start void timer stop void timer reset void timer init void endif timer h ii Subvehicle Sensor board trunk timer c include lt avr interrupt h gt F 152 Spring 2008 ECE 477 Final Report Spring 2008 include timer h uintl6 t timer cnt void timer init void DDRC OxFF enable PC2 7 as logic level outputs for motorcontroller DDRB 1 3 enable PB3 as output for PWM signal DDRD 1 7 enable PD7 as output for PWM signal Timer0 clk0 Mo TCCRO 0x6A Se Se tor Controller t Timer Counter0 to fast PWM mode t output compare to asserted state Prescaler factor to set PWM freq at 3 9KHz max PWM freq is 20KHz OCRO OxFF se TCCR2 Ox6A Se 8 t output compare register to Duty cycle t Timer Counter2 to fast PWM mode et output compare to asserted state Prescaler factor to set PWM at 3 9KHz OCR2 OxFF Se t OC reg to something TIMSK 0x04 enable timer overflow interrupt timer cnt 0 void timer start TCCR1B 0x05 set freq void timer stop TCCR1A 0X00 TCCR1B 0X00 void timer reset TCNT1H 0x00 TCNT1L 0x00 timer cnt 0 ISR TIMER1 OVF vect timer cnt TCCR1A 0x0C normal mode to i Subvehicle Sensor board trunk i2c h ifndef I2C H define I2C H F 153 ECE 477 Final Report in in
80. the maximum dimensions of around 14 x6 x6 and mechanical components like motors and tires taking up a large portion of this space already it was important that the electrical components be kept small Since the software is going to be fairly complex on its own an embedded linux solution seemed to be a good choice Before going to a pre built computer module ucLinux was investigated ucLinux is an open source project aimed at porting linux to several popular microcontrollers It has a large user community and supported device list Unfortunately their website was very unstable making research difficult Even when a device list was obtained it didn t look like any of the supported microcontrollers had a high enough clock rate USB host controller and reasonable package It was during this research that the Marvell XScale PXA series microprocessors were discovered The new Marvell XScale PXA series seemed like a perfect solution to the proposed problems This processor line had clock rates ranging from 600 800MHz and a USB host ECE 477 Final Report Spring 2008 controller with one caveat the only available package is BGA Fortunately there are several pre built computers using this CPU The two most appealing models were the Strategic Test TRITON 320 13 and Gumstix Verdex XL6P 10 Both have very small footprints and low power requirements The TRITON 320 was attractive because of its unique interface with the real world AII that was requ
81. the speed to drive the motors from how long the PWM cycle is asserted The H bridges also have two GPIO pins per channel which determine the state of the motors to drive forward reverse brake to ground or brake to V The code for this part of the 3l ECE 477 Final Report Spring 2008 project is completed entirely to allow the car to drive however testing needs to be done to see how straight OMAR will drive Assuming that it will not drive straight the magnetometer will be implemented into the drive forward and reverse functions that will vary the PWM duty cycles to compensate to help OMAR drive straight The magnetometer will also be used to turn OMAR and the motor controller will drive each side of wheels in opposite directions until the desired angle is reached Neither of these considerations has been completed and will be once the frame is built and OMAR is mobile The magnetometer accelerometer and sonar sensors all use the i2c module For each device the ATmega32 will send the address of the device it wants to read send the command to acquire data and then continue to read out the necessary number of bytes For the IR sensors the ADC is triggered to take a sample and then the data is copied to a variable Once all data is collected the main loop will dump the data to Gumstix via the UART The functions for each of these devices has been written and tested on the PCB The micro can successfully read each sensor and send the data ove
82. time tilt void Set Framerate int devnum int framerate struct video window vwin get resolution framerate if ioctl device devnum VIDIOCGWIN amp vwin 1 error exit VIDIOCGWIN if vwin flags amp PWC FPS FRMASK set new framerate vwin flags amp PWC FPS FRMASK vwin flags framerate lt lt PWC FPS SHIFT if ioctl device devnum VIDIOCSWIN amp vwin 1 error exit VIDIOCSWIN else fprintf stderr This device doesn t support setting the framerate n exit 1 void Flash Settings int devnum if ioctl device devnum VIDIOCPWCSUSER 1 error exit VIDIOCPWCSUSER void Restore Settings int devnum if ioctl device devnum VIDIOCPWCRUSER 1 error exit VIDIOCPWCRUSER void Restore Factory Settings int devnum if ioctl device devnum VIDIOCPWCFACTORY 1 error exit VIDIOCPWCFACTORY void Set Compression Preference int devnum int pref if ioctl device devnum VIDIOCPWCSCQUAL amp pref 1 error exit VIDIOCPWCSCQUAL void Set Automatic Gain Control int devnum int pref if ioctl device devnum VIDIOCPWCSAGC amp pref 1 error exit VIDIOCPWCSAGC F 85 Spring 2008 ECE 477 Final Report void Set Shutter Speed int devnum int pref if ioctl device devnum VIDIOCPWCSSHUTTER error exit VIDIOCPWCSSHUTTER amp p
83. val OCR1AH OCRIAL val amp OxFF00 gt gt 8 val amp OxOOFF void timer start TCCR1A 0x0C normal mode TCCRIB 0x05 set freq to void timer stop F 40 Spring 2008 ECE 477 Final Report TCCR1A 0x00 TCCR1B 0X00 void timer reset TCNT1H 0x00 TCNT1L 0x00 timer cnt 0 ISR TIMER1 OVF vect timer cnt kb Subvehicle Motorcontroller adc h ifndef MY ADC define MY ADC include lt avr interrupt h gt include lt avr io h gt extern uint8 t lval uval void adc_init uintl6 t read adc void endif MY ADC Subvehicle Motorcontroller MControl c include lt avr interrupt h gt include lt avr io h gt include MControl h include lt util delay h gt include i2c h define gain prop 1 define gain deriv 1 define gain sensor 1 uintl6 t heading uintl6 t heading error 0 uintl6 t prev heading error 0 KKK RK Ck kk kk kk kk kk ke ke ek Go Foward Function Sets INA for both H Bridges to 1 and sets INB for both to 0 FEA He void go forward F 41 Spring 2008 ECE 477 Final Report PORTC 1 3 1 5 PORTC amp 1 lt lt 2 amp 1 lt lt 4 return KKK RK RK KKK KK e ke ek k Go Reverse Function Sets INA for both H Bridges to 0 and sets INB for both to 1 KCKCKkCkCk kk ck ck I ko kk ke
84. 0 Spring 2008 LOG WARNINGLOG No activity from network in the last us timeoutCnt 100 break default timeoutCnt 0 if recvSize recv cSock pN buffer LOG ERRORLOG Network recv failed else if recvSize 0 close cSock cSock 1 else NET BUF LEN 0 MSG DONTWAIT s strerror errno LOG INFOLOG Network client has disconnected LOG DEBUGLOG Network received packet Size d bytes s recvSize pN buffer TODO Handle packets pthread mutex lock amp pN state lock pthread mutex unlock amp pN state lock pthread mutex lock amp pN state lock ER pthread mutex unlock amp pN state lock ER if cSock 1 close cSock pthread exit NULL bool CNetwork operator bool ret true pthread mutex lock amp state lock if state NET_OPEN ret false pthread mutex unlock amp state lock return ret i Subvehicle Sensor board trunk adc h ifndef MY ADC define MY ADC include lt avr interrupt h gt include lt avr io h gt void adc init uint8 t read adc endif MY ADC hi Subvehicle Sensor board trunk MControl c include lt avr interrupt h gt include lt avr io h gt F 137 ECE 477 Final Report include MControl h include util delay h include i2c h include timer h define gain prop 1 define gai
85. 0ms void Set LED Off Time int devnum int val F 72 ECE 477 Final Report Spring 2008 void Set Sharpness int devnum int val 0 65535 void Set Backlight Compensation int devnum int val 0 0ff other on void Set Antiflicker Mode int devnum int val 0 0ff other on void Set Noise Reduction int devnum int val 0 none 3 high void Set PanTilt int devnum int pan int tilt void Get PanTilt int devnum int pan int tilt t i Subvehicle refs od otherlibs moveit c moveit c example file on how to move the camera include philipscamera h int main int dev int val val2 dev Open All Devices Get All Device Info Set Pan Or Tilt Or Zoom dev 1 O0 sleep 2 Set Pan Or Tilt Or Zoom dev 0 0 A Set PanTilt dev 0 0 printf how much to move pan scanf Sd sval printf how much do move tilt scanf d amp val2 Set PanTilt dev val val2 Set Pan Or Tilt Or Zoom dev 0 val sleep 2 Set Pan Or Tilt Or Zoom dev 1 val Close All Devices return 0 Hittite Subvehicle refs od otherlibs philipscameraARM c philipscamera c This file is part of PhilipsWebCamLib PhilipsWebCamLib is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Fo
86. 144 ECE 477 Final Report Spring 2008 int get data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data read send NACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK return ERROR put str DATA REC ERRORMn Nr return OK KKK KKK KKK int get data XCkckckckckck ck ck ko k ke ke x int get nack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data read send NACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK return ERROR put str DATA REC ERROR An Nr return OK KKK KKK KKK int get data XCkckckckckck HH x int get ack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA ACK return ERROR put str DATA REC ERROR An Nr return OK Subvehicle Sensor
87. 2 jwildey Created test code to start driving the Motors Set up PWM on the OCO pin on the ATmega32 running at 3 9ish kHz PC6 and PC7 to be GP outs to control H bridges Only code to drive one H bridge 2008 02 13 11 rtoepfer removed No clue how this got checked in here FA ECE 477 Final Report Spring 2008 2008 02 13 10 rtoepfer moved GP2Y0A700K to trunk too 2008 02 13 9 rtoepfer moved srf02 into trunk where it belongs 2008 02 13 8 rtoepfer added Initial commit of SRF02 test code 2008 02 13 7 rtoepfer Trent is going to kill me 2008 02 13 6 rtoepfer I dicked up the repo 2008 02 13 5 rtoepfer added Initial commit of SRF02 Sonar test code 2008 02 11 4 rtoepfer added Long range sensor IR GP2Y0A700K wrote initial driver to initialize adc and read adc a test program main c was written to test the adc with the IR sensor 2008 02 08 3 rtoepfer removed initially put into wrong directory New location Sensors 2008 02 08 2 rtoepfer added initial import of sample i2c code for srf02 2008 02 02 1 nelson11 Initial repository creation F 5 ECE 477 Final Report Actual Code ERAN Subvehicle Sensors trunk GP2Y0A700K adc h ifndef MY ADC define MY ADC include lt avr interrupt h gt include lt avr io h gt extern uint8 t uval lval void adc_init endif MY ADC Td inc inc inc inc Subvehicle Sensors trunk GP2Y0A700K main c lude lude include include include inclu
88. 2008 send stop if data 0 i2c read 0x3A 0x29 lt lt 8 ERROR put_str failed n c send stop if data 1 i2c read 0x3A 0x2A ERROR put str failedin r send stop if data 1 i2c read 0x3A 0x2B lt lt 8 ERROR put_str failed n c send stop if data 2 i2c read 0x3A 0x2C ERROR put_str failed n c send_stop if data 2 i2c read 0x3A 0x2D lt lt 8 ERROR put_str failed n c send stop snprintf s 32 X 6d Y 6d Z 6d Nr data 0 data 1 data 2 put str s if 1 avgx i data 0 avgy i data 1 avgz i data 2 i i 1 10 totalx totaly totalz 0 if size lt 10 sizet for j 0 j lt size j totalx avgx j totaly avgy j totalz avgz jl fendif snprintf s 32 X 4d Y 4d Z 4d Nr totalx size totaly size totalz size put str s endif return 0 end main endif tt t Subvehicle Sensors trunk LIS3L uart c include lt avr interrupt h gt F 15 ECE 477 Final Report include avr io h define BAUD 12 include uart h define NULL void 0 UART variables static volatile uint8 t tx_read static volatile uint8 t tx_write static volatile uint8 t tx buff TX BUFF SIZE void uart init fa B sbi UCSRB RXEN sbi UCSRB TXEN tx read tx write 0 Set baud rate registers E
89. 22P to a rgb image Ef int v4l yuv422p2rgb unsigned char rgb out unsigned char yuv in int width int height int bits width height bits gt gt 3 const int numpix const unsigned int bytes int h we y00 y0l u v unsigned char pY yuv in unsigned char pU pY numpix unsigned char pV pU numpix 2 unsigned char pOut rgb out if rgb out yuv in return 1 for h 0 h lt height h 1 for w 0 w lt width 2 w 2 y00 pY yOl pY 1 uc purty 1285 v pV 128 v4l copy 422 block y00 y01 u v pY 2 pout bytes lt lt 1 F 124 Spring 2008 yll u v width pout width pout bits ECE 477 Final Report pY width pOut width bytes return 0 ih Subvehicle OMAR trunk Logger cpp include lt time h gt include lt stdarg h gt include Logger h static char szLOGLEVEL 8 NONE DEBUG INFO o Q Logger g_Logger CLogger Logger int fp NULL tee Tee ifdef DEBUG logLevel DEBUGLOG else logLevel fendif a level const char logfile level if logfile NULL amp amp level l NONELOG fp fopen logfile w if fp NULL fp stderr log WARNINGLOG else log DEBUGLOG SzLOGLEVEL logLevel else fp stderr log DEBUGLOG SZzLOGLEVEL logLevel l
90. 3 enabled start auto trigger interrupt flag interupt enabled prescalars SFIOR 0x00 free running mode set auto trigger to interupt flag ADCSRA 1 lt lt ADEN ADCSRA 1 lt lt ADSC return uint8 t read adc void return ADCH endif ADC H F 151 Spring 2008 ECE 477 Final Report Subvehicle Sensor board trunk uart h ifndef MY UART define MY UART include lt avr interrupt h gt include lt avr io h gt define TX BUFF SIZI define RX BUFF SIZI 256 256 ifndef BAUD If different baud rate is desired do fdefine BAUD BEFORE include uart h in your source define BAUD 51 38400 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTE sfr BV bit endif ifndef cbi define cbi sfr bit SFR BYTE sfr amp BV bit endif Initialize UART MUST BE CALLED void uart init Write 8 bit value to UART void put char uint8 t c Write 16 bit value to UART void put short uintl6 t s Write string to UART void put str char str get 8 bit value from UART uint8 t get char get string from UART uint8 t get str char uint8 t endif MY UART rt Subvehicle Sensor board trunk timer h ifndef timer h define timer h define CLOCK unsigned CLOCK SPF O extern uintl6
91. 8 v pV 128 Spring 2008 u v width pOut v4l copy 422 block y00 y01 u v width pOut bits pY 2 pout bytes lt lt 1 pY width pOut width bytes F 93 ECE 477 Final Report Spring 2008 return 0 ti Subvehicle refs od od NetLAN h od NetLAN h Object Detection ifndef OD NETLAN H define OD NETLAN H include lt netinet in h gt include lt sys socket h gt include lt pthread h gt include od common h include od Network h define OD NET LAN PORT 4385 define OD NET BUFFER SIZE 4096 typedef struct od LANServer pthread t sthandle pthread t clients OD N int clients socks OD N int clients state OD N int num clients int listen socket od LANServer 3 T MAX CLIENTS T MAX CLIENTS T MAX CLIENTS 3 E p D 3 int odCreateLANServer int odDestroyLANServer void odLANServer thread void args void odLANClient thread void args int odLANSend char buffer int size int client id void sigiohandler int arg endif OD NETLAN H A eof ht Subvehicle refs od od dbase c od dbase c i lt ObjectDetection database section source SI include lt stdlib h gt include lt assert h gt F 94 ECE 477 Final Report Spring 2008 include malloc chk h include od dbase h DO NOT W
92. 8 t tmp tail rx buffer empty if rx head rx tail return char NULL tmp tail rx tail rx tail rx tail 1 RX BUFF SIZE return rx buff tmp tail uint8 t get str char buff uint8 t size uint32 t i 0 while buff i get char char NULL amp amp i lt size itt return i UART tx interrupt SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write cbi UCSRB UDRIE return UDR tx buff tx read tx read tx read 1 gt TX BUFF SIZ Fl Wi o tx read 1 void put char uint8 t c uint8 t tmp write tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full F 150 ECE 477 Final Report if tmp write tx read sbi UCSRB UDRIE return tx buff tx write c tx write tmp write Enable Tx interrupt to start sending Sbi UCSRB UDRIE return void put short uintl16 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put str char str uint32 t i 0 while str i char NULL put char str i itt Subvehicle Sensor board trunk adc c ifndef ADC H define ADC H include lt avr interrupt h gt include lt avr io h gt include adc h void adc_init void ADCSRA 0x00 PORTA 0x00 DDRA 0x00 port a is input ADMUX OxEO port0 enabled ADCSRA 0x8
93. A clear TWINT to start transmission of addresss send ACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA ACK return ERROR put str DATA REC ERROR An Nr return OK ECE 477 Final Report Spring 2008 ii Subvehicle Sensors trunk LIS3L main c include avr interrupt h include avr io h define F CPU 800000UL include i2c h include uart h int main uart init while 1 put str Mary had a little lamb r n return 0 if 0 int16 t j i 0 size 0 uint8 t data 0x00 int16 t data 3 0 0 0 int32 t avgx 11 0 avgy 11 0 avgz 11 0 intl6 t totalx totaly totalz 0 char s 32 init uart and i2c uart init i2c init sei put str HI my name is RJ from main Mn MnNr i2c transmit 0x3A 0x20 0xB7 while 1 delay ms 2500 dif 0 if i2c read accel 0x3A 0x88 data ERROR put str failedin r send stop else snprintf s 32 X 4d Y 4d Z 4dNr data 0 data 1 data 2 put str s snprintf s 25 Y dNnNr data 1 put str s snprintf s 25 Z Sd n r data 2 put str s else if data 0 i2c read 0x3A 0x28 ERROR put str failedin r F 14 ECE 477 Final Report Spring
94. ALETTE YUV411P printf YUV 4 1 PlanarMn break case VIDEO PALETTE printf YU break case VIDEO PALETTE YUV410P 4 printf YUV 1 0 Planar n K lt lt n N o U 4 2 0 Planar n break default printf Unknown d n vpic palette if ioctl device devnum VIDIOCPWCGCQUAL amp dummy 1 error exit VIDIOCPWCGCQUAL printf Compression preference d n dummy if ioctl device devnum VIDIOCPWCGAGC amp dummy 1 error exit VIDIOCPWCGAGC printf Automatic gain control d n dummy if ioctl device devnum VIDIOCPWCGAWB amp pwcwb 1 error exit VIDIOCPWCGAWB printf Whitebalance mode if pwcwb mode PWC WB AUTO printf auto Nn else if pwcwb mode PWC WB MANUAL printf manual red d blue d n pwcwb manual red pwcwb manual blue else if pwcwb mode PWC WB INDOOR printf indoor n else if pwcwb mode PWC_WB OUTDOOR F 82 ECE 477 Final Report Spring 2008 printf outdoor Wn else if pwcwb mode PWC WB FL printf artificial lightning fl n else printf unknown Nn if ioctl device devnum VIDIOCPWCGLED amp pwcl 1 printf Led ON time d n pwcl led on printf Led OFF time d n pwcl led off else not_supported Blinking of LED if ioctl device devnum VIDIOCPWCGCONTOUR amp
95. Camera camera open Make sure camera isn t open already pthread mutex lock amp state lock if state CAM CLOSED pthread mutex unlock amp state lock LOG ERRORLOG Camera already open return CAM ERROR Open camera cd open device O RDWR if cd 1 pthread mutex unlock sstate lock LOG ERRORLOG Failed to open camera on s device return CAM ERROR Set camera input to defaults if v4l set input cd input norm 1 pthread mutex unlock amp state lock LOG ERRORLOG Failed to setup camera input close cd cd 1 return CAM ERROR Check camera dimesions if v4l check size cd amp width amp height 1 pthread mutex unlock amp state lock LOG ERRORLOG Camera failed size check close cd cd 1 return CAM ERROR F 128 Spring 2008 ECE 477 Final Report State CAM OPEN pthread mutex unlock amp state lock LOG INFOLOG Camera opened on s device return CAM OK int CCamera camera close pthread mutex lock amp state lock if state CAM OPEN pthread mutex unlock amp state lock LOG DEBUGLOG Camera already closed return CAM ERROR close cd cd 1 State CAM CLOSED pthread mutex unlock amp state lock if thread id pthread join thread id NULL LOG DEBUGLOG Camera thread stopped tid 0x 08X thr
96. DR tx buff tx read tx read tx read 1 gt TX BUFF SIZE 0 tx read 1 void put char uint8 t c uint8 t tmp write tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full if tmp write tx read sbi UCSRB UDRIE return tx buff tx write c tx write tmp write Enable Tx interrupt to start sending Sbi UCSRB UDRIE return void put short uintl16 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put str char str uint32 t len uint32 t i for i 0 i lt len i put char str i Subvehicle Sensors trunk GP2Y0A2 adc c ifndef ADC H F 28 Spring 2008 ECE 477 Final Report Spring 2008 define ADC H include avr interrupt h include avr io h include adc h void adc init void PORTA 0x00 DDRA OxFE ADMUX 0xE0 port0 enabled ADCSRA 0x85 uintl6 t read adc void ADCSRA 1 lt lt ADSC while ADCSRA amp ADSC gt gt ADSC return ADCH lt lt 2 endif ADC H Hihi Subvehicle Sensors trunk GP2Y0A2 uart h ifndef MY UART define MY UART include lt avr interrupt h gt include lt avr io h gt define TX BUFF SIZE 256 ifndef BAUD If different baud rate is desired do fdefine BAUD BEFORE include uart h in your source define BAUD 51 9600 baud 8MHz normal speed end
97. ECE 477 Final Report Spring 2008 Team 8 OMAR NESS INSTITUTE THAMPIONS Trent Nelson Mike Cianciarulo Robert Toepfer i Team Members 1 Signature Date 2 Signature Date 3 Signature Date 4 Signature Date CRITERION SCORE Technical content Design documentation Technical writing style Contributions Editing Comments ECE 477 Final Report TABLE OF CONTENTS Abstract 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 Project Overview and Block Diagram Team Success Criteria and Fulfillment Constraint Analysis and Component Selection Patent Liability Analysis Reliability and Safety Analysis Ethical and Environmental Impact Analysis Packaging Design Considerations Schematic Design Considerations PCB Layout Design Considerations Software Design Considerations Version 2 Changes Summary and Conclusions References Appendix A Individual Contributions Appendix B Packaging Appendix C Schematic Appendix D PCB Layout Top and Bottom Copper Appendix E Parts List Spreadsheet Appendix F Software Listing Appendix G FMECA Worksheet Mc Spring 2008 A U N e 18 21 25 27 29 32 33 34 A 1 B 1 C 1 D 1 E 1 F 1 G 1 ECE 477 Final Report Spring 2008 Abstract OMAR is part of a solution to the Purdue IEEE Aerial Robotics project which is an ongoing project and competes in the
98. ET MAX CLIENTS while go accept socket accept server listen socket NULL NULL if accept socket 1 if errno EAGAIN printf Error accept rrno d n errno else sleep 2 continue if server num clients gt OD NET MAX CLIENTS printf Error too many clients n close accept socket continue else Zort i 0 i lt OD NET MAX CLIENTS i if server gt clients i break if 0 pthread create amp server clients i NULL odLANClient thread void y yof server clients i 0 printf Error creating new client threadin close accept socket continue else pthread mutex lock amp server lock server gt num_clients t server clients socks i accept socket pthread mutex unlock amp server lock while go pthread mutex lock amp server lock for i 0 i lt OD NET MAX CLIENTS i if server gt clients i 0 server gt clients state i 0 send quit message close server clients socks i server clients socks i 0 pthread mutex unlock amp server lock close server listen socket free server odLANServer thread F 59 ECE 477 Final Report Spring 2008 void odLANClient thread void args int client number int args int err int cpos contpos packet mode OD NET PACKET NEW char bu
99. L odDestroyWindows F 100 ECE 477 Final Report Spring 2008 void odShowWindows IpllImage source IplImage final Fl cvShowlmage OD WIN SOURCE source cvShowImage OD WIN FINAL final odShowWindows endif HAVE OPENCV HIGHGUI H eof ti Subvehicle refs od od Camera h t od Camera h Object Detection Functions to operate the camera E ifndef OD CAMERA H define OD CAMERA H include lt sys time h gt define OD PIC WIDTH 640 define OD PIC HEIGHT 480 Takes a picture and returns the image buffer uncompressed char odCameraTakePicture struct timeval time int shutter speed int gain Takes image from camera and writes it to specified file quality 0 100 int odCameralmageToJPEGFile char image char filename int quality This will write the raw data of the image to the filename specified int odCameralmageToFile char image char filename int odCameraMove int pan int tilt fendif OD CAMERA H KY eof ti Subvehicle refs od od dbase h Hi od dbase h ObjectDetection database section header Data types and functions related to the maintenance of the database An emphasis on speed and size is very Se important since this is designed to work on a low memory system ifndef OD DBASI define OD DBASI Fl Fl include od_common h
100. MAX PATH if device NULL LOG DEBUGLOG Failed to allocate device string return if Device strncpy device Device S ERIAL MAX PATH else strncpy device SERIAL DEVICE S buf NULL buf new u int8 t SERIAL BUF SIZE if buf NULL ERIAL MAX PATH LOG DEBUGLOG Failed to allocate serial buffer return memset buf 0 sizeof buf Try to startup serial port service if serial initialize SERIAL OK return CSerial CSerial F 111 NULL bool Tee Spring 2008 true ECE 477 Final Report serial close if buf dele if device d te buf void CSerial serialThread v int selectRet u int32 t timeoutCnt timeval timeo fd set rfds char buf 101 memset buf 0 Set thread lete device oid arg Val 0 0 ut wfds ZBO owner CSerial spSer LOG DEBUGLOG Read until reinterpret cast CSerial gt arg Serial thread started port is closed pthread mutex lock amp pSer state lock whil pSer s pthread mut Setup ar timeout tv timeout tv usec tate SERIAL OPEN ex unlock amp pSer s tid 0x 08X pSer thread id tate lock gs for select as it invalidated them sec 0 10000 FD ZERO amp rfds FD ZE FD SET pSer FD SET pSer RO am
101. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Foundation Inc 59 Temple Place Suite 330 Boston MA 02111 1307 USA RY This is pwc ioctl h belonging to PWC 8 10 xy Changes 2001 08 03 Alvarado Added ioctl constants to access methods for changing white balance and red blue gains 2002 12 15 G H Fernandez Toribio VIDIOCGREALSIZE LE These are private ioctl commands specific for the Philips webcams They contain functions not found in other webcams and settings not Specified in the Video4Linux API The define names are built up like follows VIDIOC VIDeo IOCtl prefix PWC Philps WebCam F 67 ECE 477 Final Report Spring 2008 optional Get optional Set the function na SJ The frame rate is encoded in the video window flags parameter using the upper 16 bits since some flags are defined nowadays The following defines provide a mask and shift to filter out this value In Snapshot mode the camera freezes its automatic exposure and colour balance controls define PWC FPS SHIFT 16 define PWC FPS MASK OxOOFF0000 define PWC FPS FRMASK 0x003F0000 define PWC FPS SNAPSHOT 0x00400000 struct pwc probe char name 32 int type pwc_whitebalance mode values
102. OMAR will need to autonomously navigate a room avoid obstacles and take still images of its surroundings To perform these tasks IR sensors will be used to do precise room mapping Sonar sensors will provide object collision detection Still image capture will be handled by a camera with VGA resolution to cut down on downstream traffic yet provide a good enough image for processing The chassis will ride on 4 tires directly driven by independent motors and control will be similar to that of a tank providing 360 degree rotation Aside from strictly competing in the IARC OMAR could also be used for military or law enforcement applications Autonomous vehicles are becoming ever more popular because it does not have a potential for casualties They are also a very active field of research even within our own government The possibilities are nearly limitless and OMAR is part of the new and exciting field of technology and robotics Shown below are images of the final functional prototype of OMAR along with its block diagram ECE 477 Final Report Spring 2008 Figure 1 1 Final Prototype of OMAR Figure 1 2 Block Diagram of OMAR ECE 477 Final Report Spring 2008 2 0 Team Success Criteria and Fulfillment e Anability to control vehicle direction and speed OMAR is able to control all aspects of vehicle motion The direction and speed is dependent upon what the sensors are reading The speed of OMAR is varied directly propor
103. ORRY ABOUT THIS FUNCTION RIGHT NOW od VertLink odAddVert od DB db int x int y int z return NULL od VertLink DO NOT WORRY ABOUT THIS FUNCTION RIGHT NOW int odRemoveVert od DB db verti 3d vert return OD OK odRemoveVert DO NOT WORRY ABOUT THIS FUNCTION RIGHT NOW od ObjLink odAddObj od DB db od Object parent specs return NULL odAddObj int odRemoveObj od DB db od Object obj od Object subobjects od ObjLink link od ObjLink obj Use assert when checking for non critical truths Remember that in each release build these statements will be ignored when compiled assert db amp amp obj db OLS tail next link link gt next NULL db gt OLS nclinks t if obj gt prev NULL obj gt parentObject gt subObject obj gt next if obj gt next obj gt next gt prev NULL subobjects obj gt subObject obj gt subObject NULL obj gt parentObject NULL obj gt next NULL obj gt probability 0 return OD OK not finished return OD OK odRemoveObj int odCreateVLinkServer od DB db int i od VertLink Temp assert db db gt VLS head malloc sizeof od VertLink F 95 ECE 477 Final Report assert db gt VLS head NULL db gt VLS tail db gt VLS head db gt VLS head gt next NULL db gt VLS nclinks
104. T wait for TWINT flag set data sent NACK sent check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK i2c error ERROR put str DATA REC _ERROR n r return OK ti Subvehicle Sensors trunk srf02 main c include lt avr interrupt h gt include lt avr io h gt define F CPU 800000UL include i2c h include uart h int main uint8 t i 0 int status 0 uint8 t data char s 100 uint8 t range 0 uint8 t rangel 0 uint8 t range2 0 init uart and i2c uart init i2c initi sei 0x00 put str HI my name is RJ from main Nn MnNr while 1 delay ms 1000 delay ms 1000 delay ms 1000 Jes i if range srf read 0xE0 ERROR send stop else F 22 ECE 477 Final Report snprintf s 25 rd S4dcm put str s SCH range i2c transmit 0xE4 0x51 if i2c error ERROR put_str ERROR n r send_stop continue y range srf read 0xE0 delay ms 32 delay ms 32 delay ms 32 rangel srf read 0xE2 delay ms 32 delay ms 32 delay ms 32 del 32 srf read 0xE6 range2 delay ms 32 delay ms 32 delay ms 32 range i2c read 0xE4 2 snprintf s 25 rd S4ucm put str s if i2C error range ERROR put_str ERROR n r send_stop continue el
105. THOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Foundation Inc 675 Mass Ave Cambridge MA 02139 USA X 0X F F Xo F X X F F X X F F KF ox include lt stdio h gt include lt stdlib h gt include lt sys types h gt include lt sys ioctl h gt include lt sys mman h gt include fcntl h include lt unistd h gt include lt linux types h gt include lt linux videodev h gt include v41 h define min a b a b a b define max a b a b a b set the input and norm for the video4linux device k int v41 set input int fd int input int norm struct video channel vid chnl if input INPUT DEFAULT norm l NORM DEFAULT if vid chnl channel INPUT DEFAULT vid chnl channel input else vid chnl channel 0 vid chnl norm 1 F 119 Spring 2008 Spring 2008 1 ECE 477 Final Report if ioctl fd VIDIOCGCHAN amp vid chnl 1 perror ioctl VIDIOCGCHAN return 1 else if input 0 vid chnl channel input if norm NORM DEFAULT vid chnl norm norm if ioctl fd VIDIOCSCHAN amp vid chnl perror ioctl VIDIOCSCHAN return 1 re
106. ULL LOG DEBUGLOG Serial thread stopped tid 0x 08X thread id thread id 0 LOG INFOLOG Serial closed on s device else pthread mutex unlock amp state lock Port was already closed OG DEBUGLOG Serial already closed return SERIAL OK bool CSerial operator bool ret true pthread mutex lock amp state lock if state SERIAL OPEN ret false pthread mutex unlock amp state lock return ret FRAN Subvehicle OMAR trunk imageRec h ifndef IMAGE R define IMAGE REC H class CImageRec l endif IMAGE REC H ih Subvehicle OMAR trunk v4l pwc ioctl h ifndef PWC IOCTL H define PWC IOCTL H C 2001 2003 Nemosoft Unv webcam smcc demon nl This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version F 114 Spring 2008 ECE 477 Final Report Spring 2008 This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if
107. UV420P fclose ou t return OD OK odCameralmageToJPEGFile static int c int odCamera size ImageToFile char image char filename FILE out out fopen filename wb if out return OD ERROR fwrite image 1 csize out F 64 EIGHT int quality quality Spring 2008 ECE 477 Final Report fclose out return OD OK Spring 2008 odCameralmageToFile char odCameraTakePicture struct timeval time int shutter speed int gain int width OD PIC WIDTH height OD PIC HEIGHT size dev 1 char image device VIDEO DEV file test ppm filejpeg test jpg char fimage int input INPUT DEFAULT this means take over current device settings int norm NORM DEFAULT FILE out stdout if file out fopen filejpeg wb if out printf error opening file n perror file return 1 ZS open the video4linux device dev open device O RDWR if dev 1 fprintf stderr Error Can t open device n return OD ERROR if v4l_set_input dev input norm 1 return OD ERROR if v4l check size dev amp width amp height 1 return OD ERROR printf enter shutter speed scanf d amp speed speed 65535 if ioctl dev VIDIOCPWCSSHUTTER amp shut
108. V Battery fails Doesn t run Power LED off Medium LDO fails Output 5V LDO fails Potential damage to Smoke High components Excess heat A3 Input short LDO fails Component Damage Battery explodes Contact of conductive User injury surface with PCB Fire A4 Discrete short Unstable voltage LED off fluctuating Low Medium component failure regulator failure outputs Sporadic behavior ECE 477 Final Report Spring 2008 E G 2 FMECA Drive a ii Failure Made e Mode Possible Possible Causes Failure Failure Effects Method Method of Detection Detection Criticality Windings fail Insulation fails Motor s stop Vehicle stops Medium Windings break Possible smoke Brushes fail Wear Motor s stop Vehicle stops Medium High input current Possible smoke Table G 3 FMECA Software Subsystem EE Failure Mode Possible Causes Failure Effects Method of Detection Criticality No communication Failed interconnect Failure to map room Vehicle stops after Medium with Gumstix VCC out of range Failure to determine detecting obstacle Dead port pins new heading after obstacle detected No communication Failed interconnect Failure to map room Vehicle crashes with sensors VCC out of range Failure to detect Fire Dead port pins obstacles C3 Failed pushbutton object holding Microcontroller to be OMAR would stop Medium pushbutton down placed in reset mode running ECE 477 Final Report Spring 2008
109. VIDIOCGCAP amp vid caps 1 perror ioctl VIDIOCGCAP return 1 if vid_caps audios gt 0 mute the sound if ioctl fd VIDIOCGAUDIO amp vid_aud 1 return 1 else vid aud flags VIDEO AUDIO MUTE if ioctl fd VIDIOCSAUDIO amp vid aud 1 return 1 return 0 Turn a YUV4 2 0 block into an RGB block sk Video4Linux seems to use the blue green red channel order convention rgb 0 is blue rgb 1 is green rgb 2 is red Se Color space conversion coefficients taken from the excellent F http www inforamp net poynton ColorFAQ html 90 ECE 477 Final Report Spring 2008 In his terminology this is a CCIR 601 1 YCbCr RGB Y values are given for all 4 pixels but the U Pb and V Pr are assumed constant over the 2x2 block To avoid floating point arithmetic the color conversion coefficients are scaled into 16 16 fixed point integers They were determined as follows double brightness 1 0 0 black 1 gt full scale double saturation 1 0 O gt greyscale 1 gt full color double fixScale brightness 256 256 x int rvScale int 1 402 saturation fixScale int guScale int 0 344136 saturation fixScale int gvScale int 0 714136 saturation fixScale int buScale int 1 772 saturation fixScale int yScale int fixScale x LIMIT convert a 16 16
110. Y WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Cambridge MA 02139 USA endif CCamera CCamera COMAR Parent const char Device parent Parent cd 1 thread id 0 pthread mutex init amp state lock NULL State CAM CLOSED input INPUT DEFAULT norm NORM DEFAULT shutter speed CAM SHUT SPD gain CAM GAIN width CAM WIDTH height CAM HEIGHT depth CAM DEPTH device NULL device new char CAM MAX PATH if device NULL LOG DEBUGLOG Failed to allocate device string return if Device strncpy device Device CAM MAX PATH else strncpy device CAM DEVICE if camera initialize CA return CAM MAX PATH OK F 127 ECE 477 Final Report CCamera CCamera camera close if device d lete device int CCamera camera initialize int ret ret camera open if ret CAM OK return ret ret pthread create amp thread id NULL cameraThread void this if ret 0 OG DEBUGLOG Failed to create camera helper thread camera close return CAM ERROR return CAM OK int C
111. address and the data to write or the address followed by an extra acknowledgement to read the 2 bytes of data For the accelerometer you had to send it the address and each successive register to read The accelerometer returns 6 bytes of data 2 bytes per axis so you had to send it 6 register locations in a row After realizing that the accelerometer and magnetometer operated at 3 3 V Robert ordered the level shifters and had Mike add it to the PCB One of the main problems Robert had with the I2C devices was that they were all timing sensitive Robert originally did not have the F CPU setting to the correct frequency so all of his delays were off This caused all the devices to operate sporadically Robert also wrote the code for the IR sensors ADC but the IR sensors were eventually not used When the first PCB arrived Robert helped soldered most of the discrete components on the board After the PCB was ready Robert started the initial testing of the sonar sensors Robert tested different arrangements of sensors and the number of sensors as well as varying different settings in the code such as motor throttling and object distance thresholds Robert worked with the PID code and the magnetometer in order to help OMAR drive straighter but that ended up not being used because the team managed to break two magnetometers The next thing Robert did was change the I2C code so that each device was pulled so that OMAR did not have to wait for the ti
112. ages of each products packaging design and also the features of each that OMAR will use 7 1 2 MobileRobotics Pioneer 3 AT The Pioneer 3 AT 19 is an example of a UGV that is used primarily in classrooms and for research The Pioneer 3 AT 19 is capable of autonomous navigation 2 D room mapping using a laser range finder 3 D room mapping using stereoscopic vision using 2 cameras and object avoidance using multiple sonar sensors The included software allows for the Pioneer 3 AT 19 to perform room mapping straight out of the box It is quite large fairly heavy Fig 2 1 Mobile Robotics Pioneer 3 AT and does not appear to be extremely robust It stands at 50cm long x 49cm wide x 26cm tall and weights 12 kg The design seems to be fully contained with no unnecessarily exposed components The first thing to notice when looking at the Pioneer 3 AT 19 is the huge laser range finder with 2 cameras mounted on top This laser range finder is placed in the middle of the base and is stationary since the range finder is capable of 180 scanning The range finder is large heavy and consumes a large amount of power so it would not be well suited for OMAR The camera mounted on top is very small but it houses 2 lenses for stereo vision which OMAR will not need OMAR will not include 2 cameras but the placement of the camera will be replicated since mounting the camera on top seems to give the best angle for image taking The next design
113. all tight spaces to navigate ECE 477 Final Report Spring 2008 3 1 7 Cost Constraints This project is being funded by the Purdue IEEE Aerial Robotics Committee Money is not a huge constraint as their budget is relatively flexible Regardless the club has other financial obligations so the cost should be kept to a minimum Since compute power is a must a strong CPU is necessary The total cost of the chosen computer and essential accessories is near 300 which put a pinch on the rest of the components As such costs were cut by building a custom motor controller and using a lesser expensive wireless solution The goal of this project as stated earlier is to complete stage three of the IARC This being the case taking OMAR to the consumer market is not a goal It would be more at home in a military or law enforcement type market where reconnaissance without risk of human life is vital 3 2 1 Component Selection Rationale The most important part of OMAR s success is its main CPU It must be capable of running intense image detection and mapping algorithms as well as communicate wirelessly with a base station computer Obviously high clock rate and memory capacity were a major requirement But at the same time the device will be battery powered so low voltage requirements and an ability to control the clock rate are favorable traits A USB host controller will be necessary for connecting a camera Another consideration was size With
114. apable of supplying up to 30 A of current The H bridges themselves have an operating voltage of 5 V and take three logical inputs that will be provided by general purpose I O pins These logical inputs will regulate the direction of current that will be driving the motors and thus the direction that the motors spin All of the inputs will be optically isolated to ensure the protection of the ATmega32 11 The H Bridges also have a current sensor that is being considered for use however this would have to be read in by an ADC channel and would not be able to be optically isolated The current that the motors draw will come directly from the battery and will not go through any of the power circuitry and just merely directed by the H Bridges As for all of the sensors they will all be interfaced with the ATmega32 The ATmega will be running at its native 8 MHz using an internal oscillator The only two sensors that have an operating voltage of 3 3 V are the accelerometer 7 and the magnetometer 6 Because of this operating voltage a level shifter is required The MAX3370 24 was chosen to handle the level translation because of its functionality This device allows for bidirectional level translation which will allow DC communication between the ATmega32 and these two sensors The IR 2 3 and Sonar 5 sensors H Bridge microcontroller and the Gumstix computer all operate off of the 5 V rail from the power supply 8 1 Hardware Design Narrative
115. ard and obvious restraints that must be addressed in the design process Seeing as how OMAR will eventually be jettisoned off of a UAV there has to be size and weight limitations which are acquired from the UAV s physical size and lift capacity Image recognition and room mapping both require a lot of computational power as well as a fair amount of storage For the autonomous operation of the rover it will have to have an array of different sensors that will allow the rover to autonomously navigate the room while avoiding obstacles as well as using these same sensors to map out the room With all of these sensors there will have to be a fair amount of I O on the microcontroller that will interface all of the sensors with the embedded computer Along with the I O required for the sensors it will also require I O for the motor controllers as well as a link to communicate with the embedded computer There will also need to be a camera that will be responsible for capturing visual proof of the specified target and then some form of wireless communication to transmit the visual data of the target and the mapped out room 3 1 1 Computation Requirements The scope of the competition is perform real time reconnaissance and therefore has a time limit With the objective of the rover being to identify a logo while avoiding obstacles will require a relatively high amount of computing power It was determined that the image processing would be the most computati
116. as if repairs need made a technician will likely be touching parts directly containing lead Disposal of OMAR would contribute to soil and ground water pollution Another problem is the chassis The polycarbonate used to make it though easy to manipulate for prototyping and strong for debugging is not biodegradable This is obviously not good for landfills Lastly the lithium polymer battery used is actually land fill safe as far as pollution goes However if improperly disposed of the battery could explode or catch fire leading to rather undesirable situations 19 ECE 477 Final Report Spring 2008 between the dump point and or at the landfill The remainder of this section will discuss solutions to these problems The lead issue can be resolved by pushing for RoHS compliance on all of the electrical parts This will eliminate hazardous chemicals from all stages of the life cycle Forgoing RoHS many steps would have to be taken to protect workers users and the general public from health risks These steps would likely cost far more than simply complying with RoHS in the first place Most all component manufacturers at least offer their devices in an RoHS compliant version These are often a bit more expensive but at some point in the future this will likely be a forced standard anyway The Atmel ATmega32 Gumstix computer accelerometer module and magnetometer module are all RoHS compliant already The discrete components all have RoHS co
117. at odVectorAngle2D CvPoint lineA CvPoint lineB ESS fendif _ OD IMAGEPROC H up F 56 ECE 477 Final Report eof ti Subvehicle refs od od Network h od Network h ObjectDetection Een ifndef OD NETWORK H define OD NETWORK H include od common h define OD NET MAX CLIENTS 4 define OD NET PACKET NEW 1 define OD NET PACKET CONT 2 typedef struct od Packet int size The complete siz int command Any command given char buffer Data sent od Packet endif OD NETWORK H eof of the packet ti Subvehicle refs od od NetLAN c 4HHBHE od NetLAN c ObjectDetection x include lt stdio h gt include lt string h gt include lt assert h gt include lt errno h gt include lt sys poll h gt include lt sys signal h gt include fcntl h include unistd h include od NetLAN h static pthread mutex t server lock static od LANServer server NULL static int go 0 int odCreateLANServer PTHR EAD MUT EX INITIALIZER F 57 Spring 2008 ECE 477 Final Report Spring 2008 int port OD NET LAN PORT int listen socket err struct sockaddr in server sockaddr list n socket socket AF INET SOCK STREAM IPPROTO TCP if listen socket 1 printf error in socket n retur
118. ay to improve the reliability of the design would be to simply choose parts with longer MTTF One software design refinement that would increase the reliability of the design would be to have an initial test ranging devices The test would simply drive until either the sonar or the IR sensors detect an object and if the 2 sensors are not about the same then 1 of the devices is not working properly One hardware design change that could be made would be to use a switching power circuit instead of the 5V LDO 5 2 Failure Mode Effects and Criticality Analysis FMECA The criticality levels for OMAR are defined as follows High criticality is any failure that may cause harm or injury to the user A lt 10 Medium is any failure that may cause irreplaceable damage and halt the completion of the objective A lt 10 Low criticality is defined as any failure that causes damage that can be replaced and does not critically limit the completion of the objective A lt 105 The schematic for OMAR has been divided into 4 different subsystems power software sensors and drive The first subsystem is the power block and it consists of the battery and voltage regulators as shown in figure A 1 The first possible failure is the battery being shorted This could be cause by any contact with a current carrying surface The possible effects of this are the battery exploding This is a high criticality since it may injury the end user The next 2 possible
119. baud rate is desired do define BAUD BEFORE include uart h in your source define BAUD 51 38400 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTE sfr BV bit endif ifndef cbi define cbi sfr bit SFR BYTE sfr amp BV bit endif Initialize UART MUST BE CALLED void uart init Write 8 bit value to UART void put char uint8 t c Write 16 bit value to UART void put short uintl6 t s Write string to UART void put str char str get 8 bit value from UART uint8 t get char get string from UART F 39 ECE 477 Final Report uint8 t get str char uint8 t endif MY UART dibi Subvehicle Sensors trunk servo timer h ifndef timer h define timer h O define CLOCK unsigned CLOCK SPE extern uintl6 t timer cnt void move servo uintl6 t void timer start void timer stop void timer reset void timer init void endif timer h Subvehicle Sensors trunk servo timer c include lt avr interrupt h gt include timer h uintl6 t timer cnt void timer init void DDRD 1 lt lt 5 enable PD5 as output for PWM signal TCCR1A OxA2 TCCRIB OxlA ICR1 50000 OCR1AH 0x00 OCRIAL 0x00 OCR1BH 0x00 OCRIBL 0x00 TIMSK 0x04 enable timer overflow interrupt timer cnt 0 void move servo uintl6 t
120. char buffer int size int client id assert client id gt 0 amp amp client id lt OD NET MAX CLIENTS assert server clients socks client id 0 send server gt clients socks client id buffer size 0 return OD OK odLANSend int main i odCreateLANServer sleep 1 odDestroyLANServer return 0 eof i Subvehicle refs od od Camera c od Camera c Many of the functions are from vidcat c from the w3cam project Copyright C 1998 2001 Rasca Berlin 3 i his program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version 3 e his program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Foundation Inc 675 Mass Ave Cambridge MA 02139 USA X 0 X Xo F F Xo F X X F Ro X X X F F ox include stdio h include lt stdlib h gt include string h include lt sys types h gt include sys ioctl h include sys mman h include fc
121. char err 255 attempt if devicebuffers devnum size 0 failure Error Device Buffer Size lt 0 n vm frame buffer vm format devicepictures devnum palette vm width devicewindows devnum width vm height devicewindows devnum heigh if ioctl device devnum VIDIOCMCAPTURE amp vm lt 0 Sprintf err MCapture Error d n errno failure err success int Set Size int devnum int width int height of struct video window vwin attempt if device devnum lt 0 width gt devicecapabilities devnum maxwidth height gt devicecapabilities devnum maxheight width lt devicecapabilities devnum minwidth height lt devicecapabilities devnum minheight failure Parameter or device out range n if ioctl device devnum VIDIOCGWIN amp vwin lt 0 failure IOCTL error n vwin width width vwin height height vwin clipcount 0 if ioctl device devnum VIDIOCSWIN amp vwin lt 0 failure IOCTL error n Get Window devnum success int Get Frame Rate int devnum F 78 ECE 477 Final Report struct video window vwin Spring 2008 attempt if device devnum lt 0 failure Invalid device n if ioctl device devnum VIDIOCGWIN amp vwin success return vwin flags amp PWC FPS FRMASK int Set Frame Rat int devnum int fps struct video window vwin
122. d Inactivity nag message to every 5s from 1s F 2 ECE 477 Final Report Spring 2008 2008 04 07 87 nelson11 fixed Forgot to uncomment the framerate limiting code 2008 04 07 86 nelson11 fixed Network actually works now I d rather not say why it was broken 2008 04 07 85 nelson11 added Signal handling for SIGINT ctrl c 2008 04 05 84 nelson11 fixed Used int instead of uint8 t 2008 04 05 83 nelson11 fixed missed a define 2008 04 05 82 nelson11 updated More new makefiles 2008 04 05 81 nelsonl1 fixed Compile error more extern misuse 2008 04 05 80 nelson11 fixed Compile error misused extern 2008 04 05 79 nelson11 added Cool new makefile for this project too 2008 04 05 78 jwildey Added i2c readings to main c to figure out that the magnetometer is dead modified the pid loop a little bit to accept 2 vars and to return 16 bit value 2008 04 05 77 nelson11 fixed Was trying to writete elf to the uC not the srec 2008 04 05 76 nelson11 added New more useful makefiles 2008 04 05 75 nelson11 updated ATMega32 related makefiles to use new avrisp2 NOTE This breaks install on the STK500 I ll fix it properly tomorrow 2008 04 05 74 jwildey Have added timer c uart h uart c i2c c i2c h MControl c MControl h Added these to start creating PD loop for motor controller Will use magnetometer to get heading and PD loop will update accordingly eventually Got timer working correctly Timer will be used for timestamp for de
123. d reverted back to revision 108 to demonstrate the best object avoidance Modified the left and right speeds to go straighter 2008 04 22 125 rtoepfer modified added uart h to print status values for debug 2008 04 18 124 nelson11 fixed valgrind was complaining about delete being used instead of delete 2008 04 18 123 nelson11 added More callback stuff from previous commit F 1 ECE 477 Final Report Spring 2008 2008 04 18 122 nelson11 added Dabbled with callbacks a bit Sending die to the network kills omar 2008 04 18 121 nelson11 changed Compile client with gcc instead of g 2008 04 18 120 nelson11 removed Commented code unused variables 2008 04 16 119 nelson11 removed More unneeded debug statements 2008 04 16 118 nelson11 fixed Don t compile client for ARM that s silly 2008 04 16 117 nelson11 removed Unneeded debug statements 2008 04 16 116 nelson11 fixed Some debug stuff was outside the DEBUG ifdef block 2008 04 16 115 nelson11 fixed arm target wasn t being deleted 2008 04 16 114 nelson11 fixed Deadlock if bad things happen on ARM Apparently select catches signals under ARM 2008 04 10 113 rtoepfer changed added code for PID loop and new throttling code attempt at making it use compass to drive straight Code doesnt work properly 2008 04 10 112 rtoepfer updated updated the file to contain the PID loop tweaked the PID loop some still not 100 2008 04 10 111 rtoepfer changed changed get_compass to
124. d addr t addr ERROR send stop return ERROR if send_data data ERROR send stop return ERROR send_stop return OK end i2c transmit addr data uintli6 t hmc read uint8 t addr uintl6 t data 0 if send_start ERROR send_stop return ERROR if send addr r addr send stop return ERROR ERROR if get ack data ERROR send stop return ERROR data TWDR lt lt 8 if get nack data ERROR send_stop return ERROR data TWDR send_stop return data end hmc_read addr reg fx KK send_repeat int send repeat TWCR 0 1 lt lt TWSTA 1 lt lt TWINT wait for repeat start sent while TWCR amp 1 lt lt TWINT check repeat start sen if TWSR amp OxF8 TW R L correct EP START CkCkck ck k ck kckckckckckckokckok sk ke ke ke e e x 1 lt lt TW F 46 Ia D N repeat start code Spring 2008 ECE 477 Final Report Spring 2008 return ERROR put str REP START ERRORWMn Nr return OK end send repeat KRKKKKK send_start CKCKkCkCkCk Ck k kc k kc k kc k AKA AXA AXA KA Z kk ex e int send start send start TWCR 0 1 lt lt TWINT 1 lt lt TWSTA 1 lt lt TWEN send start condition wait for start sent while TWCR amp 1
125. d when setting the internal oscillator to 8Mhz Wiring up the PCB and the placement of devices are also important The ADC requires a lot of different noise canceling techniques in order to eliminate enough noise to reliably read the IR sensors We also learned that open source SLAM algorithms require around 8 CPU s and a large amount of ram which is not very well suited for a mobile embedded environment 33 ECE 477 Final Report Spring 2008 13 0 References 1 Purdue IEEE Purdue IEEE Student Branch Purdue IEEE January 2008 online Available http purdueieee org Accessed February 6 2008 2 Sharp GP2Y0A02YK Online Document unknown publication date cited January 31 2008 http www acroname com robotics parts gp2y0a02 e pdf 3 Sharp GP2YOA700KOF Online Document 2005 August cited January 31 2008 http www acroname com robotics parts R302 GP2Y 0A 700KO0F pdf 4 MaxBotix LV MaxSonar EZ2 High Performance Sonar Range Finder Online Document 2007 January cited January 31 2008 http www maxbotix com uploads LV MaxSonar EZ2 Datasheet pdf 5 Acroname Robotics Devantech SRF02 Sensor Acroname Robotics December 2007 Online Available http www acroname com robotics parts R287 SRF02 html Accessed Jan 31 2008 6 HoneyWell Digital Compass Solution HMC6352 Online Document 2006 January January 31 2008 http www sparkfun com datasheets Componen
126. d with ease The current estimation of our power draw with all of our components connected is just under 9 amps the bulk of which is the motors This estimation is based on absolute maximum values given in the documentation for each product employed Specified in the documentation a circuit is provided but the values of the discrete components will need to be calculated to accommodate for our specific power needs This power circuit design was chosen because of its efficiency and relative ease of implementation It has two sets of circuits that more or less mirror each other to provide the two customizable output levels The efficiency of the device is due to that of its operation The two mirrored circuits operate 180 degrees out of phase which allows the ripple voltage and current from the input be reduced The frequency at which the MOSFETs change state are determined with an external resistor and can be customized between 100 kHz and 600 KHz The power circuit will be driven by a 7 4 V lithium polymer battery and also has compensation circuitry specified to filter out noise created by the switching of the MOSFETs Compensation circuitry essentially works as a transconductance error amplifier or a hardware integrator that provides high DC accuracy in addition to filtering out noise 25 ECE 477 Final Report Spring 2008 The motor control will be using two ST H bridges 8 with a couple power MOSFETS 12 and other discrete components and will be c
127. de lt stdlib h gt clude sys types h clude sys ioctl h clude lt sys mman h gt clude lt fcntl h gt clude lt unistd h gt clude lt linux types h gt clude lt linux videodev h gt clude v4l h fine min a b a lt b a b fine max a b a gt b a b set the input and norm for the video4linux device Set input int fd int input int norm struct video channel vid chnl if input INPUT DEFAULT norm l NORM DEFAULT if vid chnl channel INPUT DEFAULT vid chnl channel input else vid chnl channel 0 vid chnl norm 1 if ioctl fd VIDIOCGCHAN amp vid chnl 1 perror ioctl VIDIOCGCHAN return 1 F 88 ECE 477 Final Report Spring 2008 else if input 0 vid chnl channel input if norm NORM DEFAULT vid chnl norm norm if ioctl fd VIDIOCSCHAN amp vid chnl 1 perror ioctl VIDIOCSCHAN return 1 return 0 check the size and readjust if necessary x int v4l check size int fd int width int height struct video capability vid caps if ioctl fd VIDIOCGCAP amp vid caps 1 perror ioctl VIDIOCGCAP return 1 readjust if necessary if width gt vid_caps maxwidth width lt vid_caps minwidth width min width vid caps maxwidth width max width vid caps minwidth fprintf stderr readjusting width to d
128. de lude lt avr io h gt lt avr interrupt h gt lt stdlib h gt lt stdio h gt lt string h gt uart h adc h int main uintli6 t i a 10 size 0 p 0 sum char c 10 memset void c 0 10 memset void a 0 10 sizeof uintl6 t V WDTCR 1 lt lt WDTOE 1 lt lt WDE WDTCR amp 0 lt lt WDE Initialize UART peripherial MUST BE CALLED cli uart init adc init sei while 1 Delay so we don t send stuff too fast fif 1 for i 1 i 0 i asm nop asm nop asm nop asm nop asm nop asm nop asm nop asm nop asm nop asm nop asm nop F 6 Spring 2008 ECE 477 Final Report fendif ADCSRA 1 lt lt ADSC put_str Upperval 11 a p read adc p p 1 10 if size lt 10 sizet sum 0 for i 0 i lt size i sum a i snprintf c 10 d n r int sum size itoa int uval c 10 put str c 10 THEE Subvehicle Sensors trunk GP2Y0A700K test c include lt stdlib h gt include lt stdio h gt int main int i 45 char s 10 itoa i s 10 printf Ss n s return 0 THEE Subvehicle Sensors trunk GP2Y0A700K uart c include lt avr interrupt h gt include lt avr io h gt define BAUD 12 include uart h UART variables static volatile uint8 t tx_read
129. ds to be initialized along with the frequency to the asserted output compare state The duty cycle of the asserted stated can then be controlled using the output compare register which will change continuously to help OMAR driving straight with the assistance of the magnetometer The motor controller also requires four GPIO pins two for each channel to indicate which direction to drive the motors These GPIO pins are located on port C which is also utilized by the JTAG programming interface The JT AG interface needs to be disabled because it uses four needed pins This is done by programming the fuse bits of the microcontroller The magnetometer accelerometer and sonar sensors are communicating on the i2c bus The i2c line will be initialized to run at 100 kHz standard speed This speed was chosen because each device recommended running in standard mode 100 kHz The IR sensors output an analog signal so they will be monitored on the ADC The ADC is set to not run in interrupt mode The communication between the Gumstix and the ATmega32 will be over the UART The UART will run at 38400 BUAD This is because at 8 MHz the maximum speed with the smallest percentage of data is 38400 BUAD Because the sensors on the i2c bus do not have interrupt pins the ATmega32 will operate in a polling loop Each loop will collect all sensor data and send it to the Gumstix 10 2 Software Design Narrative 10 2 1 Gumstix The Gumstix software will consist of a ma
130. e I imported the schematic It took a while to look up all the footprints for all the parts for the board I also had to make footprints for the level translators barrel jack and the pushbutton During this time some parts of the schematic were changing like more pins for some headers or more discrete components Then I would have to update the PCB at the same time I also read into PCB design to see how to trace power lines where to put the ground pour and how to design the board to reduce EMI After receiving the initial PCB a week or so I started designing a new one Some mistakes were made on the first board For example the footprint for the pushbutton was wrong Also the LED and a capacitor were put on the bottom of the board and we wanted them on the top Also more headers were added so every pin of the microcontroller was available for use I also helped out in a few other parts of the project I helped look into SLAM for the mapping part of the project Some papers were available that explained all about it I also looked ECE 477 Final Report Spring 2008 into different sets of code available The next job was to design a separate power board because the 5 0V regulator wasn t going to be able to supply enough current to the whole board We needed a separate one for the embedded computer Instead of doing a new PCB we decided to just have a small separate board I did the initial work for that board by drawing up the circuit and
131. e width JSAMPROW row ptr 1 struct jpeg compress struct cjpeg struct jpeg error mgr jerr char line line malloc width 3 if line return cjpeg err jpeg std error amp jerr F 63 ECE 477 Final Report jpeg creat compress amp cjpeg cjpeg image width width cjpeg imag height height cjpeg input components 3 cjpeg in color space JCS RGB jpeg set defaults amp cjpeg jpeg set quality amp cjpeg quality TRU cjpeg dct method Fl lt JDCT FASTEST jpeg stdio dest amp cjpeg out jpeg start compress amp cjpeg TRUE row ptr 0 line if palette VIDEO PALETTE GREY line width width for y 0 y lt height ytt row ptr 0 image jpeg write scanlines amp cjpeg row ptr 1 image line width else line width width 3 for y 0 y lt height y for x 0 x lt line width x 3 line x image x 2 line x 1 image x 1 line x 2 image x jpeg write scanlines amp cjpeg row ptr 1 image line width jpeg finish compress amp cjpeg jpeg destroy compress amp cjpeg free line int odCameralmageToJPEGFile char image char filename FILE out out fopen filename wb if out return OD ERROR put image jpeg out image OD PIC WIDTH OD PIC H VIDEO PALETT E Y
132. ead id thread id 0 LOG INFOLOG Camera closed on s device return CAM OK void CCamera cameraThread void arg ifdef DEBUG int i 0 char fn 16 FILE fp NULL endif ifdef DEBUG truct timeval start stop int size char map NULL convmap NULL truct video mbuf vid buf struct video mmap vid mmap Wd 0 CCamera amp C reinterpret cast CCamera gt arg LOG DEBUGLOG Camera thread started tid 0x 08X C thread id vid mmap format VIDEO PALETTE YUV420P vid mmap frame 0 vid mmap width C width vid mmap height C height pthread mutex lock amp C state lock while C state CAM OPEN gettimeofday amp start NULL F 129 Spring 2008 ECE 477 Final Report Spring 2008 endif pthread mutex unlock amp C state lock ioctl C cd VIDIOCGMBUF amp vid_buf if map NULL map char mmap 0 vid buf size PROT _READ PROT WRITE MAP SHARED C cd 0 if unsigned char 1 unsigned char map perror mmap map NULL lt if map NULL amp amp ioctl C cd VIDIOCMCAPTURE amp vid mmap 1 perror VIDIOCMCAPTURE gt fprintf stderr args width d height d palette d n vid mmap width vid mmap height vid mmap format munmap map vid buf size map NULL if map NULL amp amp ioctl C cd VIDIOCSYNC am
133. eate thread changed serial initialize doesn t need the device passed to it device is a member 2008 03 27 27 nelson11 changed Cosmetic 2008 03 27 26 nelson11 updated Makefile to reflect vil and network class additions 2008 03 27 25 nelson11 added v41 files for camera Ganked from aerial robotics repo see refs 2008 03 27 24 nelson11 added network class template files 2008 03 27 23 nelsonll added old od camera lib from aerial robotics repo 2008 03 24 22 nelson11 added Overloaded operator to allow for checking success of serial object creation 2008 03 23 21 nelson11 updated Makefile to handle logger fixed compile error 2008 03 23 20 nelson11 added Basic support for serial service class 2008 03 23 19 nelson11 added Initial commit of logger class 2008 03 10 18 nelson11 added messages h define interface with uC here 2008 03 07 17 nelson11 added Initial code base for the gumstix 2008 03 07 16 nelson11 removed More binaries You guys new or something 2008 03 07 15 nelson11 removed Binaries shouldn t be under revision control either 2008 03 07 14 nelson11 removed vim swap file BAD JOSH 2008 03 06 13 jwildey Added capability for all motors and both H Brdiges Added functions to go forward reverse left right and brake Will restructure so that prototype definitions are in header file Also will add capability for 2nd PWM and push button start to help see how straight OMAR doesn t go 2008 03 03 1
134. eateVLinkServer db printf d check odDestroyVLinkServer db printf d check check return 0 main eof Subvehicle refs od od ImageProcess c I ObjectDetection ST define include include include include include pllmage Variables Iplimag CvPoint2D32f CvMemStorage CvSeq CvPoint USE MATH DEFINE od ImageProcess h lt assert h gt s tdlib h gt lt limits h gt lt math h gt od ImageProcess h odAnalyzelmage e tmpl lines line tmp2 tmp3 corners line storage flines Ipllmage source Image processing functions tmp4 final fline storage F 97 float thresh od DB maindb Spring 2008 ECE 477 Final Report Spring 2008 int corners count 20000 int 1 Buffer Initializations tmpl cvCreateImage cvSize source gt width source height IPL DEPTH 8U 1 tmp2 cvCreateImage cvSize source gt width source height IPL DEPTH 8U 1 tmp3 cvCreatelmage cvSize source gt width source height IPL DEPTH 32F 1 tmp4 cvCreateImage cvSize source gt width source height IPL DEPTH 32F 1 final cvCreatelmage cvSize source width source height IPL DEPTH 8U 3 assert tmpl assert tmp2
135. end hmc_read addr reg KRKKKKK send repeat EK KK KK KK KK k e e x x int send repeat TWCR 0 1 lt lt TWSTA 1 lt lt TWINT 1 lt lt TWEN repeat start code wait for repeat start sent while TWCR amp 1 lt lt TWINT check repeat start sent correct if TWSR amp OxF8 TW_REP START return ERROR put str REP START ERROR n r return OK end send repeat KRKKKKK send_start FE Ck k ck k kc k KK KK ek ex int send start send start TWCR 0 1 lt lt TWINT 1 lt lt TWSTA 1 lt lt TWEN send start condition wait for start sent while TWCR amp 1 lt lt TWINT wait for TWINT flag set indicates start sent check start sent correct if TWSR amp OxF8 START return ERROR put str START ERROR n r return OK end send_start KRKKKK send addr t uint8 t addr KCKCkck ck ck ck ckck KK e x x f int send addr t uint8 t addr send addr TWDR addr TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT to start transmission of addresss wait for ACK while TWCR amp 1 lt lt TWINT F 143 ECE 477 Final Report Spring 2008 check status slave sent ack received if TWSR amp OxF8 TW MT SLA ACK return ERROR return OK end send addr KRKKKK send addr r uint8 t addr XCKCkckck ck ck KK ke e e x x
136. er timer h ifndef timer h_ define timer h_ define CLOCK unsigned CLOCK SPEED extern uintl6 t timer cnt void timer start void timer stop void timer reset inline void timer init void endif timer h k Subvehicle Motorcontroller timer c include lt avr interrupt h gt include timer h uintl6 t timer cnt void timer init void TimerO clk0 Motor Controller F 53 Spring 2008 ECE 477 Final Report TCCRO 0x6A OCRO 0x5F TCCR2 0x6A OCR2 TIMSK 0x04 timer cnt Set Timer Counter0 to fast PWM mode Set output compare to asserted state Prescaler factor to set PWM freq at 3 9KHz max PWM freq is 20KHz set output compare register to Set Timer Counter2 to fast PWM mode Set output compare to asserted state Prescaler factor to set PWM at 3 9KHz void timer start TCCR1A 0x0 TCCR1B 0x0 Ox5F Set OC reg to something enable timer overflow interrupt 0 C normal mode 57 eet freg to void timer stop TCCR1A 0X0 TCCR1B 0X0 void timer res TCNT1H 0x0 TCNT1L 0x0 timer cnt ISR TIMER1 OVF timer cnt include lt avr include lt stdi include lt util include lt util define ADDR_S define START 0 0 et 0 0 0 vect ifndef I2C H define I2C H io h o h twi h define F
137. essed Mar 25 2008 15 Google Socially interactive autonomous robot Google Online Available http www google com patents id ngOPAAAAEBAJ amp dq 6539284 Accessed Mar 25 2008 16 Google Multi purpose autonomous vehicle with path plotting Google Online Available http www google com patents idZDIEgAAAAEBAJ amp dq 5170352 Accessed Mar 25 2008 17 Department of Defense Military Handbook Reliablity Prediction of Electronic Equipment Online Document Janurary 1990 Available HTTP http cobweb ecn purdue edu dsml ece477 Homework Fall2006 Mil Hdbk 217F pdf 18 New Corn Based Plastics Considered Durable Biodegradable Aug 23 2004 http usinfo state gov gi Archive 2004 Aug 24 641357 html 19 MobileRobots inc Pioneer 3 AT with room mapping kit MobileRobots inc January 2008 online Available http www activrobots com ROBOTS systems html Accessed February 6 2008 20 iRobot PackBot with mapping kit online document unknown publication date cited February 6 2008 http www irobot com pass cfm li filelibrary GIspecsheets MappingKit pdf 21 Professional Plastics Lexan Sheet Professional Plastics Online Available http www professionalplastics com LEXANSHEET9034 Accessed Feb 06 2008 22 Lynxmotion Lynxmotion Robot Kits Lynxmotion Online Available http www lynxmotion com Accessed Feb 06 2008 23 Maxim IC
138. ex lock amp s if sta te tate lock pthread mutex unloc LOG DEBUG return NET close soc 0G ERROR sockfd 1 state kfd NET CLOSED NET CLOSED k amp state lock pthread mutex unlock amp state lock if thread id P LOG DEBUGLOG thread id 0 LOG INFOLOG return N thread join thread id NULL Network thread stopped Network closed ET OR void CNetwork networkThread void arg int recvSize 0 cSo ck cLen if 1 1 int selectRetVal uint32 t timeoutCnt 0 sizeof addr 5 Network ready on port d NET PORT Network already closed tid 0x 08X F 135 sizeof optval thread id Spring 2008 strerror errno cce 4 strerror errno strerror errno ECE 477 Final Report Spring 2008 fd set nrfds struct timeval timeout fendif CNetwork amp pN reinterpret cast CNetwork gt arg pthread mutex lock amp pN state lock if listen pN sockfd SOMAXCONN 0 pthread mutex unlock amp pN state lock jOG DEBUGLOG Network thread started but failed listen on socket Sain strerror errno pN network close pthread exit NULL pthread mutex unlock amp pN state lock LOG DEBUGLOG Network thread started listening tid 0x 08X pN thread id
139. ffer msg int msg size buffer char malloc sizeof char OD NET BUFFER SIZE assert buffer pthread mutex lock amp server lock server clients state client number 1 pthread mutex unlock amp server lock while server gt clients state client number rr recv server clients socks client number buffer OD NET BUFFER SIZE 0 if err 1 printf Error on recv n continue cpos 0 while cpos lt OD NET BUFFER SIZE if cpos gt OD NET BUFFER SIZE 4 else msg size od Packet amp buffer cpos gt size switch packet mode case OD NET PACKET NEW msg char malloc msg size if msg size gt OD NET BUFFER SIZE cpos packet mode OD NET PACKET CONT else break case OD NET PACKET CONT break default printf This should not have been reached in odLANClient thread n break while 1 send quit message close server clients socks client number pthread mutex lock amp server lock server clients socks client number 0 server num clients server clients client number 0 pthread mutex unlock amp server lock odLANDClient thread F 60 ECE 477 Final Report Spring 2008 int odLANSend
140. fixed point value to a byte with clipping define LIMIT x x gt 0xffffff 0xff x lt 0xffff 0 x gt gt 16 G static inline void v4l copy 420 block int yTL int yTR int yBL int yBR int u int v int rowPixels unsigned char rgb int bits const int rvScale 91881 const int guScale 22553 const int gvScale 46801 const int buScale 116129 const int yScale 65536 Xmnt y qx b g guScale u gvScale v r rvScale v b buScale u yTL yScale yTR yScale yBL yScale yBR yScale if bits 24 Write out top two pixels rgb 0 LIMIT b yTL rgb 1 LIMIT g yTL rgb 2 LIMIT r yTL rgb 3 LIMIT btyTR rgb 4 LIMIT g yTR rgb 5 LIMIT r yTR Skip down to next line to write out bottom two pixels rgb 3 rowPixels rgb 0 LIMIT b yBL rgb 1 LIMIT g yBL rgb 2 LIMIT r yBL rgb 3 LIMIT b yBR rgb 4 LIMIT g yBR rgb 5 LIMIT r yBR else if bits 16 Write out top two pixels rgb 0 LIMIT b yTL gt gt 3 amp Ox1lF LIMIT g yTL lt lt 3 amp OxEO rgb 1 LIMIT g yTL gt gt 5 amp 0x07 LIMIT r yTL amp OxF8 rgb 2 LIMIT btyTR gt gt 3 amp Ox1F LIMIT g yTR lt lt 3 amp OxEO rgb 3 LIMIT g yTR gt gt 5 amp 0x07 LIMIT r yTR amp OxF8
141. g basic TCP socket programming The base station client will connect to it over an AdHoc 802 11b g network Primarily this connection will be used to send the target image back to the base station once found If necessary its function will be extended to provide debugging and control to the vehicle The camera thread will take a picture with the USB webcam and signal the image recognition thread for processing when it has finished The camera takes 20ms to take a picture giving way to 50 fps which is definitely overkill for this application The frame rate will likely be limited to 3 4 fps The last thread will communicate with the microcontroller over the UART Primarily it will receive telemetry data to be sent off to the SLAM thread but will also be used to start and stop the vehicle as well as transmit new headings All portions of the Gumstix codes have been diagrammed Any non trivial code segments have been laid out in pseudocode The UART class is mostly complete A test stub for the camera has been written for x86 which also compiles without error under ARM the kernel driver needs to be compiled before it can be tested 10 2 2 ATMega32 The only module that the motor controller and servo utilizes is the PWM Since the PWM is in the asserted output compare state the output compare register will control how much of the duty cycle will be asserted as opposed to the other way around The H bridges located on the motor controller determine
142. gram int odDestroyVLinkServer od DB db Used to initialize the links and to resize the link server list depending on memory needs If count lt 0 then it reduces gt 0 increase Returns the number of links added or reduced Links are added or reduced from the end of the list int odResizeVLinkServer od DB db int count Same as above but for object link server Almost identical functions int _odCreateOLinkServer od DB db int odDestroyOLinkServer od DB db int odResizeOLinkServer od DB db F 102 ECE 477 Final Report Spring 2008 Given the xyz coordinates and the type of link to create a link is obtained from the link server set to the appropriate values and inserted properly in the vertices database The pointer to the link just made is returned NULL on error od VertLink odAddVert od DB db int x int y int z Given a pointer to a vertex it will remove it from the vertices list and replace it in the link server non zero returned on success This maintains the integrity of the list it removes the item from int odRemoveVert od DB db verti 3d vert Same as above but for objects od ObjLink odAddObj od DB db od Object parent specs int odRemoveObj od DB db od Object obj od Object subobjects endif OD DBASE H m eof ZEIEN Subvehicle refs od od SearchPath c od SearchPath c ObjectDetec
143. gress 100 int zoom N A set to 1 l Range of angles of the camera both horizontally and vertically The zoom is not used maybe in the futur Si F 116 ECE 477 Final Report Struct pwc mpt range int pan min pan max degrees 100 int tilt min tilt max int zoom min zoom max ly nm ox struct pwc mpt status int status int time pan int time tilt Restore user settings define VIDIOCPWCRUSER LO ae 192 Save user settings define VIDIOCPWCSUSER IO v 193 Restore factory settings define VIDIOCPWCFACTORY _To v 194 Spring 2008 You can manipulate the compression factor A compression preference of 0 means use uncompressed modes when available 1 is low compression 2 is medium and 3 is high compression preferred Of course the higher th compression the lower the bandwidth used but more chance of artefacts in the imag The driver automatically chooses a higher compression when the preferred mode is not available A Set preferred compression quality 0 uncompressed 3 highest compression define VIDIOCPWCSCQUAL IOW v 195 int Get preferred compression quality define VIDIOCPWCGCQUAL IOR v 195 int This is a probe function since so many devices are supported it becomes difficult to include all the names in programs that want to check for the enhanced P
144. hilips stuff So in stead try this PROBE it returns a structure with the original name and the corresponding Philips type To use fill the structure with zeroes call PROBE and if that succeeds compare the name with that returned from VIDIOCGCAP they should be the same If so you can be assured it is a Philips OEM cam and the type is valid define VIDIOCPWCPROBE IOR v 199 struct pwc probe Set AGC Automatic Gain Control int lt 0 auto 0 65535 fixed define VIDIOCPWCSAGC IOW v 200 int Get AGC int lt 0 auto gt 0 fixed range 0 65535 define VIDIOCPWCGAGC IOR v 200 int Set shutter speed int lt 0 auto gt 0 fixed range 0 65535 define VIDIOCPWCSSHUTTER IOW v 201 int Color compensation Auto White Balance define VIDIOCPWCSAWB IOW v 202 struct pwc whitebalance define VIDIOCPWCGAWB IOR v 202 struct pwc whitebalance Auto WB speed define VIDIOCPWCSAWBSPEED IOW v 203 struct pwc wb speed define VIDIOCPWCGAWBSPEED IOR v 203 struct pwc wb speed LEDs on off blink int range 0 65535 F 117 ECE 477 Final Report Spring 2008 define VIDIOCPWCS define VIDIOCPWCGLI IOW v 205 struct pwc leds IOR v 205 struct pwc leds ED ED Contour sharpness int lt 0 auto 0 65536 fixed define VIDIOCPWCSCONTOUR IOW v 206 int define VIDIOCPWCGCONTOUR IOR v 206 int Backl
145. ic palette palette VIDEO PALETTE GREY if ioctl fd VIDIOCSPICT amp vid pic 1 perror ioctl VIDIOCSPICT to GREY return 1 return 0 check if driver supports mmap ed buffer Si int v4l check mmap int fd int size struct video mbuf vid buf if ioctl fd VIDIOCGMBUF amp vid buf 1 return 1 if size size vid buf size return 0 mute sound if available Ef int v4l mute sound int fd struct video capability vid caps struct video audio vid aud if ioctl fd VIDIOCGCAP amp vid caps 1 perror ioctl VIDIOCGCAP return 1 if vid_caps audios gt 0 mute the sound if ioctl fd VIDIOCGAUDIO amp vid_aud 1 return 1 else vid aud flags VIDEO AUDIO MUTE if ioctl fd VIDIOCSAUDIO amp vid aud 1 return ls return 0 Turn a YUV4 2 0 block into an RGB block Video4Linux seems to use the blue green red channel order convention rgb 0 is blue rgb 1 is green rgb 2 is red F 121 ECE 477 Final Report Spring 2008 Color space conversion coefficients taken from the excellent http www inforamp net poynton ColorFAQ html In his terminology this is a CCIR 601 1 YCbCr gt RGB Y values are given for all 4 pixels but the U Pb and V Pr are assumed constant over the 2x2 block To avoid floating point arithmetic the color c
146. if ifndef sbi define sbi sfr bit SFR BYTI endif Fl sfr BV bit ifndef cbi define cbi sfr bit SFR BYTI endif Fl sfr amp BV bit Initialize UART MUST BE CALLED void uart init Write 8 bit value to UART void put char uint8 t c Write 16 bit value to UART void put short uintl6 t s Write string of length len to UART void put str char str uint32 t len fendif Mr UART_ tti t Subvehicle Sensors trunk HMC6352 i2c c include lt avr interrupt h gt include lt avr io h gt F 29 ECE 477 Final Report Spring 2008 include i2c h include uart h void i2c init PORTC 0x03 portO and portl internally pulled high TWSR 0 lt lt TWPSO amp 0 lt lt TWPS1 prescalar 1 default 0 TWBR 8 F CPU 100000UL 16 2 0x02 2 with prescalar 1 should 100kHz end init int hmc transmit uint8 t addr uint8 t data int status 0 if send start ERROR return ERROR if send addr t addr ERROR return ERROR if send data data ERROR return ERROR send stop return OK end i2c transmit addr data uintli6 t hmc read uint8 t addr uintl6 t data 0 if send_start ERROR return ERROR if send addr r addr ERROR return ERROR if get ack data ERROR return ERROR data TWDR lt lt 8
147. ight Compensation int devnum int val if ioctl device devnum VIDIOCPWCSBACKLIGHT amp val 1 error exit VIDIOCPWCSBACKLIGHT void Set Antiflicker Mode int devnum int val F 87 Spring 2008 ECE 477 Final Report Spring 2008 voi ttt 0X F X X F F Xo Xo X X F F F X X in in in in in in in in in in de de Se St int v4l if ioctl device devnum VIDIOCPWCSFLICKER val 1 error exit VIDIOCPWCSFLICKER d Set Noise Reduction int devnum int val if ioctl device devnum VIDIOCPWCSDYNNOISE amp val 1 error exit VIDIOCPWCSDYNNOISE Subvehicle refs od otherlibs v4l c v4l c Copyright C 2001 Rasca Berlin This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Foundation Inc 675 Mass Ave Cambridge MA 02139 USA clude lt stdio h gt clu
148. ight compensation 0 off otherwise on define VIDIOCPWCSBACKLIGHT IOW v 207 int define VIDIOCPWCGBACKLIGHT IOR v 207 int Flickerless mode 0 off otherwise on define VIDIOCPWCSFLICKER IOW v 208 int define VIDIOCPWCGFLICKER IOR v 208 int Ia Ia Dynamic noise reduction 0 off 3 high noise reduction define VIDIOCPWCSDYNNOISI IOW v 209 int define VIDIOCPWCGDYNNOISI IOR v 209 int Ia D Ia D Real image size as used by the camera tells you whether or not there s a gray border around the image define VIDIOCPWCGREALSIZE _IOR v 210 struct pwc imagesize Motorized pan amp tilt functions define VIDIOCPWCMPTRESET IOW v define VIDIOCPWCMPTGRANGE define VIDIOCPWCMPTSANGLE IOW define VIDIOCPWCMPTGANGLE define VIDIOCPWCMPTSTATUS IOR int struct pwc mpt range struct pwc mpt angles struct pwc mpt angles struct pwc mpt status lt lt H o Kl lt 44d4dd BYR DSO NS WNNFR EF lt endif 4 Subvehicle OMAR trunk v41 v4l h v4l h Copyright C 2001 Rasca Berlin This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This program is distributed in the ho
149. ill 28 ECE 477 Final Report Spring 2008 be able to handle up to 7 5 amps while the regulator for the rest of the components will be 3 0 amps The 5 0 volt regulator at 7 5 amps needs a 1OuF capacitor on the input and a 150uF capacitor on the output which was specified in the datasheet 26 For the 5 0 volt regulator at 3 0 amps the manufacturer recommends that a 0 33uF capacitor should go on the input and a 0 1uF capacitor should go on the output as bypass capacitors to help reduce noise from propagating throughout the circuit 27 The 3 3 volt regulator needs to have a 0 47uF capacitor along with a 33uF capacitor 28 10 0 Software Design Considerations Several aspects must be considered when designing the software for an autonomous vehicle like OMAR Sensors must be read consistently and at an appropriate rate These values need to be filtered integrated with the current state and control signals modified as necessary It is important that all of these things happen in a timely manner and that data from the sensors be received on time A real time system is an excellent solution to all of these problems Its main goal is to meet deadlines making it the perfect development paradigm for OMAR 10 1 Software Design Considerations To solve the real time problem an embedded Linux operating system was chosen With the addition of a preempting process scheduler that operates in O 1 time complexity added in kernel version 2 6 as well as a
150. in control thread which will have the task of spawning the worker threads registering callbacks and cleaning up after the workers once they have terminated It will also stop the vehicle if it is determined that the mission is complete CPU usage by this thread will be relatively low as it will spend a majority of the time asleep Two threads will be created to do heavy computation One will handle image processing using the object detection functions of Intel s open source computer vision library OpenCV When it finds the target object it will callback to the main control thread which will 30 ECE 477 Final Report Spring 2008 stop the vehicle and send the image back to the base station The other CPU intense thread will take care of mapping using a SLAM Simultaneous Localization and Mapping algorithm Two potential candidates for this algorithm are being researched GridSLAM and DP SLAM both of which are hosted at OpenSLAM org This thread will maintain a map of what has been seen so far in the room The map will be used to determine where to explore next by determining the largest opening in the map When it is decided that the room has been sufficiently mapped a large percentage of the map is closed the thread will signal the control thread to stop the vehicle as the target image is not likely in the room Three more threads will be spawned to handle the network camera and telemetry data The networking thread will run a server usin
151. inal Report if neg gain left speed right speed if ls left right throttle speed gain 2 throttle speed gain 2 left speed lt 0 left speed 0 if else if OCRO left side OCRO OCR2 if left speed gt OxFF left speed OxFF right speed lt 0 right speed 0 right speed OxFF OxFF right speed OCR2 right side uint8 t left speed right speed go forward check for objects Lt sonar_suml lt THRESHOLD brake delay ms 10 state REVERSE if pos gain if any sonar detects object go to state sonar sum2 THRESHOLD Spring 2008 left right REVERSE A sonar sum3 lt THRESHOLD go reverse for 10 ms if S2 detects and S3 does not turn right else turn left else if EVERS E state OCRO OxFF OCR2 OxFF go_reverse delay ms 10 if sonar sum2 lt sonar sum3 State RIGHT else state LEFT state RIGHT or LEFT else if state RIGHT if sonar suml lt THRESHOLD 10 OCRO OxFF OCR2 OxFF turn right else brake state STOP else if state LEFT if sonar suml lt THRESHOLD 10 OCRO OxFF OCR2 OxFF turn_left F 148 Turn left or right until no object Then go sonar sum2 THRESHOLD 10 sonar sum3 lt THRESHOLD 10 ECE 477 Fi
152. inal Report memset void a 0 10 sizeof uint16 t Initialize UART peripherial MUST BE CALLED cli uart init adc init sei while 1 Delay so we don t send stuff too fast delay ms 32 delay ms 32 a p read adc p p 1 10 if size lt 10 sizet sum 0 for i 0 i lt size i sum a i snprintf c 10 IR 4d r int sum size put str c 10 THEE Subvehicle Sensors trunk GP2Y0A2 test c include lt stdlib h gt include lt stdio h gt int main int i 45 char s 10 itoa i s 10 printf Ss n s return 0 THEE Subvehicle Sensors trunk GP2Y0A2 uart c include lt avr interrupt h gt include lt avr io h gt define BAUD 12 include uart h UART variables static volatile uint8 t tx_read static volatile uint8 t tx write static volatile uint8 t tx buff TX BUFF SIZE void uart init Enable the UART for sending and receiving sbi UCSRB RXEN sbi UCSRB TXEN tx read tx write 0 Set baud rate registers F 27 Spring 2008 ECE 477 Final Report UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx interrupt Sbi UCSRB RXCIE UART tx interrupt SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write cbi UCSRB UDRIE return U
153. ing literal infringement against OMAR 4 3 Action Recommended Since OMAR has literal infringement on all three patents there are very few options available The easiest option available is to wait until the patents expire Even though this option is available it is basically unusable Two of the three patents were filled 7 8 years ago which means it would be anther 12 13 more years until those expire By then this technology would 13 ECE 477 Final Report Spring 2008 most likely be useless anyway Like stated before this option is useless The next option is to change the design to erase the literal infringement However this is also useless because everything in the project is needed and there really isn t any way around getting the project done without using what is already being implemented The next option would involve paying royalties to the owners of the patents If OMAR would become a commercial product this would be the only option available to use However since OMAR is not going to be a commercial product and that it is only needed for the aerial project nothing needs to be done in order to avoid infringing on active patents 5 0 Reliability and Safety Analysis As far as safety and reliability are concerned there are many things to consider with OMAR First reliability is very critical considering this application will most likely be used for military reconnaissance purposes If this device were to fail it may cause the
154. ink in for some dumb reason 2008 03 28 40 nelson11 changed make to use arm compiler WON T WORK ON X86 2008 03 28 39 nelson11 added Camera service actually takes pictures now added Test function to store images as jpeg 2008 03 28 38 nelson11 fixed Check for successful oject creation didn t work at all 2008 03 27 37 nelson11 changed Makefile is a little more flexible for subdirectories now 2008 03 27 36 nelson11 modified I m just using this to test stuff ATM Changed it to start the omar control thread which then starts the other services 2008 03 27 35 nelson11 added Serial and camera services to the omar control thread 2008 03 27 34 nelson11 removed All of the debug code this time fixed Duplicate log message 2008 03 27 33 nelson11 removed Duplicate log message fixed Potential deadlock if select fails miserably 2008 03 27 32 nelson11 added Missd a header in the last commit removed Some debug code that forced camera service to succeed without camera attached 2008 03 27 31 nelson11 added Most of the code for the camera service class needs testing 2008 03 27 30 nelson11 fixed Makefile didn t relink when most files were modified 2008 03 27 29 nelson11 changed Moved v4l c to v4l cpp so it will be compiled with g and actually link with the rest of the code updated Makefile to reflect the above 2008 03 27 28 nelsonl1 removed Unnecessary getStatus function fixed Call close serial if we fail to cr
155. ired was a DIMM200 slot on the PCB to grant access to nearly all of the PXA s peripherals This module also used the fastest of the PXA series processors PXA 320 with a maximum clock rate of 806MHz Another potential problem was finding a small 802 11 card to connect to the PCMCIA bus Strategic Test also boasted it as being the lowest power PXA module on the market using 1 8v SDRAM and NAND flash units Sadly after a week of emailing Strategic Test with no response and no useful publicly available datasheet the search was on again Finally the Gumstix Verdex XL6P 10 was decided upon Though it has a slightly slower processor and less NAND flash the expansion boards Gumstix offers were unparalleled One particular board has 10 100 ethernet 802 11b g wireless and an SD card reader The first two meet some of our requirements while the third alleviates the lack of flash storage The XL6P with this breakout board is just under twice the price of the TRITON 320 13 but development can be done without any more hardware where the TRITON 320 required a nearly 2000 development board Table 2 Embedded Computer Comparison Gumstix Verdex Strategic Test XL6P TRITON 320 CPU Marvell PXA 270 Marvell PXA 320 Clock 600MHz 806MHz SDRAM 128MB 64MB NAND Flash 32MB 128MB UART 3 3 USB Host Y Y Ethernet Y Y vai Y 8rd Party over wia Y PCMCIA SD Card Y Y Supply 3 6 5 0V 3 3 5 0V Voltage Dimensions 80mm X
156. iteness d n vpic whiteness printf Palette switch I vpic palette case VID EO PALETTE GREY printf Linear intensity grey scale 255 is brightest break case VIDEO PALETTE HI240 printf The BT848 8bit colour cube n brea case VIDEO PALETTE RGB565 printf RGB565 packed into 16 bit words n break case VIDEO PALETTE RGB555 ch CT T wy CT ER 3 F 81 gt gt An ECE 477 Final Report Spring 2008 printf RGV555 packed into 16 bit words top bit undefined n break case VIDEO PALETTE RGB24 printf RGB888 packed into 24bit words Nn break case VIDEO PALETTE RGB32 printf RGB888 packed into the low 3 bytes of 32bit words The top 8bits are undefined n break case VIDEO PALETTE YUV422 printf Video style YUV422 8bits packed 4bits Y 2bits U 2bits VNn break case VIDEO PALETTE YUYV printf Describe me n brea case VIDEO PALETTE UYVY printf Describe me n brea case VIDEO PALETTE YUV420 YUV420 capture n W Cl ER T ch CT ER T prin brea case VIDEO PALETTE YUV411 printf YUV411 capture n brea case VIDEO PALETTE RAW printf RAW capture BT848 n brea case VIDEO PA ETTE YUV422 wy Ct ER I wy CT ER I ch Ct ER U printf YUV 4 2 2 Planar n break case VIDEO P
157. ition are all fields of highly active research When searching for similar products the vehicles that were found all fell within two intended categories research or military use When it comes to the packaging design used in each category they seem to have some distinct differences The vehicles for research tend to be much larger in size more open and less contained and some were significantly lighter than those intended for military use The main reasons for this are due to the fact that military UGV s are intended for detection neutralization breaching minefields logistics fire fighting and urban warfare to name a few uses These applications can require the vehicle to be very small sometimes heavy have long battery life and always very powerful In research implementation the size and weight of the vehicle are not usually of concern It is the sensors and software running on the vehicle that is the main concern Two main commercial products have been chosen that most similarly resemble the project The first product which falls under the research category is the MobileRobotics incorporation s Pioneer 3 AT 19 with the 2 D 3 D room mapping and stereovision kits The second product 21 ECE 477 Final Report Spring 2008 the iRobot PackBot 20 with mapping Kit is an example of military use OMAR is planned to incorporate many features from both products and also have some unique features Shown below are the advantages and disadvant
158. ke x ke x x6 1 TWEN 1 TWSTO return OK kkkk int get data int get data get data TWCR 0 1 lt lt TWINT NACK XCkckckckckck ck kk ke e ke x x 1 TWEN clear TWINT bit to wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK return ERROR put str DATA REC ERROR An Nr return OK kk int get data int get nack data get data TWCR 0 1 lt lt TWINT NACK XCkckckckckck ck kk ke ke ke x 1 lt lt TWEN clear TWINT bit to wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set F 32 start data read send data sent NACK sent start data read send data sent NACK sent ECE 477 Final Report Spring 2008 check status MR DATA NACK if TWSR amp OxF8 TW MR DATA NACK return ERROR put str DATA REC ERROR An Nr return OK RK KKK KKK int get data XCkckckckckck ck ok ck ke ke ke x int get ack data get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK sent while TWCR amp 1 TWINT wait for TWINT flag set data sent NACK sent check
159. le TWCR amp 1 TWINT wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MR SLA ACK i2c error ERROR put str ADDR SENT ERROR n r return OK end send addr KKK RK KK Ck Ck kk Ck kk kk kk kk AXi KKK KK ke ke kk int send data uint8 t data KCKCKCKCKCKCkCkCkCk Ck kCkCkCkCk Ck kk kk kk k k kk ck ck ck ck ck ck kck ck sk ko int send data uint8 t data i2c error OK send data TWDR data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data transmission wait for ACK while TWCR amp 1 TWINT wait for TWINT flag set data sent ACK received check status MT DATA ACK if TWSR amp OxF8 TW MT DATA ACK i2c error ERROR put str DATA SENT ERROR n r return OK end send data F 21 ECE 477 Final Report Spring 2008 ckckckckckck kk k H kkkkxkxkxkxkxkxkxkkxkxkkxkxk send stop void send stop i2c error OK send STOP condition TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWSTO return OK kk kk int get data XCkckckckckck ck kk ke ke ke x int get data i2c error OK get data TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT bit to start data read send NACK wait for ACK sent while TWCR amp 1 TWIN
160. lerometer and Sonar code and outputs to uart 2008 04 01 57 rtoepfer added initial import of working magnetometer code outputs full 360 deg heading to uart 2008 04 01 56 rtoepfer added initial check in of working accelerometer code reads X Y Z forces 2008 04 01 55 rtoepfer updated i2c test code working reading lower byte of data only 2008 04 01 54 rtoepfer removed unecessary backup files 2008 03 31 53 nelson11 added Kdevelop project file 2008 03 31 52 nelson11 fixed distclean target actually cleans up everything now 2008 03 31 51 nelson11 changed Camera class to reflect changes in v41 2008 03 31 50 nelson11 changed Cleaned up makefiles a bit They re a little more flexible now 2008 03 31 49 nelson11 changed Renamed v4l cpp back to v4l c 2008 03 31 48 nelson11 fixed Compile error if DEBUG not defined 2008 03 31 47 nelson11 changed Run for 5s instead of 3 F 3 ECE 477 Final Report Spring 2008 2008 03 31 46 nelson11 changed Makefiles now detect arch change and run make clean only as necessary added Makefiles now auto finds dependencies Just add object to OBJS variable in Makefile 2008 03 30 45 nelson11 fixed Linking problem with libjpeg 2008 03 30 44 nelson11 added target to make for ARM 2008 03 28 43 nelson11 removed Commented test code that uses libjpeg so we can link 2008 03 28 42 nelson11 fixed Compile error 2008 03 28 41 nelson11 changed make for x86 again cause I can t get libjpeg to l
161. llution that may accompany This can also be applied to devices that are thrown out and end up in landfills There is sometimes an underlying potential for environmental damage as in the case of lithium polymer batteries The chemicals themselves are perfectly safe to send to a landfill but if the pack is sent with too high a charge there is risk of fire or explosion The remainder of this report will outline major environmental and ethical considerations taken during OMAR s design as well as discuss possible solutions 6 1 Ethical Impact Analysis There are ethically few considerations to be made with this project The biggest problem and the one with the most potential to cause harm to the user and hence liability to the producers is improper care and use of the lithium polymer battery pack Another concern is the 18 ECE 477 Final Report Spring 2008 presence of lead in the electrical components Finally there is the potential for misuse of the product to invade the privacy of others The lithium polymer battery gives an excellent power output to weight ratio making it ideal for this application However over charging the pack or handling it roughly can cause a fire or explosion To make the user aware of these risks warning labels will be applied liberally There will at least one in the battery compartment and one on the battery itself The label will caution the user through words and scary pictures as well as refer to the pages i
162. lo During the design stage of the project I spent some time researching into range finder devices There were a few options that I looked into including IR sonar laser and stereoscopy I discovered a lot of projects used laser because it gives you the best measurement However after looking into it further I discovered that any laser device available was way too heavy and the cost was extremely high As another teammate looked into IR I spent time with sonar and found a relatively cheap and accurate sonar The next parts that I researched for were batteries motors and a wireless module During the end stage of researching into parts needed for the project I started a table on a white board with a list of all parts needed Then I filled in the part name number power and current requirements and type of interface for each one I helped work on the schematic which was a stepping stone into my next job the PCB Initially we were going to have a power supply circuit so I did the whole schematic for that Before doing the PCB I had to go back in and change up the microcontroller schematic I added in headers for all the devices to connect to the board After looking into datasheets for various parts I added bypass capacitors based on the manufactures advice During the time I was working on the schematic I was also experimenting with Orcad Layout since I had never worked with that software before After playing around and testing the softwar
163. m mapping data would be incorrect as it is used in the SLAM algorithm to determine walls and objects Again since the image recognition objective could still be finished this would be a low criticality 6 0 Ethical and Environmental Impact Analysis The environment is a hot topic now more than ever For far too long has the environmental impact of a product sent to market been short changed if considered at all To a similar affect today s society is rampant with corrupt business men as well as lawsuit happy consumers For these reasons it is important to consider both the environmental and ethical impact of a new product from concept inception all the way though ship out Fortunately in the case of an autonomous reconnaissance robot like OMAR the target consumer is looking for more of a research law enforcement or military solution This knowledge relaxes the emphasis on the ethical aspects as the end user s superiors will likely ensure that the safe use guidelines provided with the product are followed and that proper training is received before use However it is still pertinent that warnings be given as a reminder of potential hazards such as contents of hazardous materials and potential for injury Environmental considerations are still quite important especially in military applications where damaged products may simply be left behind In this situation it is necessary to determine the biodegradability of the chassis as well as any po
164. mer init uart init sei timer cnt 0 put char A uintl6 t i 650 char s 50 0 F 36 Spring 2008 ECE 477 Final Report in wh re Td inc inc def inc def t x 10 ile 1 move servo i delay ms 32 itzx if x gt 0 amp amp i x gt 2450 x x else if x lt 0 amp amp i x lt 650 x x snprintf s 50 i d n r i put str s turn 0 Subvehicle Sensors trunk servo uart c lude lt avr interrupt h gt lude lt avr io h gt ine BAUD 12 lude uart h ine NULL void 0 UART variables static volatile uint8 t tx read static volatile uint8 t tx write static volatile uint8 t tx buff TX BUFF SIZE static volatile uint8 t rx head static volatile uint8 t rx tail static volatile uint8 t rx buff TX BUFF SIZE void uart init Sbi UCSRB RXEN Enable the UART for sending and receiving Sbi UCSRB TXEN tx read tx write 0 Set baud rate registers UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx interrupt sbi UCSRB RXCIE UART rc interrupt SIGNAL SIG UART RECV ui tmp head rx head 1 RX BUFF SIZE nt8 t tmp head M F 37 Spring 2008 ECE 477 Final Report Spring 2008 if rx full while tmp head rx tail rx buff rx head UDR rx head
165. ming constraints of each device This was necessary due to the real time constraints of the project The sonar test code was later revamped to include a sonar data structure and later became the main microcontroller loop Lastly Robert wrote the functions used to communicate with the Gumstix Throughout the whole project every member of the team contributed in creating headers wires re soldering parts etc Robert helped with placement of different parts on OMAR The serial level translator ended up being soldered incorrectly so Robert fixed that along with the new power board for the Gumstix which was initially incorrect as well Robert also worked with the Open CV image recognition software to train the image for recognition It went well except the haartraining exe stalled at stage 17 of the training From past user s experience a training of 20 stages or more is needed for accurate recognition Robert also researched how to use the XML files for image recognition ECE 477 Final Report Spring 2008 Appendix B Packaging Figure B 1 Top View of Conceptual Packaging of OMAR B 1 ECE 477 Final Report Spring 2008 MN Bi Eo pp pd j E EE Ee a EES Figure B 2 Side View of Conceptual Packaging of OMAR B 2 ECE 477 Final Report Spring 2008 Figure B 3 Top View of Conceptual Packaging of OMAR ECE 477 Final Report Appendix C Schematic 1 2 CONN JACK PWR PowerJack1 0 C 1 Sp
166. mpliant equivalents as well This leaves only the motors which are difficult to source with similar specifications for the application and RoHS compliance These could probably be custom made or made in house if necessary Either way cost would be significantly higher The polycarbonate chassis doesn t cause many problems until the disposal stage though its production does have petroleum components which increase the carbon footprint Both of these issues can be resolved by use of newer polymers with better biodegradability properties There have been advances with these polymers that allow them to be stronger and more durable than before Some like the one being developed at Clemson use a corn byproduct polylactic acid in replacement of most of the harmful chemicals currently used in plastic production 18 Using a material like this wouldn t hurt OMAR s durability but could potentially greatly reduce its impact on landfills as well as litter should it be left on the battlefield Lastly the lithium polymer battery pack Workers assembling the units would have to be properly trained in handling this type of battery to avoid hazards at the factory The final packaging should be designed in such a manner as to reduce the possibility of shorting the battery polarized connectors as well as minimize the likelihood of the pack being directly impacted in case of a fall or collision These two steps should lessen the chances of injury to the end users
167. n OD ERROR server sockaddr sin family AF INET server sockaddr sin addr s addr INADDR ANY server sockaddr sin port htons port err bind listen socket struct sockaddr amp server sockaddr sizeof struct sockaddr in if err 1 printf error in bind n close listen socket return OD ERROR err listen listen socket SOMAXCONN if err 1 printf error in listen n close listen socket return OD ERROR go 1 server od LANServer malloc sizeof od LANServer assert server server listen socket listen socket fcntl server gt listen socket F SETFL O NONBLOCK if 0 pthread create amp server sthandle NULL odLANServer thread void NULL printf error in pthread create n server listen socket 0 close listen socket free server return OD ERROR return OD OK odCreateLANServer int odDestroyLANServer int sflags err assert server go 0 pthread join server gt sthandle NULL pthread join server gt sthandle NULL return OD OK odDestroyLANServer F 58 ECE 477 Final Report Spring 2008 void sigiohandler int arg printf sigio called n sigiohandler void odLANServer thread void args int accept socket int i server num clients 0 memset server clients 0 sizeof pthread t OD N
168. n deriv 100 long int heading error 0 long int prev heading error 0 long int prev time 0 long int curr time 0 KKK KK Ck kk kk kk kk ke ke ke ke ek k Go Foward Function Sets INA for both H Bridges to 1 and sets INB for both to 0 KCKCKkCkCk kk k ck He kk ke void go forward PORTC 1 lt lt 3 1 lt lt 5 PORTC amp 1 lt lt 2 amp 1 lt lt 4 return KR KKK KK KK KK KK ek Go Reverse Function Sets INA for both H Bridges to 0 and sets INB for both to 1 KCKCKkCkCk kk ck ck ck ck ck ck kk void go reverse PORTC 1 lt lt 2 1 lt lt 4 PORTC amp 1 lt lt 3 amp 1 lt lt 5 return KKK RK Ck KK KK KK ek k Turn Left Function Makes 4 5 go reverse Makes 6 7 go forward KCKCKkCkCk kk ck ck ck ck ck ck kckckok ck kk void turn left PORTC 1 lt lt 3 1 lt lt 4 PORTC amp 1 lt lt 2 amp 1 lt lt 5 F 138 Spring 2008 ECE 477 Final Report return BRK KKK kk kk kk kk kk k ek Turn Right Function Makes 4 5 go forward Makes 6 7 go reverse KCKCKkCkCk kk k ck ck ck ck ck kckckok ko ke e ke x void turn right PORTC 1 lt lt 2 1 lt lt 5 PORTC amp 1 lt lt 3 amp 1 lt lt 4 return KR KKK Ck KK KK KK kk Brake Function ge KCKCKkCkCk kk ck ck ck ck ck ck kk void brake
169. n n what printf of your webcam and the driver n void Dump Current Settings int devnum struct video capability vcap struct video window vwin struct video picture vpic struct pwc probe pwcp int dummy struct pwc whitebalance pwcwb struct pwc leds pwcl Struct pwc mpt range pmr struct pwc mpt angles pma get name if ioctl device devnum VIDIOCGCAP amp vcap 1 error exit VIDIOCGCAP printf Current device s n vcap name verify that it IS a Philips Webcam if ioctl device devnum VIDIOCPWCPROBE amp pwcp 1 error exit VIDIOCPWCPROBE if strcmp vcap name pwcp name 0 Spring 2008 printf Warning this might not be a Philips compatible webcam Nn printf VIDIOCPWCPROBE returns s dWMn pwcp name pwcp type get resolution framerate if ioctl device devnum VIDIOCGWIN amp vwin 1 error exit VIDIOCGWIN printf Resolution x y d d n vwin width vwin height printf Offset d dWMn vwin x vwin y if vwin flags amp PWC FPS FRMASK printf Framerate d n vwin flags amp PWC FPS FRMASK PWC FPS SHIFT color etc settings if ioctl device devnum VIDIOCGPICT amp vpic 1 error exit VIDIOCGPICT printf Brightness d n vpic brightness printf Hue dWMn vpic hue printf Colour dWMn vpic colour printf Contrast d n vpic contrast printf Wh
170. n network service changed die callback doesn t need any args 2008 04 23 134 nelson11 fixed Got rid of scary message when we catch a signal on ARM changed Made client socket a member added go command and callback to serial to handle it causes problems 2008 04 23 133 rtoepfer modified added the stdlib h for the snprintf debug statement 2008 04 23 132 rtoepfer modified added sonar structure and some sonar functions to initialize avg and find the minimum distance Added code to detect when we are running close to a wall The middle sonar sensor seems to not go above 5lcm for some odd reason Maybe its picking up ghost readings from the other sensors The side detection wasnt tested since the speed was always slow due to the middle sensor not functioning properly Needs further debug testing of middle sensor and side sensors 2008 04 23 131 rtoepfer Modified added terminal mode definition 2008 04 23 130 nelson11 added packet structures for network and serial as well as some enumerated types to define packets and commands 2008 04 23 129 rtoepfer modified took out the accel mag and sonar code and put in respective c h files 2008 04 23 128 rtoepfer added broke up the i2c c and i2c h files to smaller more manageable files seperated the magnetometer accelerometer and sonar i2c code into seperate files 2008 04 23 127 nelson11 added some basic layout components for image recognition service 2008 04 22 126 rtoepfer modifie
171. n the manual for proper care and usage of the battery In the manual there will be explicit guidelines for charging discharging and handling the battery safely Concerning the presence of lead the best solution is to simply eliminate it by making the entire design RoHS compliant Forgoing this though the only thing that can be done is to design the packaging in a manner as to shield the user from direct contact with the lead bearing components Also a warning label should be a fixed in a clearly visible location to make this fact known to the user It should also be mentioned in the user s manual The last issue of misuse by the user to invade the privacy of others really can t be helped Itisn t the place of the producer to tell someone how to use the product only to give a recommendation Regardless there isn t any way to police a policy printed in the manual not to mention the fact that this action would likely insinuate this type of misuse to some users 6 2 Environmental Impact Analysis The OMAR prototype is not all that environmentally friendly The motors and PCB though the amount is small both contain lead This is a problem at all stages of the life cycle Workers at the factory will have to handle the lead ridden parts as well as breathe air that could potentially contain lead particles from the manufacturing process In normal use the end user will be handling the device which may have lead residue on it from manufacture as well
172. nable the UART for sending and receiving UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx interrupt Sbi UCSRB RXCIE UART tx interrupt SIGNAL SIG UART DATA Tx buffer is empty if tx read tx write cbi UCSRB UDRIE return UDR tx buff tx read tx read tx read 1 gt TX BUFF SIZI void put char uint8 t c uint8 t tmp write 0 tx read 1 tmp write tx write 1 gt TX BUFF SIZE 0 tx write 1 Buffer is full if tmp write tx read sbi UCSRB UDRIE return tx buff tx write c tx write tmp write Wi Enable Tx interrupt to start sending sbi UCSRB UDRIE return F 16 Spring 2008 ECE 477 Final Report void put short uintl16 t s put char uint8 t s amp OxFF put char uint8 t s 8 void put_str char str uint32 t i 0 while str i char NULL put char str i itt ii Subvehicle Sensors trunk LIS3L uart h ifndef MY UART define MY UART include lt avr interrupt h gt include avr io h define TX BUFF SIZE 256 ifndef BAUD If different baud rate is desired do define BAUD BEFORE include uart h in your source define BAUD 51 9600 baud 8MHz normal speed endif ifndef sbi define sbi sfr bit SFR BYTE sfr BV bit
173. nal Report Spring 2008 else brake state STOP else if state STOP if sonar suml lt THRESHOLD sonar sum2 lt THRESHOLD sonar sum3 lt THRESHOLD brake delay ms 10 state REVERSE else hmc_transmit 0x42 0x41 brake delay ms 32 heading desired get compass state GO return 0 end main Subvehicle Sensor board trunk uart c include lt avr interrupt h gt include lt avr io h gt define BAUD 12 include uart h define NULL void 0 UART variables static volatile uint8 t tx read static volatile uint8 t tx write static volatile uint8 t tx buff TX BUFF SIZE static volatile uint8 t rx head static volatile uint8 t rx tail static volatile uint8 t rx buff TX BUFF SIZE void uart init Enable the UART for sending and receiving sbi UCSRB RXEN sbi UCSRB TXEN tx read tx write 0 Set baud rate registers UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx interrupt Sbi UCSRB RXCIE F 149 ECE 477 Final Report Spring 2008 UART rc interrupt SIGNAL SIG UART RECV uint8 t tmp head tmp head rx head 1 RX BUFF SIZE M if rx full while tmp head rx tail rx buff rx head UDR rx head tmp head uint8 t get char uint
174. nd debugging The group worked with Trent s initial vision to design the physical chassis and drivetrain modifying it where need be resulting in the final product He then went on to research the Gumstix development environment and open source libraries to aid in the the more difficult tasks of the software During the research phase Trent found the drivetrain components for OMAR from Lynxmotion motors motor mounts wheels and hubs as well as the Pololu motor contoroller He also looked into a different minicomputer also based on the Marvel Xscale microprocessor which was replaced by the Gumstix due to lacking customer support Trent helped RJ debug his sensor test code as well as with controls in the final software He helped Josh brush up on his C skills so he code hash out some code for the motor controller Lastly he helped Mike create some custom layouts for the barrel jack and I2C level translators as well as some miscellaneous layout considerations for the PCB Trent spent the majority of his time on the Gumstix software The programming started with small tests of the Gumstix ARM tool chain to get a feel for its capabilities The consensus was that it was close enough to x86 to do a majority of development on a Linux desktop system which worked well with some Makefile magic for an ARM build C was chosen to make use of the object oriented programming it provides The POSIX threads library libpthread was employed for its robustness and
175. ness printf Depth d n devicepictures devnum depth printf Palette d n devicepictures devnum palette if devicepictures devnum palette VIDEO PALETTE YUV420P printf Palette YUV 4 2 0 Planar n success int Set Picture int devnum int b int h int cl int cn int w attempt if device devnum lt 0 failure Invalid device if b gt 0 devicepictures devnum brightness b amp Oxffff if h gt 0 devicepictures devnum hue h amp Oxffff if cl gt 0 devicepictures devnum colour cl amp Oxffff if enz 0 devicepictures devnum contrast cn amp Oxffff if w gt 0 devicepictures devnum whiteness w amp Oxffff if ioctl device devnum VIDIOCSPICT amp devicepictures devnum 0 failure IOCTL Error n success int Get Window int devnum attempt F 76 ECE 477 Final Report Spring 2008 if ioctl device devnum VIDIOCGWIN amp devicewindows devnum lt 0 failure IOCTL Error n else printf Device Window n printf x y Sd d Nn devicewindows devnum x devicewindows devnum printf Width Height d d n devicewindows devnum width devicewindows devnum height y success return 0 int Get MMap int devnum int i attempt if ioctl device devnum VIDIOCGMBUF amp devicebuffers devnum lt 0 failure IOCTL ErrorMn
176. nly be used with VIDIOCPWCSANGLE VIDIOCPWCGANGLE always returns absolute angles xy struct pwc_mpt_angles int absolute write only int pan degrees 100 int tilt degress 100 int zoom N A set to 1 l Range of angles of the camera both horizontally and vertically The zoom is not used maybe in the futur Si Struct pwc mpt range int pan min pan max degrees 100 int tilt min tilt max int zoom min zoom max 1 1 l struct pwc mpt status int status int time pan int time tilt Restore user settings define VIDIOCPWCRUSER IO v 192 Save user settings define VIDIOCPWCSUSER STOUT ME 193 Restore factory settings define VIDIOCPWCFACTORY _To tv 194 Spring 2008 0 25000 0 25000 You can manipulate the compression factor A compression preference of 0 means use uncompressed modes when available 1 is low compression 2 is medium and 3 is high compression preferred Of course the higher th compression the lower the bandwidth used but more chance of artefacts F 69 ECE 477 Final Report in th th Tu Set define Get define imag The driver automatically preferred mode is not available preferred compression quality 0 VIDIOCPWCSCQUAI _ IOW preferred compression quality VIDIOCPWCGCQUAI _IOR Li Li This is a becomes di check for it
177. ntl h include unistd h include lt linux types h gt include linux videodev h include lt jpeglib h gt include od common h F 61 ECE 477 Final Report include od Camera h include otherlibs pwc ioctl h include otherlibs v4l h finclude otherlibs philipscamera h define DEF WIDTH 640 ae define DEF HEIGHT 480 define VIDEO DEV dev v41l video0 y read rgb image from v4l device return mmap ed buffer and size char get image int dev int width struct video mbuf vid buf struct video mmap vid mmap char map convmap int len int bytes 3 if ioctl dev VIDIOCGMBUF to do a normal read XJ struct video window vid win if ioctl dev VIDIOCGWIN vid win width width vid win height height if ioctl dev VIDIOCSWIN perror ioctl VIDIOCSWIN return NULL map malloc len read dev if len lt 0 free map return NULL map size 0 width height convmap map convmap malloc v4l yuv420p2rgb memcpy map convmap free convmap return map map mmap 0 vid buf size PROT R if unsigned char 1 perror mmap return NULL int height amp vid buf amp vid win amp vid win width height size t width height bytes E unsigned char map default width default height int size 1
178. o UART void put short uintl6 t s Write string of length len to UART void put str char str uint32 t len endif MY UART ii Subvehicle Sensors trunk LIS3L i2c c include lt avr interrupt h gt include lt avr io h gt include i2c h include uart h void i2c init PORTC 0x03 portO and portl internally pulled high TWSR 0 lt lt TWPS0 amp 0 lt lt TWPS1 prescalar 1 TWBR 8 F CPU 100000UL 16 2 0x02 end init int i2c transmit uint8 t addr uint8 t reg uint8 t data int status 0 if send start E return ERROR if send addr t addr return ERROR if send data reg RROR ERROR ERROR return ERROR if send data data return ERROR ERROR send stop return OK end i2c transmit addr data int8 t i2c read uint8 t addr uint8 t reg uint8 t data 0 if send start ERROR return ERROR if send addr t addr ERROR return ERROR if send data reg ERROR return ERROR if send repeat ERROR return ERROR if send addr r addr ERROR return ERROR if get nack data ERROR return ERROR data TWDR send stop F 10 Spring 2008 ECE 477 Final Report Spring 2008 return data end i2c read addr reg uint8 t i2c read accel uint8 t addr uint8 t reg intl6 t data if send_start
179. o capability devicecapabilities MAXDEVICES struct video picture devicepictures MAXDEVICES struct video window devicewindows MAXDEVICES struct video mbuf devicebuffers MAXDEVICES unsigned char videobuffers MAXDEVICES int Get Width int devnum return devicewindows devnum width int Get Height int devnum return devicewindows devnum height int Open All Devices char devname 40 struct stat devstat inti attempt for i 0 i lt MAXDEVICES i sprintf devname dev video d i if stat devname amp devstat 0 if S ISLNK devstat st mode device devcount Open Device devname F 74 ECE 477 Final Report Spring 2008 if device devcount gt 0 printf Device num d fd d name s successfully opened n devcount device devcount devname devcount if devcount gt 0 success return 0 else failure No devices openedin int Open Device char devname int dev return open devname O RDONLY int Close All Devices int a attempt for i 0 i lt devcount i if Close Device device i 0 printf Device successfully closed n else failure Error Device that was opened was not closed n success int Close Device int devhandle return close devhandle int Get_All Device Info
180. ogfile T CLogger CLogger if fp NULL log DEBUGLOG Logger closed if fp stderr fclose fp NULL int CLogger log int level const char msg struct tm timeStamp time t t char date 21 va list list if level logLevel va start list msg t time NULL timeStamp localtime st return 0 F 125 Logger failed to open s Logger started with level s Logger started with level s Spring 2008 NOTICE WARNING ERROR FATAL bool Tee Writing to stderr logfile Logging to s Logging to stderr ECE 477 Final Report strftime date 20 Y m d SH 3M S timeStamp fprintf fp 20s 8s date szLOGLEVEL level vfprintf fp msg list fputc n fp if tee amp amp fp stderr fprintf stderr 20s 8s date szLOGLEVEL level vfprintf stderr msg list fputc n stderr va_end list return 0 THEE Subvehicle OMAR trunk omar cpp include omar h include Logger h COMAR COMAR pSer NULL pCam NULL pNet NULL if pSer new CSerial this NULL LOG ERRORLOG Serial failed if pCam new CCamera this NULL LOG ERRORLOG Camera failed if pNet new CNetwork this LOG ERRORLOG Network failed COMAR COMAR if pSer delete pSer
181. onally intensive then followed by the room mapping algorithms and then lastly by the navigational controls The image processing would have to read in the image which has been determined to be at least VGA quality 640x480 and run image recognition on the images Photos will also be taken of the main walls and used in the room mapping algorithm Additionally the room mapping will have to get information regarding distances from walls as well as the rovers heading from the magnetometer and where it is relative to its starting position This all has to be complete in a limited amount of time and must process everything real time as well as send the data wireless via 802 11 or 900 MHz serial transmission back to the base station The base station does not have any computational requirements because it s only task is to receive information from OMAR For simplicity the base station will be a laptop computer ECE 477 Final Report Spring 2008 3 1 2 Interface Requirements Navigating a room avoiding obstacle will require a plethora of proximity sensors so the rover knows its surroundings There will be a total of 10 sensors that will detect the surroundings as well as its orientation In addition the drive system of the rover will need to be interfaced with the microcontroller All of the proximity and orientation sensors will also be interfaced with the microcontroller The camera as well as communication links will be interfaced with the Gumstix compute
182. onversion coefficients are scaled into 16 16 fixed point integers They were determined as follows double brightness 1 0 0 black 1 gt full scale double saturation 1 0 O gt greyscale 1 gt full color double fixScale brightness 256 256 ei int rvScale int 1 402 saturation fixScale int guScale int 0 344136 saturation fixScale int gvScale int 0 714136 saturation fixScale int buScale int 1 772 saturation fixScale int yScale int fixScale E LIMIT convert a 16 16 fixed point value to a byte with clipping define LIMIT x x Oxffffff O0xff x lt 0xffff 0 x gt gt 16 x static inline void v4l copy 420 block int yTL int yTR int yBL int yBR int u int v int rowPixels unsigned char rgb int bits const int rvScale 91881 const int guScale 22553 const int gvScale 46801 const int buScale 116129 const int yScale 65536 Intcr dy bi g guScale u gvScale v r rvScale v b buScale u yTL yScale yTR yScale yBL yScale yBR yScale if bits 24 Write out top two pixels rgb 0 LIMIT b yTL rgb 1 LIMIT g yTL rgb 2 LIMIT r yTL rgb 3 LIMIT btyTR rgb 4 LIMIT g yTR rgb 5 LIMIT r yTR Skip down to next line to write out bottom two pixels rgb 3 rowPixels
183. or start sent while TWCR amp 1 TWINT wait for TWINT flag set indicates start sent check start sent correct if TWSR amp OxF8 START return ERROR put str START ERRORWMn Nr return OK end send start k send addr t uint8 e addr KCKCkck ck ck ck ckckckok ck kk ke ke e e e x amp f int send addr t uint8 t addr char s 25 send addr TWDR addr TWCR 0 1 lt lt TWINT 1 lt lt TWEN clear TWINT to start transmission of addresss wait for ACK while TWCR amp 1 lt lt TWINT e put str send addr t while loop n r wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MT SLA ACK return ERROR return OK end send addr KRKKKK send addr r uint8 t addr KCKCkck ck ck ck ckck I e e x amp f int send addr r uint8 t addr send addr TWDR addr 0x01 TWCR 0 1 lt lt TWINT 1 lt lt TWEN 1 lt lt TWEA clear TWINT to start transmission of addresss send ACK wait for ACK while TWCR amp 1 lt lt TWINT wait for TWINT set indicates Slave addr sent and ACK received check status slave sent ack received if TWSR amp OxF8 TW MR SLA ACK return ERROR put_str ADDR SENT ERROR WnNr return OK end send addr KKK RK KK KK AKA
184. ork initialize static void networkThread void arg public CNetwork COMAR Parent NULL CNetwork bool operator n endif NETWORK H k Subvehicle OMAR trunk client client c include stdio h include stdlib h include sys socket h include sys stat h include sys select h include netinet in h include unistd h include lt netdb h gt include string h include errno h void usage const char prgnam printf usage s host port n prgnam int main int argc char argv int size port sockfd char host buffer 128 char addrlist struct sockaddr in addr struct hostent server F 108 Spring 2008 ECE 477 Final Report if argo 3 usage argv 0 return 1 host argv 1 port atoi argv 2 if port lt 0 port gt 65535 printf error port out of range 0 65535 n return 1 if sockfd printf error return 1 socket AF_INET SOCK STREAM IPPROTO TCP failed to allocate socket n if gethostbyname host NULL s n host server printf Failed to get host s return 1 strerror Spring 2008 bt errno if 0 printf sinaka server gt h name addrlist server gt h aliases size 0 while addrlist size NULL printf s addrlist sizett printf NXnaddr type dNnh length d n addrlist
185. ort Spring 2008 while timer cnt 2 for i 0 i 2 i delay ms 32 get accel 0x3A accel data snprintf s 100 timer cnt 4u timer 5u SonarE0 5u SonarE4 5u SonarE6 5uNr timer cnt TCNTIH lt lt 8 TCNTIL get compass 0x42 get sonar OxEO get sonar 0xE4 get sonar 0xE6 put str s if get sonar 0xE6 lt 278 brake turn left for j 0 j 32 j delay ms 32 brake go reverse brake timer stop put str XnDone XnXr go forward for i 0 i lt 63 i delay ms 32 delay for 5 seconds brake for i 0 i lt 32 i delay ms 32 delay for 1 seconds go reverse for i 0 i 63 i44 delay ms 32 delay for 5 seconds brake for i 0 i lt 32 i delay ms 32 delay for 1 seconds turn left for i 0 1 lt 63 i delay ms 32 delay for 2 seconds brake for i 0 i lt 32 1i delay ms 32 delay for 1 seconds turn right for i 0 i 63 i44 y brake delay ms 32 delay for 2 seconds return 0 k Subvehicle Motorcontroller uart c include avr interrupt h include avr io h define BAUD 12 include uart h define NULL void 0 F 50 ECE 477 Final Report Spring 2008 UART variables static volatile uint8 t tx read static volatile uint8 t tx write static volatile uint8 t tx buff TX BUFF SIZE void uart init
186. p vid mmap frame 1 perror VIDIOCSYNC E munmap map vid buf size map NULL if map NULL size vid_buf size if convmap char malloc C width C height C depth NULL v4l yuv420p2rgb unsigned char convmap unsigned char map C width C height C depth 8 memcpy map convmap size t C width C height C depth free convmap gettimeofday amp stop NULL OG DEBUGLOG Cam loop took fs float stop tv sec start tv sec float stop tv usec start tv usec 1000000 LOG INFOLOG Camera snapped image ifdef DEBUG sprintf fn tmp test d jpg i i 2 4 if fp fopen fn w NULL put image jpeg fp map C width C height 100 VIDEO PALETTE YUV420P fclose fp else LOG DEBUGLOG Failed to write image fendif convmap NULL else LOG ERRORLOG Failed to capture image usleep 1000000 CAM FRAMERATE CAM DELAY CAM FRAMERATE pthread mutex lock amp C state lock pthread mutex unlock amp C state lock if map NULL munmap map vid_buf size map NULL pthread_exit NULL F 130 ECE 477 Final Report bool CCamera operator bool ret true pthread mutex lock amp state lock if state CAM OPEN ret false pthread mutex unlock amp state lock return ret if DEBUG void put image jpeg FILE
187. p wfds sd sd amp rfds amp wfds ust be don Wait for upto 10ms for serial data selectRetVa if selectR l select pSer sd Someth tVal 1 ing bad happened LOG FATALLOG Something terrible has happened to the serial connection errno pthread mu pSer serial close pthread mutex lock amp pSer state lock ls if selectRetVal 10ms has expired 0 log timeoutCnt if timeoutCnt LOG WARNINGLOG 500 timeoutCnt 100 else We have serial data timeoutCnt 0 Read read pSer sd buf 100 LOG NOTICELOG Got some serial data Sain amp rfds amp wfds tex unlock amp pSer state lock this if it happens for too long pthread mutex lock amp pSer state lock pthread mutex unlock amp pSer state lock F 112 befor NULL ach call to select amp timeout sd 1s No activity on serial port in last us buf Spring 2008 ECE 477 Final Report pthread exit NULL int CSerial serial initialize int ret Try to open port ret serial open if ret SERIAL OK return ret Failed to open port Try to start service thread ret pthread create amp thread id NULL serialThread void this if ret 0 Failed to start thread LOG DEBUGLOG Failed to create serial helper thread serial close
188. p without actually driving and just testing the values received from the PD loop After testing was done along with playing with the gains of the loop the magnetometer died and was left out of the design because of time constraints Josh then started to help out with the state machine for the main loop for the microcontroller RJ broke off from doing this and started to work on the image processing aspect of the project OMAR at this point was detecting objects fairly well except for chair and table legs as well as walls when it approached them at a certain angle The sonar sensors were repositioned and thresholds were changed to fix this problem A 2 ECE 477 Final Report Spring 2008 A 3 Contributions of Trent Nelson Trent Nelson s voluntary responsibility was software in particular the software for the Gumstix minicomputer The team decided early on that the Gumstix software need to as real time as possible which meant excessive threading More requirements came to follow including TCP network communication with the base station serial communication with the microcontroller and USB communication with a webcam Trent had the most experience in these areas so it made sense that he take responsibility for this aspect of the project Though this was his main focus he also helped out with the other aspects including overall conceptualization and design debugging software for the microcontroller debugging PCB design mechanical design a
189. pe that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program if not write to the Free Software Foundation Inc 675 Mass Ave Cambridge MA 02139 USA x X AX X X F F F Xo X F Ro Ro X X F ox ifndef VAL H define V4LH define INPUT DEFAULT zh define NORM DEFAULT 1 ifndef TRU define TRU endif Ej n F 118 ECE 477 Final Report ifndef FALSI ij uH define FALSE 0 fendif int v4l set input int fd int input int norm int v4l check size int fd int width int height int v4l check palette int fd int palette int v4l mute sound int fd int v4l check mmap int fd int size int v4l yuv420p2rgb unsigned char unsigned char int int int int v4l yuv422p2rgb unsigned char unsigned char int int int fendif kb Subvehicle OMAR trunk v4l v4l c v4l c Copyright C 2001 Rasca Berlin This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This program is distributed in the hope that it will be useful but WI
190. pid P D prev heading error heading error timestamp prev timestamp return pid k Subvehicle Motorcontroller MControl h ifndef MControl h define MControl h include lt avr interrupt h gt include avr io h include util delay h void go forward void go reverse void turn left void turn right void brake uintl6 t update PID uint16 t heading desired fendif kb Subvehicle Motorcontroller i2c c include lt avr interrupt h gt include lt avr io h gt F 43 Spring 2008 ECE 477 Final Report Spring 2008 include i2c h include uart h define nop delay us 10 void i2c init PORTC 0x03 port0 and portl internally pulled high TWSR 0 lt lt TWPSO amp 0 lt lt TWPS1 prescalar 1 default 0 TWBR 8 F CPU 100000UL 16 2 0x02 2 with prescalar 1 should 100kHz hmc transmit 0x42 0x57 i2c transmit 0x3A 0x20 0xB7 end init uint16 t get compass uint8 t addr uint8 t check 0 check hmc transmit addr 0x41 delay ms 7 return hmc read addr void get accel uint8 t addr uintl6 t data data 0 i2c read addr 0x28 nop data 0 i2c read addr 0x29 lt lt 8 nop data 1 i2c read addr 0x24 nop data 1 i2c read addr 0x2B lt lt 8 nop data 2 i2c read addr 0x2C nop data 2 i2c read addr 0x2D lt lt 8
191. pt h include avr io h include i2c h include uart h define nop delay us 10 void i2c init PORTC 0x03 port0 and portl internally pulled high TWSR 0 lt lt TWPSO amp 0 lt lt TWPS1 prescalar 1 default 0 TWBR 8 F CPU 100000UL 16 2 0x02 2 with prescalar 1 should hmc transmit 0x42 0x57 i2c transmit 0x3A 0x20 0xB7 end init void send acguire hmc transmit 0x42 0x41 ADCSRA 1 lt lt ADSC uintl6 t get compass return hmc read 0x42 void get accel uint8 t addr uintl6 t data data 0 i2c read addr 0x28 nop data 0 i2c read addr 0x29 lt lt 8 nop data 1 i2c read addr 0x24 F 140 100kHz ECE 477 Final Report nop data 1 i2c read ad nop data 2 i2c read add nop data 2 i2c read ad uint8 t get sonar uint8 i2c transmit addr delay us 70 return i2c read addr dr 0x2B lt lt 8 fr 0x2C ys dr 0x2D lt lt 8 t addr 0 0x51 3 uint8 t i2c transmit uint8 t addr uint8 t reg uint8 t data if send_start ERROR send_stop return ERROR if send addr t addr send stop return ERROR if send data reg send stop return ERROR if send data data send stop return ERROR send stop return OK end i2c transmit addr uint8 t i2c read uint8 t
192. r Each of the sensors will require different interfacing needs and are summarized in Table 1 Note that some sensors such as the camera will be interfaced directly to the embedded computer while the sensors and motor controllers will all be interfaced to the computer through the microprocessor Table 1 Interface Requirements uC CPU Usage Requirement Pins Pins Notes Poll 4 M Sensors 4x ADC 4 0 10bit precision Poll 4 SONAR Range Sensors 6x C o gt 0 4 5 Poll 1 Digital Compass 6 1x FC 0 Poll 1 3 Axis Accelerometer 7 1x C 0 Dryer aM Brage Motor 2x PWM 2 0 At least 8bit precision controllers 8 Position 1 360dg RC Servo 9 1x PWM 1 0 At least 10bit precision 1Mbaud May require external xtal to be stable Also may need RS232 to Comm between uC and CPU 1x USART 2 2 TTL level shift via MAX333 if TTL can t be tapped from Gumstix Provided by Gumstix Camera 1x USB 0 2 CPU 1x 10 100 Proprietary Gumstix pepHg Development Ethernet g E breakout interface Comes attached to Wireless comms to base station 1x 802 11b g 0 92 ethernet module Total 15 11 214 12C pins counted only once since they re shared ECE 477 Final Report Spring 2008 3 1 3 On Chip Peripheral Requirements All of the sensors needed for room mapping and autonomous navigation have different means of communicating with the microcontroller There will be four inferred sensors two long range and two short range
193. r failure would be the pushbutton failing This could be caused by any object hit it and causing it to get stuck pressed down It would affect the microcontroller because it would cause it to shutdown and go into reset mode This would be a medium criticality since OMAR would again not accomplish its task The FMECA table for this subsystem can be found in appendix A table A 3 The fourth and final subsystem is the sensor subsystem The magnetometer could fail because of either improper VCC or magnetic interference This would cause the compass heading to be incorrect and OMAR would not drive straight or turn properly This would be a low criticality since it could still finish its objective even though it may not drive straight or efficiently The next failure would be the sonar failing The sonar could fail do to noise caused on the 40kHz spectrum This would cause OMAR to not detect objects High criticality would be assumed since OMAR may run into objects causing possible batter explosion and fire Next the accelerometer may fail This could be cause by improper VCC It would cause the room mapping data to be incorrect as the accelerometer data is used in the SLAM algorithm Since the image recognition objective could still be accomplished this would be a low criticality The last and final possible failure would be if the IR sensors failed It could be caused by ambient light noise 17 ECE 477 Final Report Spring 2008 or improper VCC The roo
194. r the UART The Accelerometer will aid in knowing how far we have moved and is essential for the SLAM algorithm The Sonar sensors will be used for object avoidance The IR sensors will be used for room mapping and is also essential for the SLAM algorithm The only thing that is left to be done is that each of the sonar devices needs to have a different address so we will have to change the addresses of 3 of our sonar devices 11 0 Version 2 Changes Looking back on this project there are a few changes that would have been made if a second chance was given The first thing to change would be to make the frame more robust in order to withstand being launched from the helicopter The frame would also be modified so that is was a closed shell of some sort to make it more stable to protect the sensors and to make it more aesthetically pleasing The IR sensors were not very reliable and did seem to provide accurate data Instead an expensive laser scanner sonar sensors or a much more improved ADC noise canceling circuit would be used A switching power supply would be used as it is more reliable Also a regulator that can supply higher currents would be used as the Gumstix seems to draw much more current than expected Along those lines a battery charging circuit would be very beneficial so the battery does not have to be unplugged to be charged The solutions for implementing SLAM were to computationally intensive so alternate solutions would be pu
195. re Foundation either version 2 of the License or at your option any later version PhilipsWebCamLib is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of X X F F F F F HF X tH F 71 Spring 2008 PhilipsWebCamLib is free software you can redistribute it and or modify ECE 477 Final Report Spring 2008 X X F F X X X Ro Ro F F X ox s in in in in in in in in in in in in in in in in in in in in in in Gh CE AGE oct cC cb ck ch CFE EE CT Ck eT CE CU CF CE T EFC CE ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the NU General Public License for more details Qs You should have received a copy of the GNU General Public License along with PhilipsWebCamLib if not write to the Free Software Foundation Inc 59 Temple Place Suite 330 Boston MA 02111 1307 USA PhilipsWebCamLib Version 1 2 0 Release Date 1 04 Author Derrick Parkhurst Copyright c 2004 Derrick Parkhurst lt derrick parkhurst jhu edu gt All Rights Reserved Open All Devices Open Device char devname Close All Devices Close Device int devhandle Get_All Device Info Get Capabilities int devnum Get Picture int devnum Set Picture int devnum int b int h Lit cH int cn int w Get Window int devnum Get MMap int devnum Activate MMap int devnum Deactivate MMap int devnum
196. re in their claims that are different from this project however those parts are a small part of the whole The first patent number 6515614 discussed having a scan and non scan type sensor OMAR has both an IR for scanning and sonar for non scanning The patent had a detection unit that takes in the sensors data and determines the position of the obstacle and a controller for moving the apparatus This is also on OMAR because the microcontroller takes in the sensors data and the embedded computer uses that data to determine the position of the obstacle The computer then sends signals to the microcontroller to move the wheels As one can see OMAR and the claim from the patent are similar and that literal infringement exists 12 ECE 477 Final Report Spring 2008 The second patent number 5170352 had a lot of components including three subsystems that worked together The machine vision subsystem received the sensor signals the controller subsystem took in input signals and the navigational subsystem did everything else The navigational subsystem took in signals from the other two subsystems and then plotted a map and path for the vehicle It also continuously monitored signals from the machine vision to determine moving and still obstacles OMAR covers almost this entire design but in a slightly different way The project only has two subsystems the microcontroller and the embedded computer The microcontroller takes in the sensors data
197. reduce noise on the power lines and since they are small enough to be surface mounts they can go on the back of the board under the microcontroller 25 Also to avoid any disturbance on the ADC inputs power traces and other components will not be placed near those lines One of the most critical traces going into the microcontroller for the reset pin so the trace will be placed so that little noise and interference could cause it to jump causing the microcontroller to behave erratically 25 Also the reset pin has a resistor and a pushbutton that stabilizes that trace and pin 9 2 PCB Layout Design Considerations Power Supply To provide the right amount of voltage and enough current to all parts on and off the PCB three regulators will be used to provide two 5 0 V rails and one 3 3 V rail The reason behind utilizing three regulators is to be able to meet the requirements for the current draw Almost every component in the design ranging from the embedded computer microcontroller motors and to almost all the sensors run on 5 0 volts while the accelerometer and magnetometer run on 3 3 volts The reason for two sources of 5 0 volts was to split up everything on the board and the motors from the embedded computer The embedded computer will also use a USB connection for a camera and a wireless connection which in this case causes this part of the circuit to require more than 3 0 amps of current The regulator for the embedded computer w
198. ref 1 void Set Automatic White Balance Mode int devnum char mode struct pwc whitebalance pwcwb if ioctl device devnum VIDIOCPWCGAWB amp pwcwb 1 error exit VIDIOCPWCGAWB if strcasecmp mode auto 0 pwcwb mode PWC WB AUTO else if strcasecmp mode manual 0 pwcwb mode PWC WB MANUAL else if strcasecmp mode indoor 0 pwcwb mode PWC WB INDOOR else if strcasecmp mode outdoor 0 pwcwb mode PWC WB OUTDOOR else if strcasecmp mode fl 0 pwcwb mode PWC WB FL else fprintf stderr s is not a known white balance mode Wn exit 1 if ioctl device devnum VIDIOCPWCSAWB amp pwcwb 1 error exit VIDIOCPWCSAWB void Set Automatic White Balance Mode Red int devnum int val struct pwc whitebalance pwcwb if ioctl device devnum VIDIOCPWCGAWB amp pwcwb 1 error exit VIDIOCPWCGAWB pwcwb manual red val if ioctl device devnum VIDIOCPWCSAWB amp pwcwb 1 error exit VIDIOCPWCSAWB void Set Automatic White Balance Mode Blue int devnum int val struct pwc whitebalance pwcwb if ioctl device devnum VIDIOCPWCGAWB amp pwcwb 1 error exit VIDIOCPWCGAWB pwcwb manual blue val if ioctl device devnum VIDIOCPWCSAWB amp pwcwb 1 error exit VIDIOCPWCSAWB void Set Automatic White Balance Speed int devnum int val struct pwc wb speed pwcwbs F 86 Sp
199. returns probe function the enhanced Philips stuff Tat fest Since so many devices are supported fficult to include all the names in programs that want So in stead a structure with the original name Spring 2008 chooses a higher compression when uncompressed 195 int 3 highest compression 195 int qe to try this PROBE and the corresponding Philips type To use fill the structure with zeroes call PROBE and if that succeeds compare the name with that returned from VIDIOCGCAP they should be the same If so you can be assured it is a Philips OEM cam and the type is valid Ef define VIDIOCPWCPROBE _IOR v 199 struct pwc_probe Set AGC Automatic Gain Control int lt 0 auto 0 65535 fixed define VIDIOCPWCSAGC _IOW v 200 int Get AGC int lt 0 auto gt 0 fixed range 0 65535 define VIDIOCPWCGAGC IOR v 200 int Set shutter speed int lt 0 auto gt 0 fixed range 0 65535 define VIDIOCPWCSSHUTTER IOW v 201 int Color compensation Auto White Balance define VIDIOCPWCSAWB IOW v 202 struct pwc whitebalance define VIDIOCPWCGAWB IOR v 202 struct pwc whitebalance Auto WB speed define VIDIOCPWCSAWBSPEED IOW v 203 struct pwc wb speed define VIDIOCPWCGAWBSPEED IOR v 203 struct pwc wb speed
200. ring 2008 mode ECE 477 Final Report if ioctl device devnum VIDIOCPWCGAWBSPEED amp pwcwbs 1 error exit VIDIOCPWCGAWBSPEED pwcwbs control speed val if ioctl device devnum VIDIOCPWCSAWBSPEED amp pwcwbs 1 error exit VIDIOCPWCSAWBSPEED void Set Automatic White Balance Delay int devnum int val struct pwc wb speed pwcwbs if ioctl device devnum VIDIOCPWCGAWBSPEED amp pwcwbs 1 error exit VIDIOCPWCGAWBSPEED pwcwbs control delay val if ioctl device devnum VIDIOCPWCSAWBSPEED amp pwcwbs 1 error exit VIDIOCPWCSAWBSPEED void Set LED On Time int devnum int val struct pwc_leds pwcl if ioctl device devnum VIDIOCPWCGLED amp pwcl 1 error exit VIDIOCPWCGLED pwcl led on val if ioctl device devnum VIDIOCPWCSLED amp pwcl 1 error exit VIDIOCPWCSLED void Set_LED Off Time int devnum int val struct pwc_leds pwcl if ioctl device devnum VIDIOCPWCGLED amp pwcl 1 error exit VIDIOCPWCGLED pwcl led off val if ioctl device devnum VIDIOCPWCSLED amp pwcl 1 error exit VIDIOCPWCSLED void Set Sharpness int devnum int val if ioctl device devnum VIDIOCPWCSCONTOUR amp val 1 error exit VIDIOCPWCSCONTOUR void Set Backl
201. ring 2008 VBat NA V5 0 LDO1 MIC29300 5 0BT k R1 10k V3 3 LDO1 MIC29150 3 3BT n Figure C 1 Power Schematic ECE 477 Final Report Spring 2008 Save document vso NA vso vso u fuv 6 olrc ontrollerz Mokrcontotlert HEADER 10 Tok Pc2 TM PCS TDO PCs TDb PCS TOSt L PCG TOSC2 PCT xTAL2 AVCC XTALI AREF RxD PDO TxD PDI ADCT auTO PDD ADCS PAG ANTH PDS ADCS PAS 3 IPdongi2 OC 1B PDs ADC 4 PAS OCIA PDS ADC3 PAS CEP 1 PDS ADC2 PAD ABCD ADC Qe KTO mi IRahorbi xb Pco AINOTINTZ Rehat PropBADER 4 77 o HEADER 5x2 1 Ces Gum tet HEADER OCD POT ccelerome leri HEADER HEADER 3 GIA PCI Moca an Moab Moo maw Bona i 2 HEADER 4 Magne tome kri HEADER A T ATMEGA 32 n A HEADER Sonar HEADER Figure C 2 ATmega32 Schematic ECE 477 Final Report Spring 2008 Appendix D PCB Layout Top and Bottom Copper MOTORCONTROLLERI 3 3 LDD1 IFERITEELTIE m Tu V GROUP 8 PCB2 Figure D 2 Bottom of PCB D 1 ECE 477 Final Report Spring 2008 Appendix E Parts List Spreadsheet Table E 1 Parts List Spreadsheet Vendor Manufacturer Part No Description Unit Cost Qt Total Cost X Mouser Atmel Atmega32 MicroController 6 40 1 6 40 Acroname Devantech SRF02 Sensor Sonar wi
202. rivative portion of controller 2008 04 04 73 nelson11 added Changelog generation script 2008 04 04 72 nelson11 Changed Wait forever just for testing 2008 04 04 71 nelson11 Added Network class 2008 04 04 70 nelson11 Added Basic support for network service 2008 04 04 69 rtoepfer modified attempted to change the code so that the get data command could be called and later read the data Works for all devices except the sonar for some unkown reason Sonar will not communicate in this fashion Delays were added but did not change anything 2008 04 04 68 rtoepfer added timer h added to test the noise coming from the servo 2008 04 04 67 nelson11 added Basic definition of network class 2008 04 04 66 nelson11 fixed Allocate buffers on initialization instead of statically Saves stack space 2008 04 04 65 nelson11 fixed typo and missing include 2008 04 04 64 nelson11 changed arm target binary is now named omar arm 2008 04 03 63 rtoepfer modified changed main to read the IR sensors and the makefile to use the sstk500 board for programing change to v2 for the avrisp 2008 04 03 62 rtoepfer added initial add of adc code to main loop 2008 04 02 61 nelson11 fixed build run commands should work in kdevelop now 2008 04 02 60 nelson11 changed Mostly cosmetic 2008 04 02 59 nelson11 fixed NULL member pointers in constructor 2008 04 01 58 rtoepfer added initial check in of main Sensor board code Currently reads Magnetometer acce
203. rsued 32 ECE 477 Final Report Spring 2008 Finally the internals of OMAR are very hard to connect and fit everything together nice and compact so a better method of cable management and part placement might be considered 12 0 Summary and Conclusions This entire project has been a huge accomplishment for all of us This is the first time most of us have ever had to deal with a project that consisted of both analog and digital hardware as well as software There are no clear guidelines on how to accomplish the tasks you have to research and read up on how to get it done We were able to successfully take a popular hobby microcontroller and exploit almost all of its interfaces We were able to interface with various sensors given little documentation This was also our first time working in a real time environment so our Gumstix code was heavily threaded Two PCBs were made where the latter of the two had better noise suppression and was successfully implemented in the design Throughout this entire project a lot of lessons have been learned The I2C bus is heavily dependent on timing and delays It was learned that one must take care in making sure that the delays and timing are setup properly Sonar devices are only accurate if the object it is facing is square with the sensor otherwise the sound waves bounce off in the wrong direction The microcontroller can be locked if you are not careful when setting the fuse bits which was experience
204. ry light weight and small Appendix A contains 3 3 D drawings of OMAR For OMARs drive system the 4 wheel design will be used The left and right sides will be controlled independently so that OMAR can rotate 360 On the front of OMAR 2 or 3 Devantech SRF02 5 sonar sensors will be mounted at either 45 or 60 apart The PCB and Gumstix 10 embedded computer will be place in the middle between the sheets of plastic On top the R298 1T 9 servo will be mounted On the front and back face of the servo will sit the Sharp IR 2 range finders The reason they will be mounted on the servo is so that OMAR can scan an area of 360 In order to help eliminate the IR range finders minimum distance the servo will be mounted in the middle of the vehicle The body will consist of two sheets of lexan 21 The motors will be packaged between the 2 sheets of plastic with dimensions 10cm wide x 20cm x 10cm These measurements were estimated by observing how big the helicopter is and how much room can be used to store OMAR on its landing gear Foam tires motors motor mounts and mounting hubs from Lynxmotion 22 will be used The camera will also be place on top of the servo so that OMAR can rotate the camera if needed to take pictures in tight situations The battery will sit on top of the vehicle located in the back Finally the wireless card will be placed on top between the sonar sensors and the servo 7 3 PCB Footprint Layout The PCB footprint is sho
205. se range lt lt 8 range i2c read 0xE4 3 snprintf s 25 Nrd 4ucm put_str s if i2c_error range ERROR put_str ERROR n r send_stop continue DA snprintf s put str s 100 Nrsonarl 3d sonar2 3d sonar3 3d return 0 end main ihr Subvehicle Sensors trunk srf02 uart c F 23 range rangel Spring 2008 range2 ECE 477 Final Report include lt avr interrupt h gt include lt avr io h gt define BAUD 12 include uart h define NULL static vola static vola static vola voi d 0 UART variables void uart init sbi sbi GER UCSRB RXEN UCSRB TXEN read tx wr ite 0 tile uint8 t tx read tile uint8 t tx write tile uint8 t tx buff TX BUFF SIZE Enable the UART for sending and receiving Set baud rate registers UBRRH UBRRL Enable Rx in uintl16 t BAUD uint16 t BAUD terrupt sbi UCSRB RXCIE UART tx interrupt SIGNAI G L SIG UART DATA if tx read tx write cbi UCSRB UDRIE ies UDR CS eturn tx buff tx read read tx read 1 gt TX BUFF SIZI void put char uint8 t c uint8 t tmp write tmp if sbi UCSRB Buffer is fu write tx write 1 gt TX BUFF SIZE 0 Lt amp Oxff00 amp Oxff
206. specification to note is that the Pioneer 3 AT 19 encloses 8 sonar sensors mounted directly to the front bumper of the base The placement of this design seems optimal but the amount of sensors seems excessive After researching sonar sensors object detection and avoidance can easily be accomplished by mounted only 2 or 3 sensors on the front at 45 or 60 respectively The last main design specification on the Pioneer 3 AT 19 is the drive system This robot uses a 4 wheel design This system is cheap and light weight and is very easy to use OMAR will copy the 4 wheel design 22 ECE 477 Final Report Spring 2008 7 1 3 iRobot PackBot IRobot 20 offers many UGV s on there website The PackBot 20 is a standard UGV that can come with many different kits that can perform bomb detection visual reconnaissance room mapping and even sniper detection The kit that most closely meets OMARs intended application is the PackBot 20 with the room mapping kit This robot is sometimes used in the classroom or for research but it is mostly used in the Ee Rack Bot wath mening Kay military as are the rest of their robots This PackBot 20 is capable of room mapping visual reconnaissance object detection and avoidance autonomous navigation and it can even climb stairs It is very tightly packed sitting at 20 cm wide x 35cm long x 8 cm tall The problem with this design is that it weighs 42 pounds It is heavy but it is smaller and extremely
207. status MR DATA NACK if TWSR amp OxF8 TW MR DATA ACK return ERROR put str DATA REC ERROR An Nr return OK HHt t t Subvehicle Sensors trunk HMC6352 main c include lt avr interrupt h gt include avr io h define F CPU 800000UL include i2c h include uart h int main char s 25 uintl6 t range 0 init uart and i2c uart init 126 iuit sei hmc transmit 0x42 0x57 delay ms 10 while 1 delay ms 10000 delay ms 100000 if hmc transmit 0x42 0x41 ERROR delay ms 100 if range hmc read 0x42 ERROR send stop Jelse send stop F 33 ECE 477 Final Report Spring 2008 snprintf s 25 d 4d deg r range put str s return 0 end main Ht tt Subvehicle Sensors trunk HMC6352 uart c include lt avr interrupt h gt include lt avr io h gt define BAUD 12 include uart h define NULL void 0 UART variables static volatile uint8 t tx read static volatile uint8 t tx write static volatile uint8 t tx buff TX BUFF SIZE void uart init Enable the UART for sending and receiving sbi UCSRB RXEN sbi UCSRB TXEN tx read tx write 0 Set baud rate registers UBRRH uint16 t BAUD amp Oxff00 gt gt 8 UBRRL uintl16 t BAUD amp Oxff Enable Rx interrupt Sbi UCSRB RXCIE
208. stix computer 10 With regards to the Gumstix computer it too will use a serial interface as well as a USB to communicate with a camera and a wireless interface that will relay information it gathers back to a base station 9 0 PCB Layout Design Considerations The main components taken into consideration during the design of the PCB are the microcontroller and interfaces to the sensors embedded computer and motor controller Most of the projects components come prepackaged like the sensors and motor controller The distance and proximity sensors need to be placed strategically in order to take reliable data The orientation sensors need also need to be placed off the PCB so they don t have to be calibrated every time they re used The motor controller will be placed near the motors and doesn t need to be on the PCB The last part is the embedded computer which is also off board since there isn t a way to connect it to the PCB At the same time having that with the camera and wireless link will take up a lot of room and doesn t need to be on the board Since all of those pieces are already designed and on boards already the PCB just needs headers to connect those components to the microcontroller The board can be broken up to sections covering power digital and analog These three sections need to be separated in order to minimize EMI throughout the board 25 The power section covers the regulators that convert the incoming battery voltage
209. t 0 0 current contours while current result cvApproxPoly current sizeof CvContour contour storage CV POLY APPROX DP cvContourPerimeter current 0 010 0 cout lt lt Sequence Total lt lt result gt total lt lt endl CvPoint data CvPoint result gt first gt data for int j 0 j lt result gt total j cout lt lt data j x lt lt lt lt data j y lt lt endl Ep uu cvDrawContours final result CV RGB 2 0 0 1 8 cvPoint 0 0 brShowWindows source final cvWaitKey 0 0 255 V OV RGB 255 0 0 current current gt h next 1 Memory Cleanup cvReleaseMemStorage amp contour storage cvReleaseMemStorage amp line storage cvReleaseMemStorage amp fline storage cvReleaseImage amp tmpl cvReleaselmage amp tmp2 cvReleaseImage amp tmp3 cvReleaseImage amp tmp4 free corners return final odAnalyzelImage int odAnalyzeLines CvSeq lines od DB db int 1 CvPoint line od Object current for i 0 i lt lines gt total i line CvPoint cvGetSeqElem lines i current db gt objects while current if current gt next NULL break current current gt next otherwise insert as a new object
210. t 5 amp 0x07 LIMIT r yTR amp OxF8 convert a YUV420P to a rgb image yf int v4l yuv420p2rgb unsigned char rgb out unsigned char yuv in int width int height int bits const int numpix width height const unsigned int bytes bits gt gt 3 int h w y00 wl y10 yll u v unsigned char pY yuv in F 92 ECE 477 Final Report bits unsigned char pU pY numpix unsigned char pV pU numpix 4 unsigned char pOut rgb out if rgb out yuv in return 1 for h 0 h lt height 2 h 2 for w 0 w lt width 2 w 2 y00 pY yOl pY 1 yl0 pY width yll pY width 1 u pU 128 v pV 128 v4l copy 420 block y00 y01 y10 vil pY 2 pout bytes lt lt 1 pY width pOut width bytes return 0 convert a YUV422P to a rgb image SJ int v4l yuv422p2rgb unsigned char rgb out unsigned char yuv in int width int height int bits const int numpix width height const unsigned int bytes bits gt gt 3 int h w y00 y01 u v unsigned char pY yuv in unsigned char pU pY numpix unsigned char pV pU numpix 2 unsigned char pOut rgb out if rgb out yuv in return 1 for h 0 h lt height h 1 for w 0 w lt width 2 w 2 yOO pY yOl pY 1 ka e 12
211. t h gt include avr io h F 25 Spring 2008 ECE 477 Final Report include stdio h include util twi h define F CPU 800000UL include util delay h define START ERROR 2 define ADDR SENT ERROR 3 define DATA SENT ERROR 4 define ADDR REC ERROR 5 define DATA REC ERROR 6 define DATA NACK REC ERROR 7 define SENT OK 8 define OK 0 define ERROR OxFF define START 0x08 extern uint8 t i2c error void i2c init int srf change addr uint8 t curr addr uint8 t new addr uint8 t srf read uint8 t addr int i2c transmit uint8 t addr uint8 t data uint8 t i2c read uint8 t addr uint8 t reg int send repeat int send start void send stop int send addr t uint8 t addr int send addr r uint8 t addr int send data uint8 t data int get data endif I2C H ii Subvehicle Sensors trunk GP2Y0A2 adc h ifndef MY ADC define MY ADC include lt avr interrupt h gt include lt avr io h gt void adc init uintl6 t read adc endif MY ADC THEE Subvehicle Sensors trunk GP2Y0A2 main c include avr io h include lt avr interrupt h gt include stdlib h include stdio h include string h include lt avr delay h gt include uart h include adc h int main uintli6 t i a 10 size 0 p 0 sum char c 10 memset void c 0 10 F 26 Spring 2008 ECE 477 F
212. t of the patent is for an autonomous vehicle to operate in a predetermined work area while avoiding both fixed and moving obstacles In order for it to accomplish that it needs a plurality of laser sonar and optical sensor to detect targets and obstacles It then provides signals to processors and controllers which direct the vehicle through a route to a target while avoiding any obstacles The first claim for this patent is lengthy and covers a lot of the design for the described vehicle The claim starts with a vehicle comprised of a body member wheels means for propelling and steering the body and sensors mounted on body Then it describes three subsystems of the overall design The first is a machine vision subsystem for receiving the sensor signals and interpreting the signals Next a main controller subsystem for receiving input signals The last one is a navigational subsystem This subsystem is comprised of a means of receiving input signals from the main controller and machine vision subsystems and then using those signals to plot a map of the area and a path to a destination It also sends control signals to control the propelling and steering for the body It then continuously monitors the signals from the machine vision to determine if an object is in the way or moving 4 2 Analysis of Patent Liability From the three patents listed and discussed above OMAR has literal infringement on all of them Two of the three only have one featu
213. t running void sigint int sig running 0 int main COMAR pO new COMAR running 1 while running Signal SIGINT sigint sleep 1 delete pO return 0 dibi Subvehicle OMAR trunk Logger h ifndef LOGG define LOGG ER H ER H include lt stdio h gt define LOG g Logger log typedef enum DEBUGLOG INFOLOG NOTICELOG WARNINGLOG ERRORLOG FATALLOG NONELOG jOGLEVEL class CLogger private FILE fp int logLevel F 110 ECE 477 Final Report bool tee public CLogger int level INFO CLogger int level INFOLOG const CLogger int Close inline void setLogLevel int level inline int getLogLevel return int log int level const char msg l extern CLogger g Logger endif LOGGER H ii Subvehicle OMAR trunk serial cpp include lt string h gt include lt unistd h gt include lt pthread h gt include fcntl h include termios h include lt time h gt include errno h include sys select h include Logger h include serial h CSerial char logfile logLevel logLevel 2 HEHEH CSerial COMAR Parent const char Device Initialize members parent Parent sd 1 thread id 0 buf head buf tail 0 pthread mutex init sstate lock NULL state SERIAL CLOSED device NULL device new char SERIAL
214. tdlib h gt include lt stdio h gt include od Camera h include od common h int main int argc char argv int pan tilt if argc 3 return 0 pan atoi argv 1 tilt atoi argv 2 if OD OK odCameraMove pan tilt printf SGPCAM d d n pan tilt F 66 ECE 477 Final Report Spring 2008 return 0 iii Subvehicle refs od otherlibs debug h ifndef debugscripts Compile with debuging on define debugscript x printf x define debugcode x x Compile with debuging off define debugscript x define debugcode x define attempt debugscript FUNCTION Attempt in define failure x debugcode printf FUNCTION Failure s x return 0 define success debugscript FUNCTION Successn return 1 define success return x debugscript FUNCTION Success Mn return x define debugscripts fendif ih Subvehicle refs od otherlibs pwc ioctl h ifndef PWC IOCTL H define PWC IOCTL H C 2001 2003 Nemosoft Unv webcam smcc demon nl This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of
215. ter speed 1 return OD ERROR if ioctl dev VIDIOCPWCSAGC again 1 return OD ERROR image get image dev width height amp size gettimeofday time NULL if size close dev if image fimage malloc size memcpy fimage image size put_image ppm out image width height put image jpeg out image width height 60 VIDEO PALETTE YUV420P if size munmap image size close dev else if image free image else fprintf stderr Error Can t get image n return NULL F 65 ECE 477 Final Report Spring 2008 csize size return fimage odTakePicture int odCameraMove int pan int tilt int dev struct pwc mpt angles values int rval OD OK if pan lt 7000 pan gt 7000 return OD_ERROR if tilt lt 3000 tilt gt 2500 return OD ERROR dev open VIDEO DEV O RDWR if dev 1 return OD ERROR values absolute 1 if ioctl dev VIDIOCPWCMPTGANGLE amp values 1 fprintf stderr Error can t set pan tilt n rval OD ERROR values pan pan values tilt tilt if ioctl dev VIDIOCPWCMPTSANGLE amp values 1 fprintf stderr Error can t set pan tilt n rval OD ERROR close dev return rval odCameraMove eof 4 Subvehicle refs od movecam c include lt s
216. th ok resolution 26 50 5 106 00 Acroname Sharp R302 GP2Y0A700K0F Long range IR 19 50 2 39 00 Acroname Sharp R144 GP2Y0A02YK Short range IR 12 50 2 25 00 Sparkfun ST LIS3LV02DQ Accelerometer 43 95 1 43 95 Sparkfun Honey Well HMC6352 Magnetometer 3995 1 59 95 Gumstix Gumstix XL6P Embedded Computer 269 00 1 269 00 Acroname Acroname R298 1T SERVO Servo with 360 degrees turn 18 00 1 18 00 Gumstix Gumstix Verdex XL6P Embedded Computer 169 00 1 169 00 Gumstix Gumstix netwifimicroSD FCC Expansion Board wifi 99 00 1 99 00 Gumstix Gumstix Breakout vx Expansion Board 27 50 1 27 50 Future Electronics Micrel Inc MIC29150 3 3WT LDO Regulator 3 3V 3 42 I Health Stores Magnetic Shielding Foil 15in wide 2895 2 57 90 0 010 in thick Pololu Pololu MD03A 708 Dual VNH2SP30 motor driver carrier 59 95 1 59 95 Digikey Micrel Inc MIC29300 5 0BT ND LDO Regulator 5 0V 3A 4 25 1 4 25 Digikey Linear Technology LT1083CP 5 PBF ND LDO Regulator 5 0V 7 5A 13 50 1 13 50 Digikey AVX Corporation TAJA104K035R Cap Tantalum 0 10uF 0 87 2 1 74 Digikey Vishay Sprague 293D334X9035A2TE3 Cap Tantalum 0 33uF 0 10 2 0 20 Newark Maxim Max3370EXK T Level translators 2 10 2 4 20 Digikey Lite On Inc SMD LTST C171TBKT LED 0 62 1 0 62 Mouser Kemet C1206F104K3RACTU Ceramic Capacitor 1206 0 10uF 0 47 8 3 74 Digikey EPCOS Inc B82422H1103K Inductor 10uH 1210 0 56 1 0 56 Digikey EPCOS Inc B82496C3479J Inductor 4 7nH 0603 0 32 6 1 92
217. than most embedded systems that were not extremely expensive Initially the Triton320 was considered but it was eventually determined that a Gumstix module would be better to use due to its packaging documentation and prior experience Robert also researched some methods for distance measuring and room mapping Robert decided that IR and sonar sensors would be the best and options for distance ranging due to the low cost and range Laser range finders would be more ideal but they are heavy large and expensive Robert selected the Sharp IR sensors and Devantech srf02 sonar sensors for the distance ranging After researching online Robert discovered that SLAM was a common technique used for 2 D room mapping A little research was done reading up on SLAM and the ideas behind it It initially seemed like SLAM was the way to go and there were open source implementations online ready to use After all the parts were determined and purchased Robert was responsible for most of the microcontroller and sensor work Robert first started out by initiating the UART and communication with the micro via serial to a computer Robert wrote all of the I2C drivers which ECE 477 Final Report Spring 2008 our sonar IR magnetometer and accelerometer sensors used The code for each I2C device ended up having to be different For the sonar sensors you had to send the address the register to read or write and then the command For the magnetometer you sent the
218. that all require analog to digital converters The four motors will be driven by 2 motor controllers that will use pulse width modulation There will also be a turret that will rotate the inferred sensors with a 360 servo that will also require a PWM signal There will be sonar sensors for the longer distances There are two sonar sensors that have been picked out with different peripheral interfaces The SRF02 5 uses UC while the EZ2 4 uses ADCs Final decisions on which sonar is used will depend upon accuracy ease of use and peripheral requirements and availability The magnetometer and accelerometer will also require IC Lastly the microcontroller will have to use UART to communicate with the embedded computer that will have to be level shifted with a max333 As for the embedded computer it will need an RS232 port to receive data from the microcontroller There should be USB capability in the event that a USB compatible camera is used The rover also needs to communicate with the base station wirelessly Wireless modules are available for direct connection with the embedded computer along with Ethernet which will be very beneficial for developing on the embedded computer 3 1 4 Off Chip Peripheral Requirements The Gumstix XL6P 10 combined with an ATMega32 11 can interface all of the required external devices except for the four brushed DC motors For this purpose a pair of ST VNH2SP30 E H Bridge 8 bi directional motor drivers will be
219. tion Search path creation and findings x x include od SearchPath h int odCreatePath od DB db od Path path return 0 odCreatePath eof i Subvehicle refs od od common h od common h ObjectDetection Common Header ifndef OD COMMON H define OD COMMON H Constants ae ee define OD OK 1 define OD_ERROR 0 d Data Types 257905 Saas Sa SSS SS Sa RS P SSH P Sen typedef struct verti 2d lHt x v int probability struct od Object owner F 103 ECE 477 Final Report verti 2d typedef struct vertf 2d float x y int probability struct od Object owner vertf 2d typedef struct verti 3d Int x YZ int probability struct od Object owner verti 3d typedef struct vertf 3d float x y z int probability struct od Object owner vertf 3d typedef struct od Line struct od Line next prev struct od Object owner verti 3d ptl pt2 int probability if this is not a line and on theoretical then this is set to od Line typedef struct od Object struct od Object subObject struct od Object parentObject struct od Object next prev Spring 2008 the vertices is 0 link to any subjects owned by this object link to parent object points to next and previous objects struct od Line lines List of Lines contained by the object int probability od Object
220. tional to how far an obstacle is the farther away from OMAR the faster it will drive and vice versa The direction is changed if the sensors detect an object and depending on which side it is detected on will determine which way to turn e Anability to detect and avoid obstacles Being able to detect and avoid obstacles is an imperative requirement for the autonomous navigation of a room OMAR has successfully demonstrated these abilities and have used these abilities to control our direction and speed as mentioned above e Anability to capture still images OMAR is able to capture still images This is done with the Logitech camera that is interfaced with the Gumstix embedded computer via USB e Anability to identify a logo within a captured image OMAR is able to detect faces using the OpenCV library It is the same software that is used for object detection except that it has already been trained Training the software with a customized logo was taking a lot longer than the team had anticipated and so the face recognition was employed instead e Anability to autonomously map room and determine vehicle path OMAR was unable to complete this due to insufficient resources The SLAM algorithm that was going to be used required a lot more memory that was not available on the Gumstix ECE 477 Final Report Spring 2008 3 0 Constraint Analysis and Component Selection The OMAR reconnaissance vehicle as complex as it is has fairly straightforw
221. to a destination under such control as to avoid obstacles In the first claim for the patent it describes the comprising parts of the autonomous apparatus It has a scan type sensor that scans a horizontal plane to detect a position of an obstacle while a non scan type sensor detects an obstacle in the space It then uses the information from both sensors to estimate the position or area of the obstacle Using a controller for controlling the apparatus it then travels to the destination while avoiding the obstacle The second patent was number 6539284 filed Jul 25 2001 titled Socially interactive autonomous robot 15 The patent describes that a robot performing substantially autonomous movement will need certain components in order to direct the robot to move within any predetermined safe are and that it accepts input from a human The first claim under this patent breaks down the components It has a processing device a memory that communicates with the processing device and a mobility structure controlled by the processing device which moves the apparatus Also there is at least one sensor for measuring an amount of movement Lastly the 11 ECE 477 Final Report Spring 2008 memory contains instructions to move the apparatus within a predetermined safe area having a boundary and reference point The third patent was number 5170352 filed Aug 7 1991 titled Multi purpose autonomous vehicle with path plotting 16 The basic concep
222. ts HMC6352 pdf 7 STMicroelectronics LIS3LV02DQ Online Document 2005 October January 31 2008 http www sparkfun com datasheets IC LIS3L V02DQ pdf 8 STMicroelectronics VNH2SP30 E Online Document 2007 May cited January 31 2008 http www st com stonline products literature ds 10832 vnh2sp30 pdf 9 Acroname Robotics High Torque Full Turn Servo Acroname Robotics January 2008 Online Available http www acroname com robotics parts R298 1T SERV O html Accessed Jan 31 2008 10 Gumstix Specifications of the Gumstix Verdex Motherboards DocWiki December 2007 Online Available http docwiki gumstix org Verdex Accessed Jan 31 2008 11 Atmel ATmega32 Online Document 2007 August cited January 31 2008 http www atmel com dyn resources prod documents doc2503 pdf 12 STMicroelectronics STD60NF3LL Online Document 2006 July cited January 31 2008 http www st com stonline products literature ds 7680 std60nf31l pdf 13 Strategic Test Corp TRITON 320 PXA320 module Online Document unknown publication data cited January 31 2008 http www strategic embedded com pxa320 monahan linux wince datasheet triton 320 html 34 ECE 477 Final Report Spring 2008 14 Google Autonomous moving apparatus having obstacle avoidance function Google Online Available http www google com patents id 2TY OAAAAEBAJ amp dq 6515614 Acc
223. ts are also critical to the completion of this project Without one the project would fail Below are the tables for the reliability calculations for the 3 chosen parts The microcontroller and the voltage regulator will follow the equation Ap Cizr Cong nom for microcontrollers and MOS devices and the motors will follow the equation A t a 1 aw for motors 17 Tables 1 3 show the selected coefficients and the reasoning behind each choice The MTTF for the microcontroller is 64 276 years 29 790 years for the voltage regulator and 99 13 years for the motors Table 1 Microcontroller A 1 776 failures 10 6 hours Ap Cir Cong non 64 276 years failure 14 microcontroller C2 015 SMT we EET Table 2 Voltage regulator 3 832 Failures 10 6 hours A C1 nT C2 xE n Q zaL 29 790 years failure 00092 3 pins SMT 15 ECE 477 Final Report Spring 2008 Table 3 Motors 1 515 Failures 10 6 Hours Ap t ap l aw 99 13 years failure 0 0833 hours 86000 Motor bearing life 30 C 6 6e05 Motor winding life 30 C According to the calculations done the parts that have been chosen for OMAR seem to be extremely reliable Because OMAR is intended for 1 use only the MTTF for our parts does not play a significant part unless it is extremely low less than 1 per year Our lowest MTTF is 29 8 years so OMAR should have no problems with failing irreplaceable parts One w
224. turn 0 check th Wi int v4l check size siz and readjust if necessary int fd int width int height struct video capability vid_caps if ioctl fd VIDIOCGCAP amp vid caps 1 perror ioctl VIDIOCGCAP return 1 readjust if necessary width height if width gt vid caps maxwidth width lt vid caps minwidth width min width vid caps maxwidth width max width vid caps minwidth fprintf stderr readjusting width to d n if height gt vid_caps maxheight height lt vid_caps minheight height min height vid caps maxheight height max height vid caps minheight fprintf stderr readjusting height to d n return 0 check the requested palette and adjust if possible seems not to work ST int v4l check palette int fd int palette struct video picture vid_pic if palette return 1 if ioctl fd VIDIOCGPICT amp vid pic 1 perror ioctl VIDIOCGPICT return 1 vid pic palette palette if ioctl fd VIDIOCSPICT amp vid pic 1 try YUV420P F 120 ECE 477 Final Report Spring 2008 fprintf stderr failed n vid pic palette palette VIDEO PALETTE YUV420P if ioctl fd VIDIOCSPICT amp vid pic 1 perror ioctl VIDIOCSPICT to YUV ok try grayscale EJ vid p
225. undation either version 2 of the License or at your option any later version a PhilipsWebCamLib is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details F 73 ECE 477 Final Report Spring 2008 Xx F Xo X F X F o F X Xo ox Zei int devcount 0 You should have received a copy of the GNU General Public License along with PhilipsWebCamLib if not write to the Free Software Foundation Inc 59 Temple Place Suite 330 Boston MA 02111 1307 USA PhilipsWebCamLib Version 1 2 0 Release Date 1 04 Author Derrick Parkhurst Copyright c 2004 Derrick Parkhurst lt derrick parkhurst jhu edu gt All Rights Reserved This code was derived in part from the GNU GPL project setpwc C 2003 Folkert van Heusden folkert vanheusden com include stdio h include lt stdlib h gt include signal h include lt sys types h gt include sys stat h include fcntl h include errno h include stdio h include unistd h include linux videodev h include lt sys ioctl h gt include string h include sys mman h include ccvt h include pwc ioctl h include debug h define MAXDEVICES 8 define SET PAN 0 define SET TILT i define SET Z20O 2 int device MAXDEVICES struct vide
226. very 10s changed Cleaned up message handling and associated logging 2008 04 24 146 jwildey modified uncommented go commands from state machine 2008 04 24 145 nelson11 changed Commented out serial read code for debugging added Try to stop omar before we close down serial service 2008 04 24 144 jwildey modified deleted the after the last o file and deleted the terminal and fuse bit modes 2008 04 24 143 nelson11 changed Simplified uart comms with uC 2008 04 24 142 jwildey Added code to get a command from the gumstix gumstix will send 0x55 for GO and OxAA for STOP also commented out default state in state machion 2008 04 24 141 nelson11 changed Cosmetic 2008 04 23 140 nelson11 removed Excessive debugging statements 2008 04 23 139 nelson11 fixed Turns out serial callback has been working fine all along I m an idiot removed Tons of unnecessary debug commented code 2008 04 23 138 nelson11 changed rewrote serial callback in a less stupid way Still causes problems 2008 04 23 137 jwildey added terminal modes to make file as well as hfuse and lfuse write option to 0xd9 and 0xe4 respectively 2008 04 23 136 nelson11 added send function for use in network amp gt serial communication added lock around serial descripter messes up network thread fixed More scary messages after signal is caught on ARM changed Open serial port for non blocking access 2008 04 23 135 nelson11 added support for go callback i
227. vironment which will aid in the heat dissipation Most of the devices that are being utilized operate at 5 V however there are a few devices that operate at 3 3 V The motors chosen operate from between 5 and 12 V Given these parameters the battery has been chosen to be a 7 4 V battery The capacity of the battery is still unknown and will depend upon the inrush and continuous current that is pulled by the motors which are estimated to pull a maximum of 8 A total 3 1 6 Packaging Constraints The intended use of this rover is to be transported on a UAV and then aerially deployed at a specified location for reconnaissance Therefore there will have to be a size and weight restriction as well as surviving up to 3 g s of impact when landing Even though rigorous mechanical functionality will not be considered in the design of OMAR the size and weight issues will still be addressed in the design process It was decided that considering the lift capacity of the current UAV the weight would ideally be around 5 Ibs and can be up to a maximum of 10 Ibs The size restriction will have to be relatively small compared to the UAV to ensure that it will actually fit on the UAV and fit well enough so as not to unbalance the UAV while airborne Obviously with regards to size the smaller the better however the maximum determined size was 14 x6 x6 Another justification for the small size of the rover is it will be traversing an unexplored room and may have sm
228. vr io h gt include i2c h include uart h uint8 t i2c error void i2c init i2c error OK PORTC 0x03 portO and portl internally pulled high TWSR 0 lt lt TWPSO amp 0 lt lt TWPS1 prescalar 1 TWBR 4 F CPU 100000UL 16 2 0x02 2 with prescalar 1 should 100kHz end init int srf change addr uint8 t curr addr uint8 t new addr i2c error OK i2c transmit curr addr O0xAO0 delay ms 32 i2c transmit curr addr O0XAA delay ms 32 i2c transmit curr addr 0xA5 delay ms 32 i2c transmit curr addr new addr delay ms 32 return OK uint8 t srf read uint8 t addr F 18 ECE 477 Final Report i2c error OK i2c transmit addr 0x51 delay ms 110 range i2c read addr 2 lt lt 8 delay ms 32 delay ms 32 delay ms 6 return i2c read addr 3 if send start ERROR i2c error ERROR if send addr t addr ERROR i2c error ERROR if send data 0x02 ERROR i2c error ERROR if send repeat ERROR i2c error ERROR if send addr r addr ERROR i2c error ERROR if get data ERROR i2c error ERROR range TWDR 8 put str checkNinNr if send repeat ERROR i2c error ERROR if send addr t addr ERROR i2c error ERROR if send data 0x03 ERROR i2c error ERROR if send repeat ERROR
229. wn in appendix C Listed below in table 4 1 is a list of all the major components and the selected packages There were not many options for the accelerometer and magnetometer so the listed packages were chosen The estimated dimensions are 95mm x 95mm and the estimated total area is 9025 mm All components were placed around the microcontroller based on their interfaces with the microcontroller and where their respective pins are The dimensions of the PCB were chosen to be as small as possible but still leaving ample room for making all of the necessary traces 24 ECE 477 Final Report Spring 2008 Table 4 1 List of major components and packages selected Mfg Part Description Package Other options Atmel ATmega32 Microcontroller QFP44 DIP40 QFN44 ST Semi VNH2SP30 H Bridge SO 30 None ST Semi STD60NF3LL Pwr MOSFET DPAK None ST Semi LISSLVO2DQ Accelerometer QFN28 None Honeywell HMC6352 Magnetometer QFN24 None Maxim IC MAX1585A Buck Power Reg QSOP24 None 8 0 Schematic Design Considerations There are three main components of the preliminary schematic are power microcontroller and motor controller circuits Because of the wide array of sensors that are in use as well as the Gumstix embedded computer 10 ATmega32 microcontroller 11 and the motor controller the only voltages required are 3 3 and 5 volts The MAX1858 DC to DC step down converter 23 was chosen because it has two customizable voltage outputs and can handle the power loa
Download Pdf Manuals
Related Search
Related Contents
取 扱 説 明 書 Manuale d`uso Easypix EasyPad 1370 4GB Black, Silver MT716 - セイコークロック RECEPTOR DE AUDIO BLUETOOTH 1 本保証は、本保証書添付の延長保証加入明細 延長保証期間中に故障 PDF 55KB / 11ページ - DISCO Corporation KWC Designo K.12.H1.11.000 User's Manual Au nom du peuple italien Time machine Page 1 of 39 Time machine for sale Copyright © All rights reserved.
Failed to retrieve file