JeremyBlum.com

Nerf Sentry Gun…be afraid.

The nerf sentry gun was developed as a final project for Cornell University’s CS1114 Matlab Robotics class.  Jason Wright (www.jasonline.net) and I worked on the gun together, and were awarded “coolest final project”.

Check out the video of the gun in action, and see how we built it:

READ ON FOR PICTURES, SOURCE CODE, AND A COMPLETE FEATURE LIST

FEATURES

Authentication Mode
This tells the gun to actively prompt things that move in front of the camera for badges and then shoots them if they fail to present a badge. Anybody who enters has their image uploaded to the web (cs1114.jeremyblum.com) along with the date of entry, and whether or not they were approved to enter. This information is twittered as well (www.twitter.com/nerfsentrygun)

Freefire Mode
Tracks and shoots anything that moves.

Panic Mode
Plays a siren, turns on the gun, and rotates the gun semi-randomly.

Manual Mode
Allows you to control the gun manually.  Arrow keys rotate the gun and the space bar fires.

HOW IT WORKS

Matlab Image Tracking
A matlab program is responsible for performing all image tracking tasks.  A USB webcam and the image acquisition toolbox allow matlab to capture a video stream and analyze frames to ascertain velocity vectors.  Scale-Invariant Feature Transform (SIFT) image recognition software is used to identify a badge in authentication mode.  A custom matlab GUI is used to switch between modes, change color maps, and more.

National Instruments USB DAQ-6008
This digital I/O device was interfaced to matlab using the data acquisistion toolbox to allow for control of the trigger and gun.  Channel 0 outputs a 5V signal to a mosfet in the handle of the gun that activates the trigger.  Outputs 1 and 2 connect to a basic stamp motherboard for control of the rotation servo.  Matlab can be used to turn these outputs on or off at the appropriate times.

Basic Stamp 2 and Motherboard
A basic stamp was responsible for controlling the rotation servo.  Upon receiving an input signal from the DAQ, it will rotate the servo right or left (depending on which input was activated).  It also interfaces to two hooks that sit behind the gun and act as limit switches.  When the gun rotates all the way in one direction, a hook on the gun attached to a 5V rail makes contact with a hook connected to the basic stamp.  This sends a 5V signal to the stamp on this channel so the stamp knows to stop rotating the motor.

Trigger Circuitry
A trigger circuit was assembled in the handle of the gun, it runs in parallel with the existing trigger, so the gun can still be fired manually.  Sending this circuit a 5V signal from the DAQ tells it to close the motor circuit and fire the gun.  The schematic for this circuit is included in the download below.

Physical Setup
A futaba servo is attached to the bottom of the gun.  Modifying the original tripod mount allowed us to attach it fairly easily.  Unfortunately, this motor does not provide a huge amount of torque.  This is why the gun turns somewhat slowly.  To compensate slightly for this, we made the battery pack external to reduce weight on the motor.  This motor setup is attached to two metal napkin holders (totally not stolen from a dining hall) using gorilla glue.  The entire setup is on a cardboard sheet to maintain proper spacing.

SOURCE CODE AND SCHEMATICS

These materials are made available via a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.  Feel free to modify and improve upon this code as much as you like, but share your improvements and credit myself and Jason Wright as the original authors.  Please do not use this code for commercial purposes without first asking for our permission.
Creative Commons License
Download Nerf Sentry Gun Source Code and Schematics

PHOTO GALLERY

MATLAB FUNCTIONS UTILIZED

MATLAB SIFT Function by vlfeat.org
MATLAB twitter Function by Navan Ruthramoorthy
MATLAB passive FTP Function by Idin Motedayen

33 comments

