skycam-bleed

bookcoverThis project is excerpted from Make: 3D Printing Projects, available at the Maker Shed and fine bookstores.

Huge Thanks: Brian Roe designed the 90° and 45° 3D-printed skyway corners, while my friend and code wizard Mick Balaban and Printrbot engineer Nick Ernst got me sorted on the software tutorials.


Building a robot from scratch has been a dream of mine since I was very young. In fact, I have a few robot kits sitting in boxes in my garage right now — but I just couldn’t get excited about a line-following robot or a simple tank. I just like doing things differently and attacking problems from a fresh perspective.

Read articles from the magazine right here on Make:. Don't have a subscription yet? Get one today.
Read articles from the magazine right here on Make:. Don’t have a subscription yet? Get one today.

My Skycam is a little robot that travels on a rope or string, can turn corners, and even has a little camera with pan and tilt. The whole thing can be controlled from your phone or any browser — and it even streams live video.

This project was born out of the desire to make a robot that I can control from my phone. I had recently been playing with the Raspberry Pi and Google Coder, a neat bit of software that teaches the basics of web development. Using Coder, I was able to control an LED from my phone, so I knew controlling other hardware was possible. I enlisted friends to help me over the hardware and electronics hurdles, so I don’t deserve full credit, but that’s the beauty of the maker movement — a rich community of people ready to help!

My dream has come true. I built a robot. Not just any robot, but one that rides a monorail of string in the sky, streams video, and is remote-controlled from my phone. I love being a maker.

Editor’s Note: You can get all .stl files for 3D printed parts and the skycam code from the Github repository for this project

NOW DEPLOY YOUR SKYWAY

Build your skyway with thin paracord, wire cable, or high-test fishing line. You’ll need to tie off to very secure places — I used interior door hinges in my house.

skycam-0000-BD-DSC00180

You can get creative with the skyway and even build in turns using 3D-printed corners (Skycam-corners.stl). Using a corner requires an extra length of string attached to the back, to “pull” the corner into position. I’ve included a 90° turn and a 45° turn with the 3D files.

Make sure your skyway string exits the corners right at the top so that your Skycam wheels can make the transition. Also, you’ll need to keep the skyway fairly level since there’s not a lot of torque in the little micro servos.

Best of luck and have fun!

skycam-00079

What will the next generation of Make: look like? We’re inviting you to shape the future by investing in Make:. By becoming an investor, you help decide what’s next. The future of Make: is in your hands. Learn More.

Project Steps

1. Assemble the Top Plate

skycam-00001

1a. Press the 2 bearings into their pockets in the top plate, Skycam-top.stl.

skycam-00002

1b. Attach switches

Attach the 2 power switches to the top plate with four M3×8mm screws and nuts. One switch is used to power the Raspberry Pi, the other is used to power the servos. (I used 2 different switches so I could tell them apart, but the difference is purely aesthetic.)

1c. Mount the servos

Insert the 2 continuous rotation servos into the left and right wheel mounts (Skycam-left-wheel-mount.stl and Skycam-right-wheel-mount.stl).

skycam-00006

Ensure that the servo drive gear is lined up with the center of the 3D-printed vertical post, as shown above. To operate properly, the center of the wheel needs to pivot directly above the 624 bearing when the servo post is mounted.

Screw each servo to its wheel mount using two M3×10mm screws.

TIP: If you’d like to learn how to convert regular mini servos into continuous rotation servos, I’ve written up the process at printrbot.

skycam-00005

Insert one M4×12mm screw through each bearing from below, so the threads come out the top, next to the switches. Add two M4 washers to each screw; these will allow the wheel mounts to rotate freely on the screws.

skycam-00007

Thread the ends of the screws into the left and right wheel mounts. Tighten the screws until the connection to the wheel mount is rigid. The wheel mount should still rotate freely on the screw post inside the bearing.

1d. Add the wheels

Press the wheels (Skycam-wheel.stl) onto the servo drive posts. Secure each wheel with the small self-tapping screw that came with the servos.

skycam-00008

Wrap a small rubber band into the valley of the wheel hub. This will help the wheel grip against the paracord or other cable that’s used for your skyway.

Route your servo wires down through the square holes in the top plate, leaving enough slack to allow the wheels to rotate 45° in either direction.

2. Set up the Raspberry Pi Software

