Pi2D2 – Wifi, Webcam, Video Projection, R2D2, and You!

Hacking the 15″ Hasbro Interactive R2D2 isn’t new, especially when it comes to using a Raspberry Pi to make him do all sorts of entertaining things. Still, it looked like fun, so I decided to do my own version… despite the lack of originality.

Here’s what I features I decided to include in my hack:

  • Fully controllable over a wifi internet connection via a web browser. I wanted him to be my own little Mars Curiosity rover.
  • Webcam capabilities. I wanted to see what he sees, so that navigating him remotely over wifi to terrorize my cats would be easier.
  • Video projection. Hologram technology isn’t quite there yet, but I figured his ability to project movies on a wall would still be pretty entertaining.
  • Sound output, with a large bank of samples that can be played remotely on command.
  • Some sort of control pad, so that I can maneuver him even if there is no wifi network within range.
  • Turn him into a Roomba. Okay, not really. But wouldn’t that be awesome?

In the end, the following hardware was utilized:

Audio/Video/Data:

1 Raspberry Pi Model B
1 8 gb SanDisk Extreme Pro SD card (for the operating system)
1 16gb HP USB Flash Drive (for storing all sound and video media)
1 Belkin 4-port powered USB hub
1 Edimax wifi usb dongle
1 SD card extender cable (optional, really)
1 USB extension cable (the shorter the better, or you can splice your own)
1 Mini PC keyboard with RF USB adapter
1 Logitech C270 webcam (this was before the Pi camera was available)
386AMP audio amplifier
Optoma PK102 PICO Pocket Projector

Mechanical:

2 Dual H-Bridge Motor drivers (Probably a bit overkill for this project, but it was the board I was most familiar with already)
1 small 5v solenoid (more on this later)
1 TIP120 transistor (for use with the solenoid)

Power:

2 5A SBEC voltage regulators
2 Tenergy 11.1v 1150mAh LIPO rechargeable batteries with PCB protection
1 TLP-2000 Tenergy Universal Smart Charger

And last but not least, the Hasbro Interactive R2D2 toy itself. I recommend looking on eBay for a cheap, broken version. That’s what I did. And of course, you’ll need various wires, LEDs, and plenty of solder.

R2's web interface

R2′s web interface. Webcam feed is at the top, along with various buttons. W, A, S, and D on the keyboard moves him around.

How It Works:

After switching him on, R2D2 will automatically boot into a custom Python script that I wrote. This establishes a web server that can be accessed by any browser. This web page gives players the control to move him around and rotate his dome left and right. On the page itself, clickable buttons can play any sounds that are on the USB flash drive. Users can also toggle the video projector to turn on and off, and play a movie file on command. This video is projected to a surface directly in front of R2. During his operation, a webcam mounted inside R2D2′s dome will send a video stream to the web page, allowing you to see what he sees. Nifty, eh?

The Build Process:

The specifics of taking apart the Hasbro R2 have already been well documented here. The outer casing remained pretty much all the same, although I had to dremel out several pieces on the inside that were no longer needed in order to make room for the new battery and other electronics. I discarded all original Hasbro circuit boards and cables, only keeping the front mounted speaker and the three DC motors: two for each leg and one for rotating the center dome.

All connections to the LED’s and h-bridge circuits that drive the motors are hooked directly to the Raspberry Pi’s GPIO pins. Peripherals such as the webcam, RF keyboard dongle, and 16gb flash drive are hooked into the USB hub. The Pi’s RCA video jack goes directly into the projector, and the audio output connects to the 5v amplifier, which hooks up to the front speaker that was kept from the original Hasbro toy.

The first main challenge with the build was with the video projector. I found that mounting it on top of his middle support leg was the best way to fit everything inside. It also created a nice angle to project the image forward against a wall in front of R2. However, getting the projector to turn on and off based on commands given by the Raspberry Pi was a challenge. This particular pico projector (which I was using just because my wife had bought one for her classroom and didn’t end up using it) has a push button on the side that turns it on and off. I opened up the casing to see if I could wire an on/off switch to the circuit board directly, but these things are way too small and delicate to be operating on them.

So instead, I decided to attach a small solenoid to the side of the projector to physically push the button when I wanted to power it on or turn it off. The positive connection for the solenoid was attached to the 11.1v positive on one of the batteries. A transistor was used, connecting one of the 3.3v GPIO pins on the Raspberry Pi to the base signal of the transistor. (See this tutorial if you don’t know how to use transistors with solenoids.) Originally I tried using the 5v regulated power connection for the solenoid, but it wasn’t enough juice to push the button in all the way. 11.1v seemed to work, as long as I was just using it in short intervals.

