Make Your Own‎ > ‎

Calibration


Basic Calibartion

After the turret is built, you have to go through a “calibration” process, which matches the webcam’s view to the gun’s motion. 

Turn off autonomous mode. In "Gun Settings" on the control panel, click "Reset Calibration" to set xMin = 0, xMax = 180, yMin = 0, and yMax = 180. You should find that if you move the mouse cursor across the full width of the webcam viewing window (in manual mode), the pan servo on the turret moves a full 180-degrees. Similarly, if you move the mouse cursor vertically across the webcam view window, the tilt servo on the turret should move a full 180-degrees.

If the gun’s motion is inverted on either the horizontal (pan) axis or on the vertical (tilt) axis, click "Flip X" or "Flip Y" to fix this.

Now you need to do the calibration itself. To do this, look first at the left edge of the webcam view window. Compare the left edge of the webcam view with the real world, and locate where the left edge of the webcam view lies in the real world. Usually to do this, I find an object that is just barely inside the webcam view, and that is where the edge of the webcam view is in the real world.

Next, move the mouse cursor (still in manual mode) to aim the gun at the point where the left edge of the webcam view is in the real world. Disregard where the cursor points on the webcam view window – just move it around to get the gun pointing to the left edge of the webcam view in the real world. When you are satisfied that the gun is aimed at this edge, press the 'a' key on your keyboard. Since this value is for the left edge, it is saved as your new xMin value. Verify that the xMin value has been changed by checking the value on the control panel. Do the same thing for the right edge of the viewing window, but with the 'd' key instead of 'a' – the Pan Servo Position there will be your new xMax value.

Now, align the gun with the bottom edge of the webcam view, as above. This time, press 's'. This will be your new yMin value. Do the same for the top edge, using 'w', to get your new yMax value.

You should see your new xMin, xMax, yMin, and yMax values indicated in the control panel, under "Gun Settings". Click 'Save Settings' to keep these.

Now, when you move the cursor over an object in the webcam viewing window, the gun should point at that object in real life. You have successfully calibrated the turret.



Servo Home Positions and Reload Positions

You may also want to calibrate the servo home positions set in the Arduino code. There are a bunch of values at the beginning of the Arduino code, which set the various home positions for each servo (such as where to go when the reload switch is on, where to go when the Processing code isn't running, trigger servo positions, etc). Read the comments next to each one to find the value that will work for your setup, and change the value right in the code. You'll need to re-upload the Arduino code to your microcontroller for these changes to take effect.



Congratulations, you're done!

Share some photos or video of your project on the Forum, or email them to me to post on the Featured Projects page.

Comments