It turns out that the Raspberry Pi is a great platform for building robots! You can even create your own custom user interface and stream video live to your browser.

To get these features up and running, you’ll need some free software: the Google Coder platform, the Pi-Blaster library that communicates with the servos, and MJPG-Streamer to stream video from the Pi’s camera.

Now’s the time to plug in your Pi’s Wi-Fi dongle if you’re using one.

mtdp_0809

2a. Install Google Coder for Raspberry Pi

Point your computer’s browser to Google Creative Lab’s Coder page and select the Wired button. Then follow the 3 steps onscreen to install Coder on your SD card and connect to your Pi.

During the third step, your browser will warn you: “Your connection is not private.” Click on “Advanced”, and then “Proceed to coder.local.”

Coder will prompt you to provide your password. Once you’re logged in to your Pi and are on the Coder home screen, click the gear icon and select Wi-Fi Setup, then follow the onscreen instructions.

Disconnect the Ethernet cable from the Pi. You’re now running on the Wi-Fi network! Reboot your Pi.

Log back in to your Pi by navigating to http://coder.local in Chrome. Ensure that your wireless connection is working correctly. Nice job! You’re halfway there.

Explore the Coder environment. You’ll be able to inspect and even edit the code right there in your browser window!

2b. Install Pi-Blaster on Raspberry Pi

First, you need to identify the IP address of your Pi. Any network scanning software will work; I used LanScan from the Apple Store, but Windows has lots of options as well. Scan your network for the name “Edimax Technology Co. Ltd.” This is your Pi; take note of its IP address. Mine was 192.168.1.115, but yours could be different.

On your computer, open the terminal to access the command line and type the following line, inserting your own Pi’s IP address: ssh 192.168.1.115 -l pi

You’ll be asked if you want to continue
(you do). Type: 
yes

When you’re prompted for a password, enter your Coder password.

Next, to download the Pi-Blaster software, enter the command: wget https://github.com/sarfata/pi-blaster/archive/master.zip

Once the download is complete, you can unzip the archive by entering: unzip master.zip

To move into the Pi-Blaster folder you created when you extracted the .zip file, type:cd pi-blaster-master
Your command prompt should change to pi@coder: ~/pi-blaster-master$.

You’ll now need to install the files in the pi-blaster-master folder. To do this enter: sudo apt-get install autoconf. You’ll be asked if you want to continue (type “Y” for Yes).

To build the software, you’ll begin by typing the command:./autogen.sh. (
This will take a moment to run.) 
Then type: ./configure 


Finally, compile the code: 
make. Then install Pi-Blaster: sudo make install

Pi-Blaster is now ready to run on your Pi!

CAUTION: Don’t close your terminal window or exit the ssh session with your Pi yet. Next you’ll enable streaming so you’ll be able to view what your Pi’s camera is “seeing”!

2c. Enable camera and install MJPG-Streamer

To enable the Camera function on your Pi, type: sudo raspi-config

The Raspberry Pi Software Configuration Tool GUI (graphical user interface) will appear. Use the cursor keys to select Enable Camera, then press Enter. The system will ask you if you’re sure (you are). Select Enable and press Enter. You’ll return to the main menu. Press the right arrow key to select Finish, then press Enter. Now reboot your Pi: sudo reboot

Once your Pi has rebooted, log back in to the Pi over the SSH connection as you did in Step 2b.

Update the Pi so that it knows the location of all of the files and data you’re about to load onto it: sudo apt-get update

Files being downloaded will fly by on the terminal window. This will take a few minutes.

NOTE: After each command entered, you’ll be prompted for a yes or no answer. Answer “Yes” to all queries, or the installation will be aborted and you’ll have to start over.

When you get the command prompt back, the Pi has been updated, but you still need some additional software, so type:
sudo apt-get install subversion libjpeg8-dev imagemagick libav-tools cmake

Now you’ll need to download the MJPG-Streamer software by cloning the GitHub repository where the files are stored: git clone https://github.com/jacksonliam/mjpg-streamer.git
You’ll end up with a folder called mjpg-streamer/mjpg-streamer-experimental.

To move into the mjpg-streamer folder, so you can build the software, type: cd mjpg-streamer/mjpg-streamer-experimental

Now compile the software: make 


Then enter: sudo make install

