Monday, December 31, 2012

Loose arduino turret writeup

Because I didn't really document things as I went, and because my style of construction is absurdly haphazard, I wasn't able to write up a terribly good guide to making the turret.  However, here's what I was able to toss together.  Hopefully this should be enough to guide you in the right direction and help you learn stuff as you fill in the gaps, but unfortunately it won't be enough for you to sit down and build this from scratch if you don't have any previous fabrication or electronics experience.  If you have any specific questions about stuff (materials, wiring diagrams, detail pictures, anything like that) feel free to ask and I'll do my best to answer.

Turret writeup:

-Overall structure – the big picture
-Horizontal control – making it look left and right.
-Vertical control – making it look up and down
-Fire control – making it fire
-Electronics – the brain that ties it all together
-Specific links – links to components and code websites

Overall structure:

From a mechanical standpoint, the turret has three main pieces. There's the base, which remains completely stationary no matter how the turret moves. There's the body, which rotates on top of the base. There's the gun platform, which rotates up and down while rotating left and right with the body. The main structural material I used was lexan, although some other plastic, plywood, or (if you're careful about avoiding electrical shorts) metal would also work.
The base is simply a 12” by 12” square of 1/4”-thick lexan. It has a lazy susan bearing bolted to its top, and in the center of the square (centered with respect to the lazy susan) is a large sprocket gear that's used in the horizontal control.
The body is mounted atop the lazy susan, to allow it to rotate freely with respect to the base. It's bolted on top of approximately 1 1/2” spacers (in my case, I used extra nuts on the bolts) to leave room for the gears that allow horizontal movement. On top of the body's panel are two upright legs, atop which are situated bearings that hold the axle of the gun platform.
The gun platform is a 1/2” diameter lexan rod, to which two flat sheets of lexan have been glued (Weld-On 4 acrylic solvent makes connecting lexan to lexan ridiculously easy). I put pieces the same thickness as the axle between the sheets at each edge of the platform, to ensure that it was a consistent thickness. In order to connect the gun to the gun platform, I used electrical tape. Many more elegant solutions are possible, but this was basically the last thing I did when making the turret, so I was getting sloppy.

Horizontal control:

In order to power both the horizontal and vertical movement, I use motors taken from cordless drills. The one for horizontal control is affixed vertically, pointing down, to one of the legs. The chuck is still attached, and it holds a short length of 1/4” diameter steel axle. This goes through a hole in the body's bottom panel, and on the other side of the panel a small sprocket gear is attached to the axle. This sprocket gear is connected via chain with the large sprocket gear in the center of the base.
This motor on my turret is held in place by a strange series of wrapping done with spare 1/8” lexan rod. Gluing it in place, using hoseclamps to connect it to the leg, making some sort of bracket, duct tape, or almost anything else would be better, but it works.

Vertical control:

The motor to control vertical movement is mounted horizontally along the body's bottom panel, parallel with the axle of the gun turret. It's held in place by being tightly stuck in a large hole in one of the legs. The chuck of the motor holds another small piece of 1/4” diameter axle, that extends through a 1/4” hole in the other leg. On the far side of this leg, a small sprocket gear is attached to the axle.
The gun platform axle has a large sprocket gear attached to it, and it's connected to the motor's gear with a chain. To make the gun platform move more smoothly I've attached its axle to the legs with rotating bearings; for most purposes, 1/2” holes drilled in the lexan (or whatever material) will probably work almost as well, and be cheaper.

Fire control:

The gun I'm using is the cheapest electronically-triggered airsoft gun I could buy at the super-store down the street from my apartment. It's activated with just a small switch inside the body, connected via some levers and springs to the trigger. It's a pain to actually physically pull the trigger with a solenoid, so I just drilled into the gun body (it's transparent plastic, so it was pretty easy to figure out what to do) and unsoldered the wires from the switch. I connected these to two longer wires that lead back to the electronic control unit, where a relay closes the circuit to make it fire.
Because the batteries for the gun were stored in its handle, and I wanted to remove the handle to make it easier to mount on the gun platform, I had to replace them with an external battery pack. This is fairly simple – get an external battery pack of the same size (in this case, four AAs) and attach the leads to the two springs that connect the batteries to the internal gun circuitry.