The video projector mounted on R2's middle leg

The pico video projector, mounted on top of R2′s middle leg.

The other main challenge was the battery power. This was my first project using LiPo batteries (or any kind of battery, really) and if I had more experience, I probably could have figured out how to power everything off a single battery. However, I ran into quite a few complications and decided in the end to use a total of three batteries. Not ideal, but it is what it is. One 11.1v LiPo battery utilized a switching regulator to provide 5v for the Raspberry Pi and other circuits. This battery is stored inside R2’s dome. The second 11.1v LiPo battery was regulated at 6v for the three DC motors. This is somewhat similar to Hasbro’s unaltered R2 toy, which uses 4 “AA” batteries for the computer circuits and 4 “D” batteries for the motors.

So where’s the third battery? Well, again, the problem lies with the video projector. This little guy uses a lot of power apparently, and hooking it up to the same battery as the Raspberry Pi or the motors was too much of a drain. However, the pico projector already has a 3.7v 1050mAh lithium ion battery inside. Rather than try to figure out a way around this, I decided just to utilize the battery that already came with it.

Mounting all of the components inside R2 was also a challenge. I had to position things at odd angles to get everything to fit, and frankly, it’s kind of a hot glued mess. But it works. Like I mentioned above, I mounted one of the 11.1v LiPo batteries inside the dome along with one of the h-bridge boards, the webcam, and four LEDs.

R2's dome, including a webcam, battery, and h-bridge circuit

R2′s dome, including a webcam, battery, and h-bridge circuit

The main body contains the other h-bridge board, the remaining 11.1v LiPo battery, pico projector, Raspbery Pi, USB hub, audio amplifier, front speaker, and basically everything else.

R2 front chassis

R2′s front chassis, with DC motor for dome rotation, USB hub, Raspberry Pi, and various audio/video connections

R2's back chassis

R2′s back chassis, with a 11.1v LiPo battery, two SBEC regulators, h-bridge circuit, audio amplifier, and various connections.

R2 has two compartments on his front case that can be opened. The compartment on his left side provided a nice, accessible space to put the connections for all three batteries along with the SD card and USB flash drive. So if you want to change his data or recharge the batteries, all the required cables can be found in this easily-opened compartment.

R2's charging and data connections

R2′s charging and data connections

The compartment on his right side is where Hasbro placed a little arm that can hold a beer  bottle or whatever else you want. For some reason, I was determined to keep this as is.

R2's spoon is too big

R2′s spoon is too big

In terms of software, the Raspberry Pi runs the standard Raspian distribution. WebIOPi was configured to provide a web-based interface to control the Pi’s GPIO pins. Following the Cambot tutorial, MJPEG-Streamer provided the streaming video for the webcam mounted in R2’s dome. I then wrote a Python script that would set the state of the IO pins for all LEDs and motors while playing sounds and starting video via OMXPlayer. I also had the Python script register the IP address of R2D2 on my web server so that I could look up his address easily. And last but not least, I installed Pygame to handle all the key presses on the mini RF keyboard in case I wanted to control him outside of the web.

What I wish had been done better:

Like I said, using three batteries is kind of a pain, since it means all three need to be recharged for this little droid to be fully operational. His battery life is quite long though, so that’s a plus. I also slightly regret mounting the USB webcam inside R2’s dome like I did. The reason is that it’s always looking slightly up instead of straight ahead, which means obstacles on the floor can be difficult to see. However, rotating his dome left and right can usually get you a better sense of his surroundings. I also didn’t implement any kind of positional sensor inside the dome, so it can be a little difficult to know whether or not he’s looking straight forward.

Click here to download R2D2′s Python code.

12 thoughts on “Pi2D2 – Wifi, Webcam, Video Projection, R2D2, and You!

  1. The quantity of top high quality content on your extraordinary website has truly made me realize the authority your site has. Thoughts blowing posts and articles seemingly everwhere. Maintain up the good work.

  2. Pingback: Pi2D2 หุ่นยนต์เลียนแบบ R2D2 พลัง Pi | Raspberry Pi Thailand

  3. Pingback: Pi2D2 interview | Linux User & Developer - the Linux and FOSS mag for a GNU generation

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*