You need to tell the MJPG-Streamer that you’re using a Raspberry Pi camera: ./mjpg_streamer -i "./input_raspicam.so -fps 5" -o "./output_http.so - w ./www -p 8090"

Test that the streamer and camera are working together by opening a browser window on a separate computer, then navigating to http://CODER-IP:8090, replacing CODER-IP with your Pi’s IP address; for instance, I would enter http://192.168.1.115:8090.

mtdp_0814

You should now see a page that looks like the one shown above. In the second image, under the flower, if you see a snapshot of what your camera sees, then your streaming setup is working!

Move back to your terminal session, hold down the Control key, and press the X key to stop MJPG-Streamer from running.

To configure the streamer to start automatically whenever your Pi is powered on, it needs to be closed. First you’ll need to move to your settings folder: sudo nano /etc/rc.local

The nano text editor will open the file rc.local.

You’ll need to add a few lines of code to the bottom of the rc.local file. Type or paste them after the fi and just before the exit 0 at the very bottom.

NOTE: You’ll need to use your arrow keys to navigate in nano. Your mouse won’t work.

Here’s the code to add:
cd /home/pi/mjpg-streamer/mjpg-streamer-experimental/./mjpg_streamer -i "./input_raspicam.so -fps 5" -o "./output_http.so -w ./www -p 8090"

Once you’ve added the 2 lines to the config folder, hold down the Control key and press X to exit. You’ll be asked if you want to save the changes; type Y for yes and press Enter. You’ll then be given the option to change the folder name; do not change this, as we want to overwrite the config folder to have the new settings, so just press Enter to continue.

Reboot your Pi (sudo reboot again) and you’re ready to go.

3. Assemble the Midsection

skycam-00010

3a. Mount the Raspberry Pi

Once your Wi-Fi streaming and servos are working, use four M3×8mm screws to mount the Raspberry Pi to the underside of the top plate. There’s 34mm of space for a small Pi enclosure (optional).

Connect the top plate assembly to the middle case (Skycam-middle.stl) with four M3×8mm screws.

skycam-00012

3b. Add the endstops (optional)

The middle case has flanges for mounting 2 micro lever switches, for use as end-stops. When these hit a wall or obstacle, they’ll trigger the drive servos to reverse.

Secure the endstops with four M2.5× 10mm screws, with the lever switches facing out. Route the wires through the holes in the side of the middle case, under the flanges.

4. Build the Camera Assembly

The Skycam camera assembly hangs off the bottom plate of the robot. It uses a Raspberry Pi camera module and 2 regular micro servos to pan and tilt the camera while it streams the video to your browser.

skycam-00026

Press the bottom of the second servo — the tilt servo — into the recessed area provided on the camera pan disc, directly next to the facedown pan servo. The tilt servo’s shaft and wires should be on top. This servo is a press-fit affair, so consider taping the 2 servos together if needed for stability.

Press one of the servo horns into the recess on the tilt arm (Skycam-camera-tilt.stl) and secure it with a dab of super glue.
Press the tilt servo cap (Skycam-pan-tilt-top.stl) onto the tilt servo. This cap is nonfunctional, I just like the way it visually ties together the 2 servos into one block.

skycam-00034

4b. ASSEMBLE THE CAMERA CASE

Use a dab of super glue to join the tilt arm (with the embedded servo horn) to the side of the back camera box (Skycam-camera-back.stl), matching up the shapes as shown above.

skycam-00037

Mount the Raspberry Pi Camera on the tiny pins in the back camera box, then snap on the cover.

skycam-00041

NOTE: The camera box is an existing design, used here with permission. Rather than modify it, I just used super glue.

4c. Mount the camera tilt arm

Mount the camera tilt arm on the servo, but don’t secure it with the screw just yet. If the tilt servo and arm aren’t positioned correctly, the tilt arm will hit the camera pan disc. Later when you turn on the servos, you’ll be able to verify that the tilt arm is moving properly.

5. Attach Camera and Bottom Plate

skycam-00050

5a. Glue the servo horn

Push the servo horn (shown above) through the back of the bottom plate (Skycam-bottom.stl) and secure it with a few drops of super glue.

Thread the camera cable and servo wires through the slot in the back lid, leaving plenty of slack.

skycam-00051

5b. Mount the camera