To control the turret, I use an Arduino Duemilanove. It's an open-source microcontroller platform designed for hacky prototypes like this. I'm also using two Arduino “shields,” circuit boards with additional components that easily pop onto the Arduino. One of them is a Pololu motor controller to allow me to have precise control over the power and direction of each motor. The other is one that I made that has a Wii Nunchuck adapter and a pair of relays, chained together, to allow the Arduino to receive input (the Nunchuck adapter) and trigger the gun (the relays).
The motor shield just pops right on top of the Arduino, and the wires for the motors plug in easily. The relay/nunchuk shield takes a bit more work but is still relatively straightforward.

Specific links:

The motor controller: Pololu Dual MC33926 Motor Driver Shield for Arduino []
The wired nunchuk library: []
The wireless nunchuk library: []
The Arduino code: []

Saturday, September 22, 2012

Remote-controlled airsoft gun turret

I spent a good amount of time this spring making knives, but this summer I decided to move forward to the modern day.  As such, my free-time project for the last two months has been building a remote-controlled gun turret.

It started in July with a couple basic sketches while manning support at the Amazon Puzzlehunt.

I looked at a couple possible materials for the supports [various plastics, aluminum, and steel] and ended up going with off-brand Lexan because a) it's non-conductive and so won't interfere with my extremely hacky wiring, b) is strong yet not impossible to cut with only a Dremel and a Leatherman, c) is easy to glue strongly with solvent, and d) because it's clear, leaves the inner workings visible.  For the control circuitry, I used an Arduino Duemilanove that I had lying around, coupled with a motor shield for the movement and a shield of my own design for the relay chain necessary for the firing circuit.  To move it, I used motors from two thrift-store cordless drills.  (I had to go through four drills to find two suitable motors, but that's still far cheaper than buying the motors new.)

Both the horizontal and vertical controls make use of sprocket chains.  I considered using normal gears, but that would've required more precision (my tool selection is quite limited) and wouldn't scale well (without getting absurdly expensive).  I'd like to re-make this about five times larger for mounting in a pickup truck bed, so I wanted the design to be practical at a bigger scale.

For the gun, I used a cheap airsoft gun from the grocery store.  I needed something that was purely electrical, as making a mechanism to actuate a trigger and mounting it to a remote-controlled turret is just begging for the ATF to arrest me for making a machine-gun precursor (yes, this turret is sturdy enough to hold an actual firearm if it's properly balanced around the axle; no, I'm not going to actually do that).  The larger version will likely have a battery of model rockets, because it's impressive and takes advantage of the remote control aspect. (As an added bonus, if I add an angle sensor and a rangefinder, I could have it automatically calculate trajectories.)

The controller is an off-brand wireless Wii nunchuck.  Initially it used a wired one, but because the controls are on the part that moves, the wire was getting in the way.  It required re-writing one of the control libraries a little bit, but that wasn't a problem.  The top part of the turret is entirely self-contained, with the Arduino, motors, and power source, so I didn't need to worry about it over-rotating and catching wires or anything like that.  I'll have a wireless webcam for the larger version, but it'd be impractical on this one.

Overall, it works pretty well.  Because of some slack in the chains, and the low torque output of the motors, aiming is a bit jerky.  I considered improving the gear ratio and fixing the slack, but it'd be a lot of work for minimal gain.  Also, it's ugly as sin.  That said, in its current state, I think it's good enough to call done as a first draft.

Sunday, July 15, 2012

The target audiences of open-source vs. proprietary software

