Enginursday: Mort and Mary Present...Fun with Sockets, Part Deux - Old Products Never Die

The most complicated, over-the-top, MacGyver-Van Damme'd remote-controlled laser!

Favorited Favorite 1

You know how I keep making projects and posts about Moose, my dog? Well, this is also about Moose! Even more about my laziness and how unwilling I am to stand out in Colorado winter temperatures to throw his ball around. His exercise is important to me, though, and now that I can’t be dragged across the pavement safely (because of ice) in the early mornings and late evenings, I’ve had to come up with a new way to keep Moose in good health.

In case you didn’t know, Moose is actually a cat in a very nice dog suit.

alt text

I want to give him the whole backyard to chase that red dot. I want to be indoors with a heated blanket and the internet.

Enter PiMooseCade

This system combines Mort’s Python programming skills, my clumsy hardware coaxing and Moose’s love for finding that red dot. This is a remote-controlled laser pointer. PiMooseCade uses the same socket network setup and message encoding/decoding as the project from last week’s Enginursday post, with the exception that this project is running two sockets—one for the controller data and one for the camera data. Using the parts from my crowning underachievement, the PiRetrocade, Mort and I cobbled together this necessary invention over the holiday break. Let’s start with a crude block diagram.

alt text

The PiMooseCade consists of two separate systems communicating over a socket to provide Moose with all the entertainment he/we need. The first system belongs on my desk. It is the PiRetrocade with a Raspberry Pi 3 reconfigured to map button presses to servo action. Up and Down on the joystick control the tilt, while Left and Right control the pan. An arcade button has been reconfigured to change the delay between each change in servo position. Holding down on A decreases the delay, thereby increasing the speed of changing position by 15X—all Mort’s idea. The second system, which is to be mounted on my back porch awning, consists of a Raspberry Pi 3, SparkFun RedBoard, Pi Camera Module, tilt and pan kit with two servos and a laser pointer mounted on top. From my desk I watch Moose chase after the laser with the video footage from the camera sent to my workstation via the socket. I control the position of the laser with my controller. Each button press is encoded by protobuf and sent over another socket. The Raspberry Pi outside receives the messages and forwards them onto the RedBoard. The RedBoard is running the client protobuf (in the code link below) to decode the messages into servo actions. Yes, I’m sure there was an easier way. And one day it will be made that way by us, but today is not that day.

We have here:

Why a RedBoard? Well, the PWM on the Raspberry Pi is terrible! The servos just jittered about, and the response time was dismal. We tried both software and hardware solutions to no avail. The best we could come up with to get something working quickly was to add a RedBoard to the mix.

alt text

Testing the controls over socket using protobuf. That’s where the laser goes, there on top. Pretty darn zippy.

alt text

Testing the outdoor system, controlled from the office.

alt text

From the laser’s point of view

The Complications—Still a Work in Progress

The video footage caused some major delays in the project’s progress. From my workstation we are VNC’d into both Raspberry Pis. I thought I would be able to capture the video data with Raspberry Pi’s “experimental screen capturing” using omxplayer. No luck.

Then we tried streaming the video footage over a socket from Raspberry Pi 2 to Raspberry Pi 1 using OpenCV then VLC. It was laggy to say the least—sometimes it worked, and sometimes it didn’t.

We tried a few other solutions before Mort came up with the idea of streaming the video footage directly to the workstation by sending the video data through the standard output and netcat'ing it to the workstation’s VLC player. It worked!

“Works like a senior design prototype, semester one, week eight, when you need to show your professor something,” says Mort.

We are still working on getting a less kludgy version up and running at our house. Once we have the system working according to the house spec, the updated files and video will be shared.

Finally! A project for cats as complicated as cats!


Comments 11 comments

  • There is an alternative to this laser pointer here (controlled from your smartphone): http://www.jjrobots.com/remotely-controlled-laser-pointer/

  • An Arduino Yun could be a good fit for this. You get a Linux system and AVR on one board, and the OpenWrt mjpg-streamer package gives you easy video streaming.

  • When I tried a laser with Abby, my black lab (who passed about 9 years ago), she figured out in less than two minutes where the “dot” was coming from, and then when she saw the dot, rather than chasing it, she’d come over and start “nuzzling” me. I think that Keyboard, my kitty (who passed about 7 years ago) also figured it out, but she still loved to chase the dot.

    Anyway, your project looks a lot like something I’ve been thinking about trying: A small robot with an on-board RPi sending back pictures from it’s camera, though my thoughts were to use keys on the computer to control movement. (Thus only one RPi.) I’ll take a look at your code in the next few days to see if I can get some ideas.

    • Keyboard is a great name for a kitty.

      Moose knows where the laser is coming from. If I have anything in my hands that even sort-of looks like a laser he starts looking around on the floor for the red dot. He’s nuts.

      I’d be interested to see how your project turns out.

      • “…If I have anything in my hands that even sort-of looks like a laser he starts looking around on the floor for the red dot. He’s nuts…”

        That’s not a good sign. If they can’t catch and eat it, they become obsessed with it. It’s the dog equivalent of crack cocaine.

        • Can confirm. My brother broke our parent’s dog with a laser pointer when she was about a year old. Now (9? years later) she still goes ballistic at any direct/bright light source, and will even chase shadows. If she knows you are about to handle a pan that usually causes reflections on the ceiling she’ll start getting excited…

  • First thing that came to mind was when a bug in the code makes the laser point up to the sky, into the cockpit of passing aircraft. Authorities quickly notified, knock at your door.

    Hilarity ensues.

Related Posts

Recent Posts

Tags


All Tags