[ Home - 2007 Rules - Contest Results! - Forums - Photo Gallery ]

Robotic Shooting Gallery - Reference Design, Software

The real challenge for this contest is the software. The mechanics of the gun are fairly easy to do, it's mostly just bolting together other products.

This is the software that I wrote to test the arena to make sure that the rules, match lengths, etc are realistic. At this point, this software was able to shoot down 22 targets in about 90 seconds (match length's are 2 minutes).

Unfortunately, all the code is in Visual Basic 6. I had code from past projects that controlled servos, and code that used the webcam, so for me it was quickest to merge all that code rather than put my time into figuring all that out in another language. So at the very least this code should give you some ideas about what the basic capabilities of your bot should be.

How it works

  • If there is a white pixel in the center of the image then fire the gun.
  • From the center of the webcam image, search in an outward spiral pattern looking for single white pixels.
  • Move the gun to the closest white pixel.

    Hardware

  • All control is done through servos. The Pololu Serial 8-Servo Controller was selected because it is extremely easy to interface to a computer. It is also affordable at about $26.
  • The gun was disassembled and rewired so that a momentary switch will fire it. That switch was then mounted so that a small servo's arm will hit it when turned.
  • The gun is aimed using two servos.
  • The webcam (Logitech USB Quickcam Zoom) is mounted just above the barrel.
  • Note that the servos can move farther than the physical design of the gun allows. Therefore, the software needs to know the range that it is allowed to move. This is adjusted using the three sliders on the upper left. The rest of the code merely passes in percentages which are then translated to a location within that range. You could also just experiment and hard code the values.
  • To align where the gun is aiming with where the camera thinks it is aiming there is a calibration option.

    Files

    All these files are Public Domain. There is no restriction on what you can do with them.
    File NameSizeDescription
    defconbots_ai_20070513.zip103kAll the files
    control.frm69kMain program, has all the code in it
    control.vbp2kProject file for VB6
    filters.txt5kauto-generated

    Quick Start

    There is only one control screen, so there is a lot of information here.
    1. Choose the correct COM port for your serial port, it auto-connects when you load, but if you change ports you may need to click Off then On
    2. Enable the camera by cicking on "Camera On" on the right. You may need to change the code to select the right driver first though.
    3. Use the sliders under RAW control to move the gun around. When you reach the limits of where you want the gun to shoot, click each Set button.
    4. You can verify the movement by using the sliders in the Manual Control area.
    5. Click "Fire" and note where the shots hit, then click "Set" by Camera Offset and click on the image where the shots hit. This aligns the gun to the camera.
    6. To enable automatic operation, check "Enable Webcam Control". The gun should begin tracking.
    7. To enable firing, check "Enable Firing".

    Raw Information and Status

    • The three values to the left are the current values being sent to the pololu controller.
    • The sliders will move around as the servos are commanded to move.
    • The Gun Limits determine where +- 100% are for the movements, so these will always depend on your design. Once they are set the don't need to be re-calibrated though.

    Manual Control

    • Fire Slow moves the trigger servo to the Fire Slow position. On the reference gun this is the slower firing speed.
    • Fire Fast does the same, for Fast.
    • Center recenters all the servos.
    • The sliders control the pan/tilt.

    Camera

    • The actual camera image being processed is shown.
    • Grab Timer determines how fast the webcam is polled. Since it doesn't re-trigger, you can probably set this really low.
    • The color determines how white a target has to be. You probably want it pretty high.
    • Size is how big a white blob needs to be to be considered a target. This will depend on your camera's field of view.

    Current Status

    • (x,y) is the current position on a scale of -100 to 100 and coresponds to the manual control sliders.
    • Target is the number of white pixels being detected.
    • Time is how many seconds have passed since "Enable Webcam Control" was checked.
    • When the gun is firing the words "FIRING" are displayed.

    Behavior

    • The COM port is what serial port the pololu is attached to
    • The camera can be turned on or off
    • Enable Webcam Control enables automatic operation
    • Enable Firing is the software safety switch
    • Recenter every 30 seconds does just that, it helps prevent the software getting stuck trying to hit an unhitable target.

    Logging

    • Lots of debugging stuff is printed out here.

    The goal of releasing this reference design is to get people started on a bot easily and with a better idea of what it takes to get a working bot. In the past, build costs skyrocketed easily and outside of our expectations. With this design, you will be able to have a working bot up and running for about the price listed here.

  • Questions? kallahar@kallahar.com