HOWTO build a robotic squirrel-squirting water sentry-gun, with python

Kurt Grandis needed to fight the squirrels in his backyard bird-feeder. So he turret-mounted a Super-Soaker, rigged for computer-control, and used python to program it to detect squirrels (distinguishing them from other critters, such as birds), target them, and squirt them. In this 26 minute technical presentation from Pycon US, he explains how to teach a computer to answer the question, "What is squirrelness?" and to camp on the feeder and target them. The amazing thing is how it takes the infinite patience of a computer to outlast the persistence of a squirrel. Jump to 15:45 for about a minute and a half of pure gold squirrel warfare, complete with Wacky Sax.

Militarizing Your Backyard with Python: Computer Vision and the Squirrel Hordes (via Naked Capitalism)


  1. I’ve seen something similar done to keep the neighborhood kids from cutting through the backyard. Squirrels seem more persistent in intruding on the protected zone than the kids, but the kids spent more time testing the gun to see where its sensor range was and determining the “safe zone”. Oh, and it’s “Yakety Sax”, originally recorded by Boots Randolph.

  2. Anybody else think after seeing the video that it would have been easier just to release a real python?

  3. More than most such stories, this one encourages me to learn more about python and arduino. This is partly because I have worked ‘computer vision guided pointing’ projects before for my job. Though we were in a different performance category (and different cost category — tens of millions of dollars of development), I understand blob tracking and identification is hard. I’m amazed so much can be done with simple hardware and publicly available code.

    I’ve been hearing good things about arduino for a while now; this is one of the first public mentions I’ve seen of Python (I’m not a sw engineer or programmer, obviously). Supposedly it is much friendlier for quickly stitching things together or for use by non-expert programmers. If true, that’s appealing to me. Whenever I’ve tried to ‘revisit’ programming (which I haven’t done outside of matlab/mathematica scripting for a long time) I’ve been frustrated by the amount of infrastructure and ‘boring but critically precise code’ needed to ‘interesting code’ to do something.

    1.  Yeah, you’ll probably like python.  It’s flexible, you can just do scripting or you can do more ambitious object oriented stuff.  And it’s pretty easy to get the basic syntax.

  4. Natural selection and evolution says that at some point the squirrels will not mind – or will thrive on – the squirt attacks.  Think about it – breakfast and a free drink.  And then we will have a REALLY big problem on our hands.

    Honestly, I like squirrels and animals in general, but I think short of putting the bird feeder 5 meters off the ground and at least 10 meters away from any structure (tree, house, fence), greasing the teflon-coated pole the feeder is on and putting lightly electrified chicken wire around the bottom two-thirds of the pole (if not all of it) …you’re going to end up seeing squirrels eating the bird food.  It’s a free dinner, just there for the taking.

    Made for a good bit of vid tho.

    1. I think there’s plenty of steps to take in upping the ante before you need abandon the Super-Soaker solution. Possibly the most amusing would be adding some sort of fluoro dye to the water. You get the amusement of hilarious looking punk squirrels for a while and then the removal of natural camouflage means that predators impose some natural selection pressure the other way.

      More nefarious additives to the liquid (which I’m not actually suggesting, since they’d be cruel) are left as an exercise to the reader.

      1. Thanks for sharing, that was hilarious. Especially the contrast of the stoic announcer and the chipmunk voice-overs.

        Squirrels snacking on the bird feed, and the lengths they will go to do so, are always entertaining.

  5. Squirrels can be stopped with squirrel baffles. Baffles are simple, reliable, stress-free for the birds and won’t leave the birdseed wet and moldy.

  6. I’m a programmer who primarily works in Python and my first reaction was still “they built a robot python”?

  7. That’s a lot of work just to annoy a squirrel.

    Much easier to make use of evolution. Hot peppers are thought to have evolved to prevent mammals from eating the fruits. Birds have almost no sense of taste and so chomp them on down, thereby giving the seeds wide dispersal.

    Aha! So you take your seeds and give them a light coating of spray cooking oil, toss them liberally with cayenne powder, and stick them in the feeder.

    First time I did this, the squirrel took a couple of bites, then jumped 20 feet sideways and started wiping his face on the ground.

    No more problem. Very satisfying. You can even buy super duper hot pepper just for this purpose, but regular cayenne works just fine.

      1. Well, as I said, biologists think this is why hot peppers evolved in the first place. According the Wikipedia, “The fruit of most species of Capsicum contains capsaicin (methyl vanillyl nonenamide), a lipophilic chemical that can produce a strong burning sensation in the mouth of the unaccustomed eater. Most mammals find this unpleasant, whereas birds are unaffected.”

        If you don’t believe that, how’s about Cecil Adams?

        The thing is that capsaicin is only an irritant to mammals. It has to do with the actual structure of the molecule, which binds to mammalian pain receptors but not to those of birds. Other than that, it has no real biological effects.

        My birds were happy as clams. Their deposits on the lawn showed no evidence of bunghole damage.

        1. Thanks! I just gotta trust someone who cares enough to check droppings for bunghole damage.

    1. This…but I think one needn’t use the oil and powder – just mix in the chilli flakes – very effective.

  8. For the love of god, someone please make a kit version of this, but make it target pigeons. So much sleep lost to early morning pigeon cooing, so much time lost on cleaning pigeon poop…… the pain… the pain….

    1. I want one of these to target the damned neighbourhood cats that come into my garden and lurk near or under the Acer with the feeders in. Firing lemon juice with hot chili powder dissolved in it.

    1. Owing to the pesky effects of gravity, the feeder has to be suspended from something, and the squirrels can almost certainly climb that something.

      1.  …leading to the logical conclusion that the feeder should be suspended from an autonomous zeppelin. 

        With an optional fiery self-destruct in the event that it does somehow get overrun.

        1. Thank you for the mental image of squirrels in goggles and leather dusters brandishing cutlasses and boarding an airship.  Hopefully it will stay with me all day.

        2. -abs really [b]liked[/b] this response, probably because he’s in favor of autonomous zeppelins floating around backyards across the US, actually, definitely because of that, DEFINITELY  (zeppelins are awesome)

      2.  Squirrels/rodents can’t climb metal poles, so moving the moving the feeder, as pictured in the video, away from the trees will do the trick.

        If the yard is too heavily forested for that, then a sheet metal disc, approx 0.5 meters in diameter, placed above the bird feeder should also work.

  9. This ‘problem’ makes me wish I live somewhere squirrels do.

    Aside from them being just as cute and interesting as the birds to my eye, I could have endless fun tinkering at solutions.

  10. Got to love a geek who harnesses super soakers, AI and electronics  to solve what a few cents of plywood could do. Legend.

    Though the idea of working out “squirrelness” gives me the heebies. Uncomfortably close to the scenario in (IIRC) Robert Sheckley’s short story “Watchbird” where a squad of learning weaponised remotes are sent to discourage murder, and end up stretching the proposition to treading on an ant. How long before a passer-bye eating a peanut gets a facefull of supersoaker? Hello Skynet!

    BTW: “Yaketty Sax”, not Wacky. Unless you meant it as a description. Benny Hill will now chase you around at high speed.

  11. I purposefully feed the squirrels in my backyard.  I even bought a purpose built squirrel feeder that was difficult for birds to get into.  Why?  I dunno.  Don’t they have as much right to a free lunch as a bird?  Besides, the squirrels are permanent residents of the neighborhood.  Almost all the birds are passing through.  I’ve learned to identify a couple of the squirrels, and noted behavior patterns and personalities.  

    One problem I’ve had is I had to abandon the feeder, because there was one squirrel who would sit on it and chase away the other squirrels (the bully squirrel, who seems to bully in general and gets pissed when I’m late with the food).  So now I just throw it out into the yard, and both squirrels and birds enjoy it.

Comments are closed.