Saturday, August 21, 2010

Arduino meets Sniper Training

Maybe I've been watching too many movies featured old guys past their prime shooting at evil faux-communist puppets ruled by evil capitalistic interests. Or maybe I haven't been watching them enough :-)

Anyway, Bjorn sent over a few weeks ago some really cool cases that he built for the Arduino, and one of them was camouflage. The second I saw the case, I had the same idea that anyone would normally have, when they see a smooth, camo Arduino case... time to make a sniper training ballistics tracking app for the Arduino.




So I did some research, and learned that there are actually a number of different, and sometimes conflicting theories about how sniper's should train, and how much thought to put into ballistics tracking. As an aside, I really want to go to the GPS Sniper Training School - I am not in any way endorsed by them, but it looks fun. It didn't take long for me to get in over my head, and then I figured, that probably the most helpful app I could write, would be one that helped me calculate spread, grouping density, and cluster metrics for accuracy training.

I really liked the look of this target, inspired by the Aguilar training system:

So I decided to program it into the TouchShield Slide:


The app is pretty straightforward, it lets me keep track of the shots I take, and then I can do analytics and measurement stats on the Open SciCal calculator. This is a pretty sure-fire guaranteed way to look like the biggest nerd at any firing range across America.


It took me less than 15 minutes to write that code for the Arduino and TouchShield Slide, and I had a lot of help using the function reference over here at the liquidware wiki. The functions are all inspired by the Processing programming language, so it's intuitive to pick up if you've ever written graphics for Processing.

And then I went to the shooting range, and set up at the prone position station, with the Open SciCal, and the Arduino Sniper Bullet Tracker gadget:

Here's the source code for the program (it's available at the Open Source "App Store" too):


int q;
int bulletx[30];
int bullety[30];
POINT npoint;
int debounce;

void draw_sight(void){
background(0,0,0); stroke(128,128,128); fill(0,0,0);

rect(5,5,40,25); text("New",7,12);

rect(5,210,40,25); text("Clear",7,217);

noFill(); ellipse(199,120,120,119);
ellipse(199,120,100,100);
ellipse(199,120,80,80);
ellipse(199,120,60,60);
ellipse(199,120,40,40); fill(0,0,0);
}


void setup()
{
q = 0; draw_sight(); debounce = 1;
}


void loop()
{
if(touch_getCursor(&npoint)) {

if (npoint.x > 5 && npoint.x <> 220 && npoint.y < q="0;"> 5 && npoint.x <> 5 && npoint.y < debounce="1;" q ="="" q =" 0;"> 60) {
draw_sight(); debounce = 0;
}

if(npoint.x > 60) {
bulletx[q] = npoint.x; bullety[q] = npoint.y;
}

fill(200,0,0);
noStroke();
for ( int j = 0; j <= q; j++) { if (bulletx[j]>40) {
ellipse(bulletx[j],bullety[j],5,5);
}
}

}

}


Here are a couple videos:






I uploaded some other pictures onto my Flickr page... in case anyone's interested.

I also put all the parts I used together into a kit, called the Arduino Field Gadget.

Enjoy!

2 comments:

Matt said...

I've gotten a number of emails asking, so I'm going to clarify: that's a Smith & Wesson on the left, and a Remington 700 CDL on the right. They're pretty standard fare for target shooting at cans and watermelons...

Chris Gammell said...

I hate to admit, but I had to re-read this a few times after getting linked over here from the Make blog. They write "just tap the touchscreen with the tip of a round to mark a hit" and I couldn't unwrap my mind from the idea, "If the tip of a round 'taps' the screen (like when I fire it), won't it just blow the whole thing away?". I get it now, but it took me far too long to figure out this wasn't being placed in the field as an actual target (duh, Chris). Anyway, nice use of the touchscreen though!