« Previous - Version 6/16 (diff) - Next » - Current version
Anthony Rowe, 06/24/2007 05:23 pm


= spoonBot Sample Program =

[[Image(htdocs:images/spoonBot_thumb.jpg)]]

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.

Calibrating spoonBot

Before using spoonBot, you need to calibrate your servo settings. This is done by setting the following data structure at the top of main: {{{
#!c
// SpoonBot Calibration Points
// Assume Left = Servo 0
// Assume Right = Servo 1
// Assume Spoon = Servo 2
my_cal.left_mid = 71;
my_cal.right_mid = 77;
my_cal.spoon_down = 100;
my_cal.spoon_mid = 202;
my_cal.spoon_up = 255;
my_cal.left_dir = 1;
my_cal.right_dir = -1;
my_cal.spoon_dir = 1;
// Set the calibration points
spoonBot_calibrate (my_cal);
}}}

  • Flash the cmucam2 emulation firmware onto the camera
  • Open either the CMUcam3 Frame Grabber or a Terminal Program
  • Find the middle position of Servo's 1 and 2 * Using the Frame Grabber, go to the "Settings" panel and drag the servo bars around until the wheels stop moving * my_cal.left_mid = <value from servo 0> * my_cal.righ_mid = <value from servo 1> * Now you need to find the sign of the directions * Looking at spoonBot from the back (spoon towards you) try lowering the servo 0 number which should be the left wheel * if the servo spins clockwise / backwards (toward you) then left_dir should be set to 1 * if the servo spins counter clockwise, left_dir should be set to -1 * Repeat for servo 1 (which should be the right wheel from spoonBot's point of view) * if the servo spins clockwise / backwards (toward you) then left_dir should be set to 1 * if the servo spins counter clockwise, left_dir should be set to -1 * Usually, one servo should be set to negative! * Now find the Min, Middle and Max spoon positions * Min should be the smallest value that pushes the spoon down and hence tilts spoonBot forward * Max is usually 255 and should position spoonBot looking as far up as possible * Middle is the value that makes the servo level * If Min and Max appear to be reversed, change my_cal.spoon_dir to -1