Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
Sensors/Camera/Camera.cpp@0:a6a169de725f, 2013-05-27 (annotated)
- Committer:
- shimniok
- Date:
- Mon May 27 13:26:03 2013 +0000
- Revision:
- 0:a6a169de725f
- Child:
- 23:a34af501ea89
Working version with priorities set and update time display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | #include "mbed.h" |
shimniok | 0:a6a169de725f | 2 | #include "Camera.h" |
shimniok | 0:a6a169de725f | 3 | |
shimniok | 0:a6a169de725f | 4 | Camera::Camera(PinName tx, PinName rx): |
shimniok | 0:a6a169de725f | 5 | serial(tx, rx) |
shimniok | 0:a6a169de725f | 6 | { |
shimniok | 0:a6a169de725f | 7 | serial.baud(115200); |
shimniok | 0:a6a169de725f | 8 | |
shimniok | 0:a6a169de725f | 9 | return; |
shimniok | 0:a6a169de725f | 10 | } |
shimniok | 0:a6a169de725f | 11 | |
shimniok | 0:a6a169de725f | 12 | void Camera::start() |
shimniok | 0:a6a169de725f | 13 | { |
shimniok | 0:a6a169de725f | 14 | serial.attach(this, &Camera::receive, Serial::RxIrq); |
shimniok | 0:a6a169de725f | 15 | |
shimniok | 0:a6a169de725f | 16 | // ping |
shimniok | 0:a6a169de725f | 17 | // should now get ACK\r or NACK\r |
shimniok | 0:a6a169de725f | 18 | // send colormap here |
shimniok | 0:a6a169de725f | 19 | // should now get ACK\r or NACK\r |
shimniok | 0:a6a169de725f | 20 | // disable white balance |
shimniok | 0:a6a169de725f | 21 | // should now get ACK\r or NACK\r |
shimniok | 0:a6a169de725f | 22 | serial.printf("ET\r\n"); |
shimniok | 0:a6a169de725f | 23 | // should now get ACK\r or NACK\r |
shimniok | 0:a6a169de725f | 24 | return; |
shimniok | 0:a6a169de725f | 25 | } |
shimniok | 0:a6a169de725f | 26 | |
shimniok | 0:a6a169de725f | 27 | |
shimniok | 0:a6a169de725f | 28 | void Camera::receive() |
shimniok | 0:a6a169de725f | 29 | { |
shimniok | 0:a6a169de725f | 30 | while (serial.readable()) { |
shimniok | 0:a6a169de725f | 31 | char c = serial.getc(); |
shimniok | 0:a6a169de725f | 32 | fprintf(stdout, "%c\n", c); |
shimniok | 0:a6a169de725f | 33 | } |
shimniok | 0:a6a169de725f | 34 | return; |
shimniok | 0:a6a169de725f | 35 | } |
shimniok | 0:a6a169de725f | 36 | |
shimniok | 0:a6a169de725f | 37 | |
shimniok | 0:a6a169de725f | 38 | /* |
shimniok | 0:a6a169de725f | 39 | * (Byte 0: 0x0A – Indicating the start of a tracking packet |
shimniok | 0:a6a169de725f | 40 | * Byte 1: Number of trac k ed objects (0x00 – 0x08 are valid) |
shimniok | 0:a6a169de725f | 41 | * Byte 2: Color of object tracked in bounding box 1 |
shimniok | 0:a6a169de725f | 42 | * Byte 3: X upper left corner of bounding box 1 |
shimniok | 0:a6a169de725f | 43 | * Byte 4: Y upper left corner of bouding box 1 |
shimniok | 0:a6a169de725f | 44 | * Byte 5: X lower right corner of boudning box 1 |
shimniok | 0:a6a169de725f | 45 | * Byte 6: Y lower right corner of boudning box 1 |
shimniok | 0:a6a169de725f | 46 | * Byte 7: Color object tracked in bound box 2 |
shimniok | 0:a6a169de725f | 47 | * ... |
shimniok | 0:a6a169de725f | 48 | * Byte x: 0xFF (indicates the end of line, and will be sent after all tracking info |
shimniok | 0:a6a169de725f | 49 | * for the current frame has been sent) |
shimniok | 0:a6a169de725f | 50 | */ |
shimniok | 0:a6a169de725f | 51 | void Camera::parse(char c) |
shimniok | 0:a6a169de725f | 52 | { |
shimniok | 0:a6a169de725f | 53 | |
shimniok | 0:a6a169de725f | 54 | return; |
shimniok | 0:a6a169de725f | 55 | } |
shimniok | 0:a6a169de725f | 56 |