



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Our goal this semester was to improve our previous design of a robot capable of competing in the 2008 Defconbot competition held in Las Vegas as part of Defcon 16: August 8-10th. Visit www.defconbots.org for contest information. Essentially, the goal is to shoot down some number of round targets of a specific color, ranging in diameter from 1” to 3” in a 5’x5’ arena from 10’ away in under 2 minutes. Other than that, there are only a few other stipulations: your design must be completely autonomous, it must shoot something safe (like airsoft bbs), and it must have a physical “kill switch” to stop it in case it malfunctions.
Our design that consists of a gun mount to move the gun around, a circuit board to control the movement and firing of the gun, and a PC with webcam to do image processing on the target arena. The following diagram illustrates the dataflow: Target Arena CPU (Image Processing) Robotic Gun Assembly Trigger Servo Tilt Stepper Motor Pan Stepper Motor Control Circuit Camera
The portion of the project that controls the aim and firing of the gun consists of a gun mount capable of rotating around two axes allowing the gun to pan (left and right) and tilt (up and down). This motion is generated via two high-torque hobby servos controlled by a microcontroller. There is a third servo that controls the firing of the gun. There is also a software component on the PC that communicates with the microcontroller and allows the image processing portion of the software to control the aim and firing of the gun.
The hardware consists of a servo controller circuit, the servos themselves, and a gun mount. The servo controller and servos were all run off +5V from a Rosewill RV350 power supply. We decided to use a PSU because it’s more portable than the any of the lab power supplies.
Parts List Part Quantity Microchip PIC18F458 1 Maxim MAX232N 1 The PIC hardware is fairly straight-forward. The MAX232 chip allows the PC and PIC to communicate via serial port. The PIC simply outputs the proper PWM signals for the three servos.
Parts List Part Quantity Hitec HS-805BB Servo (180 degree rotation) 3 These servos (and all analog Hitec servos, as far as I know) take a PWM signal with a period of 20ms. The width of the pulse itself ranges from 0.9ms to 2.1ms, where each pulse width corresponds to the two most extreme positions of the servo and 1.5ms corresponds to the center position (see below). Note that these are theoretical values. The 20ms period is ok, but we found that our servos had slightly different pulse width values that corresponded to their extreme positions. One servo worked from 0.6ms to 2.3ms, one servo worked from 1ms to 19ms, and the third from 0.9ms to 19ms. It’s best to generate a PWM signal on a waveform generator, output it to the servo, then adjust the pulse width to determine which pulse width values work best for that particular servo. 0ms 0.9ms 2.1ms 20ms
The image processing component of this project uses a computer with webcam. Specifically we wrote the software in c++ because of speed and existence of an image processing library OpenCV (http://sourceforge.net/projects/opencvlibrary/) which allows easy interfacing with webcams. We transitioned from using an older Creative webcam to using a Logitech QuickCam Pro 9000. The major advantages of this camera are the zoom lens, high resolution, and sophistication of camera configuration via the packaged Logitech software. The general idea is we identify the target locations from the webcam image and determine the guns position based on the location of a laser beam mounted as a gun scope.
Once the entire system is assembled and powered on, launching the software will connect to the PIC circuit via serial port as well as acquire image data from the web cam. Image data will be displayed in a window and the cursor will resemble a cross hair. Clicking on any region of the image will store that pixels color data to a buffer. The following keystrokes are controls: T(t) – Save buffered RGB value as the color of targets. L(l) – Save buffered RGB value as the color of the laser. A(a) – Begin automation of target shooting. S(s) – Stop automation of target shooting. Esc – Exit software
TargetBot.cpp is the entry point for the console application and is what sets up the global event loop. This file defines two constant values (how many frames to skip between processing and the number of pixels to skip over in scanning a single frame) which can be adjusted for changes in requirements. The main event loop passes frames into FindTarget which is the class responsible for locating targets, locating gun positioning, and moving/firing the gun via the libroboctrl discussed earlier in this document. FindTargets also has constants defined at the top for fine tuning algorithm operation. The FindTarget event loop (defined in executeAI) operates as follows:
The target arena is built out of 2’x4’s and is painted black. It is roughly 5’x5’ and has 3 shelves for targets, spaced roughly 1’ apart vertically. The targets are made out of poster board, and taped to hinges so that they can fall backwards.