I worked for a few months as a developer at a mobile security startup working on encrypted text messaging (in order to prevent this from showing up in searches about them, I won't name the company).  It was a good learning experience, and I generally enjoyed the work.  However, the target audiences (as shown on their blog and in public presentations) seem to be a) people who sext and want to keep it secret and b) healthcare professionals wanting to avoid HIPAA lawsuits.
I also follow the development progress of the Guardian Project, an open-source collaboration to create secure mobile applications (in order to avoid running afoul of my various contractual obligations, I don't contribute to the codebase).  They posted an interesting piece in April about their targeted users, such as nascent social movements attempting to organize, diffuse organizations in oppressive countries, and journalists needing to avoid monitoring in foreign locations.  There's also been talk on the mailing list about the need for secure mobile communication applications among activists, human rights workers, and journalists in Cambodia (the talk was of Cambodia because of a specific case of an activist being killed by military police, but the need for secure communications is universal).
Clearly the difference in targeted audience can partially be explained by the need for a business to make money, compared with the more altruistic forces driving a non-profit.  I don't want to make it seem like the start-up is greedy and only focused on money whereas the Guardian Project is only focused on helping the world (I currently work for a massive corporation and not some charitable non-profit, so it'd be highly hypocritical of me to fault others for making the same decision).  Certainly helping doctors is good, and not all random organizations that will use the Guardian Project's software will be engaged in legal activities, but I think it's interesting nonetheless to compare the targeted users of the two groups.

Monday, April 9, 2012

DREAD/STRIDE applied to physical security and urban exploration

As some of you may know, I have an interest in urban exploration.  I also have an interest in computer security, and learning about that field has introduced me to two concepts developed by Microsoft to rate threats, DREAD and STRIDE.

DREAD is a method of rating the seriousness of a threat. Scores are given for five metrics:
Damage - how much damage an attack could do.
Reproducibility - once the attack's been carried out once, how easy it would be for the attack to be replicated against another target.
Exploitability - how difficult it would be to carry out the attack.
Affected users - how many people could fall victim.
Discoverability - how easy it is to discover that the attack is possible.

STRIDE is a way of remember the six main kinds of attacks:
Spoofing - pretending to be someone else.
Tampering - altering data.
Repudiation - doing things without leaving a way to show that you did them (if this doesn't seem like as much of a threat as the others, imagine if you could withdraw money from an ATM and then convince the bank that you didn't).
Information disclosure - gaining access to stuff you shouldn't see.
Denial of service - preventing users from having access to information or services that they want to use.
Escalation of privilege - gaining the ability to do things that you aren't allowed to do.

Also, a clarification on the difference between urban exploration (where my interest lies) and physical security: urban exploration is exploring areas not often seen, for the purposes of discovery, education, and the joy of seeing usually-unseen things.  Physical security is the field of securing physical places.  For some people, the two come into conflict, when they attempt to explore illegal places (I myself prefer to stick to legal places, of course, but for the purposes of this post, let's think about the kinds of urban exploration that require accessing illegal areas).  I think of it using a comparison to computer hacking.  There are "white hat" hackers who attempt to access systems with good intentions (usually finding security holes so that the owners of the system can then fix them) and there are "black hat" hackers who access systems to do illegal things like steal information.  Urban explorers are the "white hat" hackers of physical security, compared to the "black hat" hackers better known as burglars.

I think metrics like these could be very useful for dealing with urban exploration.  Both urban exploration and computer security deal with ways to gain access to places that are (believed by their creators to be) secure.  However, these kinds of places vary, in the same way that computer attacks do.  So, let's adapt STRIDE to classify urban exploration.
Because proper urban exploration doesn't damage the environment being explored, these parallels won't be as direct as with DREAD.  Instead of different forms of attacks, it'll be different types of exploration. (And I wasn't initially intending to use the same letters, but it started working out that way so I kept going with it.)
Secret places - Not as much a specific physical location as any place that's not specifically secure but just isn't known to people.  The biggest focus of legal urban exploration.
Tunnels/basements - A lot of places have underground tunnels that can be explored, or unfinished basements and utility spaces.  These are a big target for exploration, as they're interesting and don't have the same level of personal connection to one individual (and so it seems less invasive to explore them).
Rooftops - one big area of urban exploration is gaining access to rooftops.  Pretty self-explanatory.
Interiors - The interiors of buildings finish off the trifecta started by below (tunnels) and above (rooftops).
Deserted areas - I find a simply amazing amount of beauty in places that used to be inhabited or used by mankind in some way and no longer are.  Whether it's deserted buildings, abandoned towns (Pripyat, Ukraine is a prime example, as are the ghost towns of the American west), or ancient ruins, they're always popular places for exploration.
Engineering/construction sites - Okay, this one was tough to get to fit the letter.  Buildings that are still being built are another of the big areas of exploration, and although once completed they'd fall into the tunnels/rooftops/interiors categories, they're definitely distinct when still under construction.

So that's STRIDE applied to urban exploration, and I think it covers almost all places people explore.  Now, on to rating those locations.  DREAD is used to rate the seriousness of a risk, and so when applied to exploration, it makes sense to have it be a rating of how likely people are to explore a place.
Desirability - How desirable is a place?  Does it have a good view, or interesting contents?  Does it look cool?  Basically, all other factors aside, how much people would want to get to the place.  If a place is extremely desirable, that'd be a rating of 5, if it's pretty boring, that'd be a 1.
Risk - How risky is getting there?  Some places are completely safe - you just walk there.  Others are absurdly risky, either because of injury or getting arrested - you climb the side of a building, or walk through a constantly-monitored hallway.  This one is rated the opposite way from how it might make sense to - if it's exceptionally risky, it's a 1, if it's safe, it's a 5.  (This is because the overall DREAD score is supposed to be a measure of how likely people are to explore a given area, in the same way that the computer security equivalent is a measure of how important it is to secure a system.)
Ease of access - How easy is it?  A location can be risky but overall easy to get to (you only need to walk through a door, but the door is almost always guarded) or absurdly difficult but not really risky (an abandoned building that requires a ten-mile hike to reach it).  1 is difficult, 5 is easy.
Affected locations - How many places are accessible in this method?  If ten roofs can all be accessed in the same way, once somebody's gotten to one, they know how to get to the rest.  However, if all the roofs somewhere are easy to access, but each one in a vastly different way, it might actually be easier to get to all the roofs where access is difficult but the same.  1 is if the method of access is unique, 5 is if it's the same a lot of places.
Discoverability - How easy is it to find out how to get to a place?  Difficult to find is a 1, easy to find is a 5.

There is still, of course, the question of why this is useful.  It could be used to rate urban exploration opportunities, but in my experience explorers couldn't care less about a number attached to an experience.  However, there is one group of people who would care about something like this, and that's the people in charge of stopping urban exploration.  When prioritizing measures to stop burglary, it's easy - you start by securing the most expensive or sensitive stuff, and then work backwards.  But with urban exploration it's not so easy.  If you take the approach of securing the very riskiest places, in the name of safety, you're only helping keep a few people safe, as opposed to much more frequently visited places that are only a bit less risky.  Alternately, if you focus on the most-visited places, you might leave unsecured some places where people could get seriously injured.  What you need is a metric that combines all of these different factors together, hence the usefulness of DREAD.  A place like the Rotunda roof might be dangerous and desirable, but it's also risky, difficult to reach, and is only a single place, so it'd score two 5s but three 1s, giving it only a combined 13.  Something like the UVA steam tunnels, though, would get around a 3 for desirability, 3 for risk, 4 for ease of access, 4 for affected locations, and 5 for discoverability, giving them a much higher score of 19, and thus indicating that it'd be more useful for people to try to secure them.  (And, as it turns out, I've heard about a lot more about security being added to the steam tunnels than I have about security being added to the rotunda.)
So, do people at places like UVA actually use this method?  Not as far as I know.  If I had to guess, I'd say they work based on two factors: how well known a destination for exploration is, and how easy it is for them to secure it.  This is great for giving an outward impression of safety, but by only taking into account two metrics instead of considering all five, UVA is missing out on potentially securing some prime targets for urban exploration.
(And I'm not going to complain about it one bit.)

Saturday, March 31, 2012

Running and injury update, and preview of a post that might actually be interesting

I'm working on one of those essay-ish posts that doesn't really relate directly to my life, just tangentially to my interests.  I'm hoping to finish it tonight, but I might not, and definitely not before it switches over to April for the vast majority of you on the east coast.  The title will be "DREAD/STRIDE applied to urban exploration" and hopefully it'll be potentially interesting to a few of you.

Anyway, that's a different post.  This one is a continuing update on my running and various injuries.  So, an activity-by-activity breakdown:
Running - this one I've been able to keep up with.  I just got back from a 7-mile run, putting my total for the year at 78.5, and I'll be doing another 4 tomorrow to get to my goal of 15 this week.  So far I haven't had any injuries to derail this one (since the stress fracture last fall, of course).
Parkour - this one I haven't been able to keep up with.  In mid-February my organization at work had an outing to go snow tubing.  While going over a jump I came off the tube and landed badly, on my side with my arm extended over my head, and my shoulder's been hurting ever since (on the other hand, I've witnessed far worse injuries from accidents like this, so I'll consider myself lucky).  I kept up with parkour for a few more weeks but then two weeks ago put that on hold to give it time to heal (climbing and pull-ups and push-ups don't combine well with hurt shoulders).  It was getting a lot better until Thursday when I was in a bike accident on the way back from work.  The accident didn't hurt it at all, the only thing that did was skin my knee, but having to pick up the 480 pound bike definitely did something bad to it.  So it'll be at least a few more weeks until I can get back to parkour.
Kendo - I was doing this once a week at the parkour gym, and I haven't since I paused that.  Once the weather improves I'll start practicing in the park near my apartment, but at the moment my shoulder also makes swinging a sword a bit unpleasant.

Wednesday, February 29, 2012

February 29th New Year's Resolutions update

1. Eat pie - I've been failing at this one a surprising amount.  Living alone, and 3,000 miles away from my usual pie chef, has left me rather pie-less.  I'll make sure to get some in the near future, though.
2. I was able to start full-on running two and a half weeks ago, and since then I've done 23.5 miles.  I'm allowed to do 11 miles this week, and increase that a mile a week.  I'm going to see how long I can keep that increase going.  The first couple weeks will be easy, but when it gets to 20-30 miles a week, that'll be tough.
3. I haven't really lost any weight yet (although I haven't really gained any, either) but I've been working out more than I used to, so odds are the balance has moved a bit more towards muscle as opposed to fat.
4. I haven't climbed much, but I started going to a parkour gym three or four times a week, so I'll count that.
5. I haven't done much photography recently.  Definitely failing at that one.  It's tough to take pictures when it's dark by the time I get home from work.
6. I'm staying relatively organized so far.  Could be better, but it's a lot better than my living spaces in the past.
7. I've written a bit.  Wish it'd been more, but it's more than I was writing, so it's a start.
8. I've done a fair amount of drawing and I think improved a little.  Still needs a lot of work, though.
9. No community service yet.  I need to work on that.
10. Not sure how much of a better person I am, but given that I don't know many people out here, I've at least been able to avoid being much of a bad person.

Sunday, January 22, 2012

General life update

Sorry for the infrequent posts lately, but, well, I'm lazy.  However, a few things of note have happened lately:

1. I'm in Seattle - My long saga of finding a job has (hopefully) ended for a while as I got an offer from Amazon to work for them as a Software Development Engineer.  I moved to Seattle this past week and I start work on Monday.

2. My leg is (healing from being) fractured - In my distance build-up while training for a half-marathon last fall, I got a stress fracture in my leg (hence the abrupt halt in the Twitter updates about my running).  I was in a brace for a few weeks and on Monday get to start running (small amounts, sticking to a schedule) again.

That's about it for now, on the news-of-my-life front.  More will I'm sure come as I settle into place up here in Washington.

Saturday, January 21, 2012

New Year's Resolutions

First, last year's resolutions:

1. Eat pie - definitely succeeded.
2. Run 365 miles, including in the Charlottesville 10-miler - Success. I ran the ten miler, and in November hit the 365 mile mark as I crossed the finish line in the Richmond Half-Marathon. I did a few miles after that but wasn't able to do much as I found out a short while later that I have a stress fracture in my leg, and won't be able to run until mid-February (and even then, much less than I had been).
3. Lose weight to 160 lbs. - Ha. Not a chance.
4. Test in Myo Sim - I tested for my 3rd degree black belt in kendo, and passed.
5. Be more organized - Hard to say.
6. Build stuff - I built a bed, as previously mentioned, and completely reassembled my bike.
7. Climb stuff - I did a bit, but nowhere near enough.
8. Work on learning an instrument - I worked a bit on guitar but not enough to get much better.
9. Work on learning a language - Nope. I worked a bit on my Spanish in the spring but since then, nothing.
10. Be a better person - Again, definitely not my place to judge whether or not this was successful.

My resolutions for the upcoming year:
1. Eat pie - as always.
2. Run 365 miles, including the Tough Mudder and the GORUCK Challenge - I've shown I can run this far, but a) I won't be able to start until mid-February and b) I want to put more of a focus on endurance runs and overall strength, hence the non-traditional runs I've set as my goals.
3. Lose weight - If I can lose any weight at all this year, it'll be an improvement from previous ones. That said, if I can gain muscle while staying the same weight, that'd be fine, too.
4. Climb more - There are three climbing gyms convenient to where I'll be living and working, and as I don't currently have kendo filling up evenings, I have no excuse not to go. I was going to sign up for a membership today but the one I was going to join was closed today due to snow.
5. Do more photography - I did a bunch back in 2009 with the trip to Vietnam and Europe but it's fallen off a lot since then. I want to change that.
6. Stay organized - I just moved into an apartment in Seattle (post explaining everything about that to come) and I'll be living here for at least the next six months. It's currently not messy (even I have trouble getting a place cluttered in a few days) and I want to keep it that way.
7. Write - I haven't really written fiction in a few years now, and I'd like to give it a shot again.
8. Draw - I always feel like I'm right at the border of being happy with how I draw, and I want to practice enough to get over that hurdle and into the range of art that's at least good enough for me.
9. Get involved in some form of community service - In elementary - high school I had Boy Scouts, and then in college I (eventually) got involved in APO. Now I'm out in Seattle and I want to find some way to get involved in service. Not sure exactly what yet, but something.
10. Be a better person - partly a cop-out because I had trouble coming up with my usual ten, but also something I'll always think I need work on.