January 29, 2013

Autonomous Anti-Mouse Sentry Turret

For Bad Ideas I built a computer controlled anti-mouse sentry turret.  The turret uses a video feed from a webcam and a slightly modified version of the Project Sentry Gun Processing code to track mouse-sized objects that move across the camera's field of view.  It fires at the objects using a hacked electric airsoft gun on a pan/tilt servo platform.


The servos arrived from HobbyKing an unfortunately short amount of time before the start of Bad Ideas, so I had only three days to build, test, and calibrate the sentry.  

The pan-tilt assembly was made from scraps of aluminum I found around MITERS.  I used as thin metal as possible to make the sentry light and responsive, and also easy to machine within my time constraints.  The tilt axis is entirely supported by the servo's output shaft, while the panning is supported by a small set of lazy Suzanne bearings, with the servo in the center.  



I removed all the unnecessary parts from the airsoft gun, like the trigger, handle, sights, and other decorative plastic bits.




To control the small DC motor that fires the airsoft gun, I just wired some small NPN transistors I had in parallel and added a diode across the motor output.  I heatshrinked over the whole thing to make it look like a real motor controller.


I used the webcam from a 2006 iMac computer.  Although these webcams are internal, they run over USB.  I spliced its four wires to those of a standard USB cable, and stuck the camera just below the pan-tilt assembly.


To get the Project Sentry Gun code to work for my setup, I had to make a few minor modifications.  First, I completely erased the stock firing code and replaced it with one line to simply turn the fire pin on the Arduino  to HIGH.  Also, by default, the motion tracking bit of the software has a lower limit for the size of moving objects it will target.  It locks onto the largest moving object above this threshold.  In addition to the lower limit, I added in an upper limit, so the turret will track things that are roughly mouse-sized, but will ignore larger things like people.

With no target, the crosshairs on the webcam overlay are thin:


When there is a small target, the crosshairs are thick and the target is boxed in red:


If the object is too large, it is ignored:


5 comments:

  1. That's cool. http://www.realsentrygun.com/ has even better systems for that kind of stuff. Have you seen their videos? Crazy stuff!

    ReplyDelete
    Replies
    1. Thanks. That software is neither free nor open source though.

      Delete
    2. You had to pay for that arduino. Their 'starter kit' comes with a better servo controller, the software, battery leads etc and is $50. THat's cheaper than what you paid. I've tried both systems and the RealSentryGun.com system performs far, far better. They've been around a lot longer so their stuff is much more refined. Their stuff was used by Valve, the discovery channel, and other shows. You gotta have higher standards man ;)

      Delete
  2. great stuff!
    any videos of it in action?

    ReplyDelete
  3. Do they jitter when the pan and tilt system moves? Since I think you didn't put gears in them.

    ReplyDelete