SpoonBot-demo
Version 8 (Anthony Rowe, 06/24/2007 05:25 pm)
1 | 4 | Anthony Rowe | = spoonBot Sample Program = |
---|---|---|---|
2 | 3 | Anthony Rowe | |
3 | 3 | Anthony Rowe | |
4 | 3 | Anthony Rowe | [[Image(htdocs:images/spoonBot_thumb.jpg)]] |
5 | 3 | Anthony Rowe | |
6 | 3 | Anthony Rowe | spoonBot is a simple differential drive robot with a spoon connected to a servo that allows it to pan and tilt. See the [wiki:spoonBot spoonBot-Construction] page for information about building spoonBot. The sample program that comes with the latest cc3 distribution contains sample code demonstrating how to move spoonBot as well as run spoonBot Demo mode. spoonBot Demo mode is similar to the CMUcam2 demo mode only it uses spoonBot to pan and tilt. |
7 | 3 | Anthony Rowe | |
8 | 5 | Anthony Rowe | |
9 | 5 | Anthony Rowe | == Calibrating spoonBot == |
10 | 5 | Anthony Rowe | |
11 | 3 | Anthony Rowe | Before using spoonBot, you need to calibrate your servo settings. This is done by setting the following data structure at the top of main: |
12 | 3 | Anthony Rowe | {{{ |
13 | 3 | Anthony Rowe | #!c |
14 | 3 | Anthony Rowe | // SpoonBot Calibration Points |
15 | 3 | Anthony Rowe | // Assume Left = Servo 0 |
16 | 3 | Anthony Rowe | // Assume Right = Servo 1 |
17 | 3 | Anthony Rowe | // Assume Spoon = Servo 2 |
18 | 3 | Anthony Rowe | my_cal.left_mid = 71; |
19 | 3 | Anthony Rowe | my_cal.right_mid = 77; |
20 | 3 | Anthony Rowe | my_cal.spoon_down = 100; |
21 | 3 | Anthony Rowe | my_cal.spoon_mid = 202; |
22 | 3 | Anthony Rowe | my_cal.spoon_up = 255; |
23 | 3 | Anthony Rowe | my_cal.left_dir = 1; |
24 | 3 | Anthony Rowe | my_cal.right_dir = -1; |
25 | 3 | Anthony Rowe | my_cal.spoon_dir = 1; |
26 | 3 | Anthony Rowe | // Set the calibration points |
27 | 3 | Anthony Rowe | spoonBot_calibrate (my_cal); |
28 | 3 | Anthony Rowe | }}} |
29 | 5 | Anthony Rowe | |
30 | 5 | Anthony Rowe | * Flash the cmucam2 emulation firmware onto the camera |
31 | 5 | Anthony Rowe | * Open either the CMUcam3 Frame Grabber or a Terminal Program |
32 | 7 | Anthony Rowe | * Using the Frame Grabber, go to the "Settings" panel and drag the servo bars to change values |
33 | 7 | Anthony Rowe | * In a terminal, type "sv <servo-id> <servo-value>" to set the servos for example: |
34 | 7 | Anthony Rowe | {{{ |
35 | 7 | Anthony Rowe | :sv 0 77 |
36 | 7 | Anthony Rowe | ACK |
37 | 7 | Anthony Rowe | }}} |
38 | 8 | Anthony Rowe | * Find the middle position of Servo's 0 and 1 by adjusting them until the wheels stop |
39 | 5 | Anthony Rowe | * my_cal.left_mid = <value from servo 0> |
40 | 5 | Anthony Rowe | * my_cal.righ_mid = <value from servo 1> |
41 | 5 | Anthony Rowe | * Now you need to find the sign of the directions |
42 | 5 | Anthony Rowe | * Looking at spoonBot from the back (spoon towards you) try lowering the servo 0 number which should be the left wheel |
43 | 5 | Anthony Rowe | * if the servo spins clockwise / backwards (toward you) then left_dir should be set to 1 |
44 | 5 | Anthony Rowe | * if the servo spins counter clockwise, left_dir should be set to -1 |
45 | 5 | Anthony Rowe | * Repeat for servo 1 (which should be the right wheel from spoonBot's point of view) |
46 | 5 | Anthony Rowe | * if the servo spins clockwise / backwards (toward you) then left_dir should be set to 1 |
47 | 5 | Anthony Rowe | * if the servo spins counter clockwise, left_dir should be set to -1 |
48 | 5 | Anthony Rowe | * Usually, one servo should be set to negative! |
49 | 8 | Anthony Rowe | * Now find the Min, Middle and Max spoon positions by adjusting Servo 2 |
50 | 6 | Anthony Rowe | * Min should be the smallest value that pushes the spoon down and hence tilts spoonBot forward |
51 | 6 | Anthony Rowe | * Max is usually 255 and should position spoonBot looking as far up as possible |
52 | 6 | Anthony Rowe | * Middle is the value that makes the servo level |
53 | 6 | Anthony Rowe | * If Min and Max appear to be reversed, change my_cal.spoon_dir to -1 |