Feature

Fido Feeder

Hungry No More!

Max Chuquimia

Issue 8, February 2018

Can robots feed your dog for you? Absolutely. Well, maybe...

Many of us have a furry friend who may need feeding when we’re stuck at the office, or out having a few drinks. Max came up with a method to remotely control a robotic arm kit using control relays and a Slackbot integration. The result is a relatively manual, but impressively functional method to feed your four-legged family member while away from home.

This is a great idea, and a solution many of us could use. What was the catalyst for this project?

As with most projects, the idea stemmed from a need. When we go out at night we tend to have to plan our times around feeding our dog Millie, so I built this “DogBot” to help with those occasions. Of course, the other reason I embarked on the project was to have a go at interfacing software with hardware over my own protocol.

We all love the challenge, but a practical use for the result helps spur the development for sure! Integrating it with Slack is a great idea - web sockets taken care of! Was that your first choice?

It was a toss-up between using Slack and Firebase - both provide super fast websocket abstractions for free. I chose Slack as I hadn’t written a proper Real-Time Slackbot before - it’s all about the challenge!

They’re both great platforms to springboard from, for sure. We’re familiar with these robotic arm kits. They’re pretty cool, but have no location sensing when they hit their range limits. Did you run into problems there, or add any range-limiting (hall effect, etc)?

This was at the back of my mind, but I still wanted to go ahead with the build for the fun of it. To provide feedback, I installed a camera on the Raspberry Pi and added a command to my Slackbot to take a photo and post it on the channel. It’s less than ideal, but in the end it’s good enough as I wasn’t using the arm to it’s full potential.

Sometimes the simplest feedback mechanisms are the best. At least you can get a clear picture (yes, we went there!) of what’s going on. How do you actually use the robot arm to feed the dog? Is it opening a hatch or something?

I trialled two ways to feed Millie. On my first use I simply commanded the arm to rotate, which then pushed food off a ledge (Millie has access to the laundry while we’re out so I installed the arm on top of the laundry fridge). For subsequent uses however, I rigged up a container of food to a string; when setting up the robot I made it’s clamp hold the string, and then I sent a command to open the clamp and then gravity lowers the container to the floor (the robot sat on a shelf and the string went over a rod to create a simple pulley).

Simple, yet effective! Is the process automated, or does it require manual control via the Slack channel?

Usage is extremely manual. Have a look at [1] and you’ll see that essentially, I write a structured message on the channel such as “run wrist up for 2 seconds” and the Slackbot detects the format and runs the given motor in the given direction for the stated number of seconds. I can also send the message “photo” and after a while the Slackbot posts a newly taken photo on the channel.

Manual, for sure - but if it works, that’s what matters! Can you explain how the Raspberry Pi GPIO is activated by Slackbot? Some Python interfacing?

The Slackbot is written in Python, so I access the GPIO via Python also (although I actually spawn a BASH process to take and upload the photo, as I have some issues uploading files via the Slack library).

The GPIO pins are connected to eight relays - each relay has a normally closed and a normally open state that I can work with when wiring. However, the robotic arm has 5 motors, which means a total of 10 possible functions (as reversing the current reverses the motor). So I carefully designed the circuit with each motor running through a relay (relays 1 to 5, counted from the left). When relays 6 and 7 are toggled, the current passing through relays 1 to 5 reverses! In my code, I (simply?) switch on combinations of relays to rotate motors in the direction I need.

[2] shows my first sketch of the controller that the robot arm comes with - on the side you can see how I figured out the places I needed to close the circuit to run the motors. [3] shows the actual wiring of the entire circuit.

2
sketch
3
relay board

For safety purposes, I use relay 8 to keep the entire circuit open when not in use. Rather than having it battery operated, I used an old mobile phone charger to power the robot arm, so I wanted to be sure I wasn’t shorting the house while we were out. Opening relay 8 also stops a short circuit from occurring when switching the direction of the current.

Prototyping
Prototyping.
raspberry pi and relay board
The Raspberry Pi and relay board being tested.
gripper releases a string tied to a cork for easy gripping
The gripper releases a string tied to a cork for easy gripping.
Installed in the laundry
Installed in the laundry.
container of food
A container of food is then lowered, so the dog can reach it (here they're testing with limes). Simple but works!

Awesome - sounds fairly straight forward! Is there anything else we should know about this project?

I just wish I’d taken more photos during the build! I’ve provided the source code (see Digital Resources). When I build these projects I tend to get them to work as quickly as possible, so digging into the source is a peek behind the façade (if there even is one). You’ve been warned! I’ve also provided some photos of it as it sits during use - unfortunately they are quite messy and dark (as laundries are). The bottles beside the arm are actually acting as counter-weights so that the weight of the food doesn’t drag the arm over.

We’ve all got messy source code somewhere, don’t worry. If you started this project from scratch again, with the knowledge you have now, what would you do differently?

Funny you should ask - I have actually started building it again! This time I’m using a Raspberry Pi ZERO W as it’s much more compact, and I’ve detached the clamp from the robot arm to use on it’s own (a single relay is much easier to maintain). Both the RPi and the clamp are each powered by a USB port, so I can simply plug it into a mobile phone powerbank, making it much more portable!

Here you can see how DogBot v2.0 has progressed so far. Oh, and I’m using Firebase this time too - controlled by a web page - so other members of the family can trigger it.

Fantastic! We look forward to seeing the result of the changes. What new and exciting project are you working on next?

Aside from DogBot v2.0, I did start work on a Theremin made with a Raspberry Pi and two ultrasonic distance sensors. But I accidentally fried the sensors so I can’t progress on that much until I get replacements.

Millie
Max's Cavalier x Japanese Spitz, Millie.
v2.0 in the works
Dogbot v2.0 is now in the works.

Theremin instruments are fun to use. Shame about the smoke release on the sensors, but we’re confident you’ll only do that once! Thanks for taking us through your dog-feeding robotic arm controller, Max.