Mount the entire camera assembly to the bottom plate using the tiny servo screw. It’s likely you’ll end up repositioning the camera mount angle, but this servo doesn’t have a hard stop like the tilt arm in Step 4c does. You won’t do any damage if it’s pointing in the wrong direction.

5c. Test-fit the bottom plate

Test-fit the middle case and bottom plate assemblies to avoid any setbacks later. The bottom plate attaches with four M3×8mm screws, but first you’ll hook up the electronics and test the software to make sure it all works and everything moves properly before closing it all up.

5d. Connect the Pi Camera

Connect the camera’s ribbon cable to the Pi, so you’re ready to test video streaming when the project software boots up.

6. Connect the Electronics

The brains of your Skycam can be repurposed for other projects. You can use what you learn here to design your own 3D-printed remote-controlled car or tank with a streaming camera!

To keep this project ultra-flexible, you’ll be making your own power and signal boards. Hang in there if this is your first time hacking together one-off electronics. When it’s done, you’ll be able to step back and see that you’ve tapped into a new superpower! Both boards are made using small pieces of perforated board and use 3-pin headers for wire connections.

6a. Make the power/regulator board

The Raspberry Pi needs its own clean and smooth 5V power source, otherwise you may see less than desirable behavior. So you’re going to make a power board that takes in 8.4V–12V DC from batteries, then regulates it down to the desired 5V.

skycam-power-board

To assemble the power/regulator board, solder the 100µF electrolytic capacitor, 5V regulator, and 3-pin header on a scrap of perf board, following the schematic diagram.

skycam-00054

The white wire is the battery pack’s voltage in, black is ground, and red is the 5V out of the regulator to the Raspberry Pi. You’ll need to solder the board’s components together underneath the perf board.

skycam-00052

I used a blue EC3-style connector to attach the battery pack to the power/regulator board and power switch. A standard hobby servo cable was used to connect power and ground to the Raspberry Pi. This switch doesn’t directly supply power to the Pi; it switches the ground line on and off to either complete the entire circuit (power on), or open the circuit (power off).
Hook up your 6xAA battery pack; then, using a multimeter, measure the output of your power/regulator board to ensure that you’re getting 5V out. If you’re not getting 5V, check your connections and retest before connecting this board to your Raspberry Pi.

Once it’s working, cover the board in electrical tape so you don’t short anything out. There’s not much room inside the Skycam and it’s likely that components will rub up against each other.

skycam-00057

6b. Make the signal board

The signal board uses 3-pin headers to power and control the servos and connect them to the Raspberry Pi. It also connects the Skycam endstops to the Pi, so Skycam knows when it has hit a wall.

The signal board has its own, separate 4xAA battery pack, and will use the second switch you installed earlier (Step 1b) to turn power on and off.

skycam-signal-board

Solder the 3-pin headers and resistors through the bottom of the perf board as shown in the schematic. Starting from the battery pack, the positive wire (red) is connected directly to the signal board’s positive input. The battery negative wire (black) goes to one of the 2 ground terminals that are not connected to the servos or endstops. You can see these 2 exposed ground connections on the right side of the schematic. After connecting to one of the grounds, hook up the other end to the switch.

Next, you’ll connect another black wire from the middle terminal of your switch to the remaining GND input on the signal board. The switch opens or closes the circuit, turning the power on and off.

6c. Connect the Pi
Now connect jumper wires from the signal board to your Pi, as follows:

Screen Shot 2016-08-26 at 11.25.46 AM

Wrap the signal board in electrical tape to protect it from shorting. Plug everything in, and turn on the Pi and the power to the servos. It’s time to test out the software controls!

7. Test the Software Controls

Using a browser on a computer, connect to the Pi as you’ve done previously.
Then download my Skycam Coder project code from github.com/Make3DPrintingProjects/Skycam. Upload it to Google Coder and it will appear in the menu.

skycam-00077

Remove your tilt arm to allow the servo to center (this is why you didn’t screw it in earlier). Use the Coder interface to drive the Skycam wheel servos and pan and tilt the camera servos. Test the tilt to find the right rotation before attaching the tilt arm and securing it with the screw. The streaming video should also be live at this point!

Assuming everything works perfectly, tuck in the wires, optionally tidy them up with zip ties, and reattach the bottom plate with four M3×8mm screws. Your Skycam is complete.