Introduction: Play Fetch With Your Dog From Your Phone
Do you miss your dog while you are at work or on vacation? Wish you could give your dog a big warm hug and play fetch, just like if you were in person? Well, if you want that badly enough, go home! If not, here's the next best thing. It's an Instructable that will help you play fetch with your dog from anywhere in the world via your phone.
The software is designed such that you can easily integrate additional functionality such as big buttons for your dog to press or movement of different toys. But, for now, this is focused on playing fetch. The basic components are as follows
- Triggering mechanism - can be triggered from phone, laptop or Alexa
- Ball launcher controlled using ESP8266 and a 24V powered solenoid
- Ball receptacle using Arduinio Uno and an RFID reader
- (optional) Treat machine. I happened to build mine because I wanted the flexibility but you can use any programmable treat machine.
Note: ball launcher and receptacle can be combined on the same microcontroller if your physical layout allows. I kept them separate so I could hide the ugly ball launcher behind our TV.
Note 2: the screen shot of the email is an optional component, if you build a treat machine as well. It allows the sender to view the dog's activities rom the treat machine perspective
Step 1: Background
My girlfriend misses our dog Pickles while she's at work. For her birthday, I built her a treat machine (here is the Instructable). Now that we have the treat machine, there is a whole world of opportunities to play with Pickles from anywhere in the world. One thing he loves is to play fetch so we built
Step 2: Materials and Fusion360 Files
If you have a treat machine, the materials are fairly simple. Note that, due to the layout of my apartment, I had to separate the ball launcher from the ball container so this doubled the # of microcontrollers that I needed and generally made everything slightly more complicated. If you can combine them together, you'll likely modify the design as well, perhaps to make the balls automatically feed back into the launcher.
build your own using my Instructable
Or interface with another one by modifying the Arduino code
36" tube - 2.75" inner diameter, 3" outer diameter - I got mine from TAP Plastics
3d printed parts
Wall mount - I used a 10" x 36" piece of walnut plywood that I had laying around but anything will do
Ramp - I used a ~2' 1x6 piece of walnut I had laying around but anything will do
RFID tags for inside the hockey balls
24V power supply to power the solenoid
Logic level converter - because the ESP8266 is 3.3V and the transistor needs 5V
Breadboard materials for this Instructable on how to wire a solenoid
1/4" acrylic. See attached files for the actual dimensions. How much material you need will be highly dependent upon how you cut it. I used a laser with a 32" bed.
Wires, power supply for the Arduino
Velcro - because it's always nice to use velcro while testing placement of parts, before finalizing things
bolts to secure the ball launcher to the wall
I've included the Fusion360 files here. Note that the files are a little different than the photos or .stl files because this is the newest version of files. Although they haven't been 3d printed yet, I'm fairly confident that these will be a slight upgrade from the current version in terms of reliability.
Step 3: Train the Dog
Training Pickles was perhaps the most difficult part. I had absolutely no experience in training complicated behaviors so that was part of my issue. But I do have some lessons learned that I can share here
First, I used clicker training. It's a technique where you first train the dog that a click means he did something right. As a result, you can give very rapid feedback and then follow the click with a treat. Very happy I learned this technique.
You'll find much more detail on the web and, because all dogs are a little different, I encourage you to read several sites so you can try different techniques until you figure out what works best for you and your furry friend.
Process I recommend following. My approach was slightly different, due to inexperience, but this is definitely how I would do it in the future. Once you've gotten the basics of clicker training underway, increase the difficulty of the task. Generally, I had to do 2-4 sessions for each of the first steps. The last steps took more repetition but now he has it nailed
- Look at ball (click!)
- Touch ball
- Put mouth on ball
- Pick up ball
- Pick up and hold ball in mouth
- Pick up ball, hold it and move towards receptacle - receptacle in middle of floor, close to me
- Drop in receptacle
- Drop in receptacle consistently (this isn't horseshoes - there's a big difference between near and in the container)
- Move receptacle farther away from me and closer to the final location
- Move your body around in different spots so the dog learns its the receptacle that matters, not the proximity to you
- Move farther away from the receptacle so the dog needs to decide which way to go - towards you or towards the receptacle
- Start over from the beginning but launch ball from the launcher. This is different, to a dog, than it coming from your hand. this round went much faster
Step 4: Create the Ball Container
I created the design for the container in Fusion 360. It was my first time using CAD software, yeah! Also noted so you don't make fun of any amateur techniques I might have used ;) Glad I learned it because I've now used it for a few other projects. There are a couple of photos of the actual box and a few more images that I took from Fusion360.
Laser cut the container pieces
I exported the individual bodies from Fusion 360 into Illustrator, which is the software I use to interface with the laser cutter. In Illustrator I created the notches that made assembly easy.
3d print the ramp
I 3d printed the ramp that the balls go down. You can see that the RFID reader goes underneath the ramp.
- The container shell should more or less snap together but I used acrylic cement to ensure nothing slipped.
- I then drilled a hole in one side (because I forgot to add it during the design phase) to slip through the power supply for the Arduino.
- To make the top pieces stay on, I cut small pieces of acrylic (approximately 1" x 1/4" x 1/4") and cemented those on as stoppers. See the photos for some examples.
- Connect the LED strip
- Connect the LED strip to the Arduino - see the photo
- Solder the RFID breakout board headers and connect to the Arduino. Make sure you solder the headers such that the RFID reader can lay flush against the ramp
- Connect the Arduino to the raspberry pi that controls the treat machine (see my other Instructable for how to build that) via USB cable. This will allow the two controllers to communicate via serial.
- Lay the Arduino underneath the ramp with the RFID reader flush against the ramp.
Load the Software
Step 5: Create and Mount the Ball Launcher
- 3d print the parts
- Attach 3d printed parts as shown in the picture. Notes
- A ~10-15 degree angle seems to be the best angle for the tube.
- 5 degrees was too low because gravity didn't always overcome ball/tube friction.
- More than 15-20 and the balls may pop out during reload
- A ~10-15 degree angle seems to be the best angle for the tube.
- Consider temporarily attaching the solenoid via velcro or tape so that you can move it around and make sure the ball launches as you desire before doing anything more permanent
- Attach to the wall mount first then attach the wall mount to the wall
- I used some bolts I had laying around - there's no magic here
- The cylinder is mostly free resting on the semi-circles but, for a little bit of extra friction, I taped on the soft side of the velcro. I found that to be better than having velcro on both sides because it takes some fine grain movements to get the cylinder situated perfectly. It hasn't moved on me with > 200 ball launch sequences.
- Follow the instructions here on how to connect an Arduino to a Solenoid.
- It worked for me except I needed to add a logic leveler to convert from the ESP8266 3.3V to the required 5V to trigger the transistor.
- See the pictures for the wiring for the logic leveler
- Using a hacksaw, I cut a narrow slit in each hockey ball
- Into each ball I inserted one RFID tag.
- Because we don't care what the actual ID is of the tag we don't need to track which tag is in which ball
In order to give it the kick it needed, I ended up using a 24V power supply for the solenoid. I originally tried a 9V and that didn't work consistently enough.
Location of the ball launcher
Because the girlfriend doesn't think that exposed wires and weird contraptions contributes to the design aesthetic of our condo, I decided to mount the ball launcher behind our TV. It's effectively completely out of site. The other nice thing about it being hidden is that I could keep the electronics on a breadboard.
Load the Software
You can load the code onto the ESP8266 whenever you want, of course. If you don't know how to do that, follow the excellent Adafruit tutorials.
Step 6: Using the Alexa for Both Testing and Fun
To test the end to end cycle, which requires holding treats and a clicker, I found it easiest to connect the Alexa to the controllers so my voice could trigger all the functionality. To set up the connection between Alexa and the devices, follow the instructions on my treat machine Instructable to set up Alexa->IFTTT->Adafruit IO
After that, add the ball launcher specific commands to the IFTTT interface. The major command I added was: "play ball".
- Raspberry Pi plays some music. He now knows that that music (a 6 second clip of Barry White) means a ball is coming
- Ball launcher has a 6 second delay so, as soon as the music is ending, the ball is launched
The RFID reader is constantly scanning for new RFID tags so it is independent from the Alexa. As you saw in a previous step, when it reads a new tag, it
- turn on the LED strip to let Pickles know he was a good boy
- turn on a music clip to let Pickles know a treat is coming
- After LED strip is on and music clip is completed, dispense treats
Step 7: Extension Opportunities
The software is flexible enough to easily add new ways of interacting with your furry friend. For example, I am currently training Pickles to press a big LED button, which can trigger the ball launcher, which ... It's not too complicated to get quite Rube Goldbergian with this (wait, did I really say that?)
Step 8: Summary
That's it! Please let me know if you have any questions. Some of the parts are in the process of being upgraded to make them more robust and/or reliable e.g. the cylinder attachments. The attached design files work - they are currently in use - but I'll upload the new ones after I've confirmed that they actually are significantly better.
The code is fairly stable so I don't anticipate major changes there.
Pickles is enjoying it so much that he now has a new place to hang out - right in front of the treat machine!
One of my challenges in making improvements has been my poor access to a 3d printer. my makerspace is somehow down to 1 functional 3d printer so I'm really hoping to get a 3d printer at home. if you like what I've submitted, please vote!