|
Video |
|
|
CMUcam + Basic Stamp 2 If you have a fast internet connection just click on EASY1.WMV movie file below, otherwise its better to download the file and view it from your local hard drive. To view this movie file you will need the latest version of the Microsoft Windows Media Player. You can download this upgrade for free from the Microsoft web site. In this demo the robot is trained to seek the color red. It determines when to stop by the size of the of the red object it sees. If the robot knows the approximate size of the object it is seeking or tracking it can use object size to estimate range. I should note that the pan and tilt servos are not enabled on this demo. This demo is to show what can be done with a Parallax Growbot or Parallax Boebot that has a CMUcam fixed to the front. Below is the code - a quick hack ' CMUcam jumpered for Baud 9600
RcvData Var Byte(10)
low 12
low 13
n var byte
Confid var byte
pause 1000
' Send "enter" to sync CMUcam and Stamp
serout 0, 85, [CR]
serin 1, 85, [Wait (":")]
pause 100
' set V servo position straight ahead serout 0, 85, ["S1 60",CR] pause 100
' Send command - Set poll mode - only sends one return packet -
' of data after each command - reduces data flow
serout 0, 85, ["PM 1",CR]
serin 1, 85, [Wait (":")]
pause 100
' Send command - Set raw data mode - also suppress Ack:/Nak: to - ' further reduce serial data serout 0, 85, ["RM 3",CR] pause 100 ' Track Window command looks at the center of CMUcam image - ' grabs the color information and sends to the Track Color function Pause 2000 ' white balance and auto gain on serout 0, 85, ["CR 18 44 19 33",CR] ' give the camera a little time to adjust pause 5000 ' Send command - Track window serout 0, 85, ["TW",CR] ' Ignore the S packet and M packet from TW pause 1000 Main: ' Send command - Track color (with no arguments) - ' will track last color grabbed by TW command serout 0, 85, ["TC",CR] ' Raw mode M packet format - 0 Byte always 255, 1 Byte always - ' Char M, 2 Byte Mx, 3 Byte My, 8 byte Pixels, 9 byte Confidence serin 1, 85, [STR RcvData\10] Confid = RcvData(9) ' 45 is H center If RCVData(8) > 250 And Confid > 50 Then Bwd If RCVData(2) > 55 And Confid > 25 Then Right ' X If RCVData(2) < 35 And Confid > 25 Then Left ' X If RCVData(8) < 120 And Confid > 25 Then Fwd Goto Main Left: for n = 1 to 20 pulsout 13,600 pulsout 12,600 next Goto main Right: for n = 1 to 20 pulsout 13,850 pulsout 12,850 next Goto main Bwd: for n = 1 to 20 pulsout 13,550 pulsout 12,900 pause 15 next Goto main Fwd: for n = 1 to 20 pulsout 13,900 pulsout 12,550 pause 15 next Goto main |