33 Comments so far

  1. [...] worked on as a final project is completed. You can view the video, photos, and source code over at Jeremy’s blog. Category: Uncategorized You can follow any responses to this entry through the RSS 2.0 feed. [...]

  2. [...] another hacked Nerf Vulcan rifle. This time it is an automated sentry gun. You must present it your badge, if no badge is found, you are assaulted with a fiery storm of [...]

  3. Joshua T May 17th, 2009 1:27 pm

    Very nice work, awesome documentation

  4. Jeremy Blum May 17th, 2009 3:25 pm

    Thanks!

  5. [...] another hacked Nerf Vulcan rifle. This time it is an automated sentry gun. You must present it your badge, if no badge is found, you are assaulted with a fiery storm of [...]

  6. [...] another hacked Nerf Vulcan rifle. This time it is an automated sentry gun. You must present it your badge, if no badge is found, you are assaulted with a fiery storm of [...]

  7. Tom Hefner May 18th, 2009 2:57 am

    Hi,

    how do you do the position tracking in automatic mode?
    I.e. how do you aim at the intruder.

    Do you use SIRF features for this, too?

  8. [...] L’intérêt de la chose est plutôt évident !!! Il faut que vous vous en fabriquiez un pour vous défendre de collègues trop collants au bureau et ainsi pouvoir bosser en paix ! Les mecs ont mis le code source et toutes leurs explications sur le site. [...]

  9. [...] remote-control weapons here on SlashGear before, but this Nerf Sentry Gun is particularly slick.  Designed and created by Jason Wright and Jeremy Blum as part of their robotics class at Cornell, the sentry uses a webcam [...]

  10. [...] remote-control weapons here on SlashGear before, but this Nerf Sentry Gun is particularly slick.  Designed and created by Jason Wright and Jeremy Blum as part of their robotics class at Cornell, the sentry uses a webcam [...]

  11. [...] remote-control weapons here on SlashGear before, but this Nerf Sentry Gun is particularly slick.  Designed and created by Jason Wright and Jeremy Blum as part of their robotics class at Cornell, the sentry uses a webcam [...]

  12. Jeremy Blum May 18th, 2009 4:07 pm

    Tom – SIFT to slow to use for real-time motion tracking. Instead, we compare frames to determine locations of movement.

  13. [...] studenata je velikodušno ceo projekat stavila pod CC 3.0 licencu i ponudila vam sva uputstva za pravljenje kao i code source zle naprave ;) Tekst tagovan pod: CS1114, Nerf Sentry [...]

  14. MrKikkeli May 20th, 2009 10:03 am

    Beware of spies sapping your sentry !

  15. [...] admin el May.24, 2009, bajo Noticias En su blog Jeremy Blum, nos describe su proyecto de una ametralladora centinela Nerf, el cual ha sido realizado para el curso Introducción a la computación usando Matlab y robótica [...]

  16. Alexander Scott July 22nd, 2009 2:12 pm

    where is the part of how you made it

  17. Jeremy Blum July 22nd, 2009 7:54 pm

    All of the info is in this post…Download the source code and schematics if you are interested.

  18. Firewall246 August 18th, 2009 10:19 am

    Hell,that’s the best gun i’ve ever seen!How does the computor know if the badge is correct,i mean,a badge could be anything!

  19. Firewall246 August 18th, 2009 10:22 am

    Hey Mrkikkeli,If spies were here,the sentry gun would shoot them!

  20. Jeremy Blum August 18th, 2009 12:39 pm

    An image of accepted badges is stored in the computer. A program called Scale-Invariant Feature Transform (SIFT), is used to determine if the badge presented matches the one stored in the computer.

  21. william August 26th, 2009 6:38 pm

    how much was it and I like it

  22. Jeremy Blum August 27th, 2009 1:14 pm

    I don’t have an exact price, I already owned much of the parts. WE had to make about $150-$200 worth of new purchases.

  23. Robin October 7th, 2009 12:00 pm

    Hey guys,you hav done an excellent job,Of course i just wanna to run ur codes in my matlab stimulator but i couldn’t, can you help me guys

  24. Robin October 7th, 2009 12:03 pm

    Hey guys u hav done a great job, i hav downloaded ur source code, when i make it run in my computer it shows me some error,con u help me guys

  25. Jeremy Blum October 9th, 2009 12:30 am

    What is the error?

  26. Robin October 12th, 2009 12:46 pm

    Hey i think , i have work it out wrongly…So wil u guide me or send me a mail, the procedures how 2 work it(i hav matlab R2007b)..Plez
    My id s Edyroby25@yahoo.com

  27. Tyler January 11th, 2010 2:49 pm

    Would you find sending me instructions of how to set up the software and run it in matlab R2009a? Can you run it just in matlab to test it? I want to hook this up to a paintball gun with the same concept of yours.

  28. Jeremy Blum January 11th, 2010 10:04 pm

    You’ll have to execute the files in the MATLAB environment. Makes sure you’ve downloaded the functions that I mentioned in my post. The comments in the M-files should explain what you need to know.

  29. Ben January 27th, 2010 7:20 pm

    I see in the first photo that the slide is in place on the gun. How did you manage to get the slide off? Did you have to cut it?

  30. Jeremy Blum January 28th, 2010 10:12 am

    It’s very difficult to get apart once you get it on the gun. We didn’t cur it, but we did use a combination of pliers, a screw drivers, and two people to pry the plastic cap off.

  31. name February 26th, 2010 2:43 pm

    cool if it had some sort of facial recognition thing so it would shoot only certain people
    especially in a nerf war

  32. [...] trouverez les instructions de construction et les logiciels en droits ouverts à cette adresse : http://jeremyblum.com/2009/05/15/nerf-sentry-gun_be-afraid/et vous pourrez les améliorer vous même avec l’arme à feu de votre choix. On arrète pas le [...]

  33. [...] ambitious, but if we can get it to work, it’s gonna be really cool (Hopefully on par with the Nerf Sentry Gun from last [...]

Leave a reply