ALLAN JAMES EDGAR

Motion Tracking BB Gun Turret


Home Hardware Software Venture

This was really my first foray into computer vision. After a conversation with one of the members of the Nottingham Hackspace about how the basics of frame by frame background subtraction worked I set my mind to making an autonomous BB gun turret. I used a webcam plugged into my laptop using an open source webcam interpreter program. First I smoothed each frame and subtracted it from the previous to reveal approximated motion. I next thesholded the size of the motion blobs and implemented a centre of mass algorithm to calculate how the servos should move the BB gun mount and commence firing. My first glaring issue was that of calibration the parralax between the camera and the turret was very important and needed test/calibration routine every time we got kicked out of a room :S. Another step I took to improve this was to positively attatch the camera and the turret. This was before my 3D printing days so the mount was a rudimentary wooden construction but it worked.

I found that this basic setup looked scary but wasnt scoring many hits on my willing test subject. The control system, if I can even call it that, was lagging so I incorporated an azimuth speed calculator. That angular speed was input to a rudimentaty feed forward estimator which increased the accuracy a fair amount, much to my test subjects dismay.

The next imperfection I identified was the inherent inaccuracies in the servos so I replaced them with stepper motors. This setup was entertaining but was inherently limited by the cameras field of view. The next natural step was to attatch the camera to the gun mount itself however there was added complexity in discriminating world motion from camera motion. This proved to be a significant challenge. The solution that I created was to stitch together a world baseline by taking a preliminary scan. This was then used for a more complex background subtraction. A bonus of this was that it significantly simplified the motor control. Instead of calculating angles from the frame it just needed to keep the target in the center of the image (plus or minus the predicted motion).