Installing ROS on a Raspberry Pi

As a lover of technology, I tend to accumulate bits and pieces of interesting devices. Usually, these are purchased for use on unrelated projects, and on occasion, I have the opportunity to bring them together into a single project in a previously unanticipated way. Such is the case with my Arduino and Raspberry Pi. Both are interesting microcomputers with their own strengths and weaknesses, so it was when I learned that they could be made to work together with the help of Robot Operating System, I had to give it a shot.

My raspberry pi

ROS is an open-sourced project that is dedicated to providing a framework of libraries for performing common tasks under the general heading of robotics. It also includes drivers that allow you to easily interface with common hardware. The core of ROS is a reactor model of observables and observers that send messages to one another, typically over a serial connection, allowing any number of controllers to interface with one another and form a unified whole.

The rosserial_arduino library is a project that allows ROS on a Raspberry Pi (or other *nix device) to interface with an Arduino over a USB serial connection, thereby combining the computing power and versatility of a Linux-based microcomputer with the IO capabilities of an Arduino.

What You’ll Need to Get Started

Installing Raspbian on the Pi

If your Pi already has an operating system on it, you can probably skip this step. If, however, it’s straight out of the box, you’ll need to install the Raspbian distribution.

As of this writing, the latest version of Raspbian is Jesse, released in September of 2015. I wasn’t able to get ROS working with this version, and backed down to the Wheezy release from May of 2015 instead. To install the operating system, I did the following:

  1. Download the Raspbian Wheezy image via a bittorrent client.
  2. When the download is complete, follow these instructions to copy the image file to your MicroSD card.
  3. Unmount the card, insert it into your Pi, and hook up the power. Your device should boot into a command prompt. From here, you can run raspi-config to customize the installation, or get right to installing ROS.

Once the installation is complete, be sure to check for updates:

pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get upgrade

An up to date system is a safe system.


Once your Pi has an operating system, you can switch to interacting with it via SSH. My TV is the only “monitor” in my house that has an HDMI input on it, so SSH works much better for me.

Make sure that sshd is running on your Pi:

pi@raspberrypi ~ $ sudo service sshd status
● ssh.service - OpenBSD Secure Shell server
 Loaded: loaded (/lib/systemd/system/ssh.service; enabled)
 Active: active (running) since Thu 2015-10-08 12:17:06 UTC; 4 days ago
 Main PID: 506 (sshd)
 CGroup: /system.slice/ssh.service
 └─506 /usr/sbin/sshd -D

If everything is working, you should see the text active (running) in the result. Once we know that an ssh server is running, we can check our ip address with the ifconfig command. The output should look something like this:

pi@raspberrypi ~ $ ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:b9:49:cd  
          inet addr:  Bcast:  Mask:
          RX packets:5150 errors:0 dropped:51 overruns:0 frame:0
          TX packets:565 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:552488 (539.5 KiB)  TX bytes:60766 (59.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)

If your Pi is connected to a LAN cable, you’ll want to look at the eth0 section. If it’s connected to WiFi, look for a wlan0 section. Both sections should have an inet addr field whose value starts with a 192.168.x.x address. In my case, it’s From a terminal on my computer, I can connect with:

jfritz@IDEAPAD-UBUNTU:~$ ssh pi@

When prompted to accept the Pi’s RSA key, I do, and when prompted for a password, I enter the default password raspberry. If you intend to leave the Pi connected to your network for long periods of time, you should change this password or add key-based authentication to the system.

If you have problems getting connected, check out the official instructions on the Raspberry Pi website.

Installing ROS on the Pi

As of this writing, the most recent version of ROS is Indigo, released in July of 2014. To get it running on the Pi, you’ll want to follow the official ROSberryPi installation instructions on the ROS website.

While following these instructions, I had a few false starts. It’s important to read the instructions carefully, as they’re fairly generic, and can be used to install different configurations of ROS on different versions of Raspbian. I found that the instructions for the ros_conn configuration worked best on Raspbian’s Wheezy release.

The  trickiest part of the instructions is section 2.2 Resolve Dependencies. It took me a couple of reads to realize that if you’re installing ROS Indigo’s ros_conn configuration on Raspbian Wheezy, you only need to compile two packages from source: libconsole-bridge-dev and liblz4-dev. Installing any other packages at this step just costs you time, and may introduce problems down the road.

I also found that the install process went much smoother when the Pi was connected to a LAN rather than WiFi. The WiFi signal in my house is relatively weak, and the Realtek #814B is really cheap, so downloading a lot of files while maintaining an SSH connection is a big ask.

Once the installation is complete, open up your ~/.bashrc file, and add two lines to the end:

# export ROS environment variables
source /opt/ros/indigo/setup.bash

This will make sure that the appropriate environment variables are set to interact with ROS on every startup. You can check that it worked by rebooting your Pi and running

pi@raspberrypi ~ $ printenv | grep ROS

If you see all of the ROS_* environment variables print out, then everything is set up and ready to go. Now it’s time to start on some tutorials.

Eventually, I want to get the Raspberry Pi communicating with the Arduino, and use the latter as a sensor platform and motor controller for some kind of a robot. For now, I need to find my way around ROS.

Building Milk Crate Sized Boxes for my Record Collection

I’m a hipster. Seriously. I have a beard, I’m a foodie, and I collect vinyl records. After moving into my new house, I realized that I needed a new place to store the aforementioned record collection, as the bookshelf that it previously lived on is now on a different floor than the record player, and I’m too lazy to walk up and down stairs every time I want to listen to a record.

This project, as many woodworking projects do, started out with some wood:

Rough cut box sides

One of my goals for this project was to learn how to create a box joint, which is a method of joining two orthogonal pieces of material together by way of cutting a bunch of fingers into each piece and interlacing them, providing a large surface area for glue to adhere to. The result is an extremely strong and handsome joint, but the method requires the sides of the box to be cut longer than you intend them to be.

In general, if all of your material is the same thickness, then each piece needs to be cut two thicknesses longer than you intend its inside dimension to be once joined. My boxes have an outside dimension of 17″ by 14″, but their inside dimensions are only 15.5″ by 12.5″, because my material is 3/4″ thick. If I were joining the sides with a simple butt joint, and the front and back pieces of my box sat between the two side pieces, then the front and back pieces would have to be two thicknesses shorter than the final width of the box. With a box joint, all sides are cut to the intended final outside dimensions of the box, because the interlacing fingers will eat up the extra length. Therefore, the front and back of my box are cut 14″ long, while the sides are cut 17″ long.

Box joints can be cut by hand, or by hogging material out with many passes across a standard table saw blade, but these methods make it hard to keep the fingers and the spaces between the fingers the same width across the entire length of the joint. Instead, I purchased the Freud SBOX8, a table saw blade specifically made for cutting 1/4″ or 3/8″ box joints. It’s basically a dado blade with only two widths that cuts a flat-bottomed channel.


In addition, I built a simple jig to help keep the spacing between fingers even:

Box joint jig

This jig is basically just a mitre sled with a 3/8″ square piece of hardwood affixed 3/8″ away from the edge of the blade channel. When cutting the fingers of the box joint, you advance the piece along the jig by fitting the previously cut finger over top of the guide piece, which ensures that the next finger will be exactly 3/8″ away from the previous one. This in turn results in fingers and spaces between fingers that are all 3/8″ wide.

Using the box joint jig

In the photo above, you can see that I use my jig to cut two sides of the box at once. Any two sides that join at a 90 degree angle can be cut this way, but they need to be offset by one finger width (in my case, 3/8″) so that the tops of the two pieces will be flush when the fingers are meshed together.

After making a great deal of sawdust, I ended up with all four sides meshing nicely:

All four sides of the box cut, but not yet glued

The next step was to glue the sides together. The wood glue that I typically use has a working time of around 15 minutes. For a project with this many glue surfaces, I’d recommend finding a glue that takes longer to set up, since it takes awhile to get all of the surfaces covered in glue, and you do want to glue the entire box together in one operation so that you can ensure that all of the pieces are square to one another. Many clamps are essential for this process.

The box is glued and clamped

With the glue dry, I used a palm sander and a router with a flush trim bit to clean up the edges of the box as well as any areas where the fingers sat proud of the side of the box. I also used a jig saw to cut some handles into the front and back sides.

The box is glued together and has handles cut in it

The last step was to put a bottom on the box. I used a router with a rabbeting bit to cut a 1/4″ channel around the inside edge of the bottom of the box, then glued in a piece of 1/4″ thick plywood.

Gluing the bottom into the boxes

Finally, it was time for finishing. This project got one coat of Minwax Pre-Stain Wood Conditioner, two coats of Minwax American Chestnut Gloss stain, and three coats of Minwax Wipe-on Polyurethane. Before staining, I sanded down to 220 grit, then hit the surface with triple-zero steel wool between each finishing coat.

In the end, while the finish is smooth and glossy, I think it came out too dark. I really liked the look of the box after the first coat of stain, and if I were doing the project again, I would probably would stopped there.

First coat of stain

I really liked the look of the finger joins with just one coat of stain


Finished box

The finished look is nice, but a bit orange for my tastes. I think the polyurethane has a lot to do with that yellowing effect.

After a lot of hard work, many mistakes, and more than a few false starts, I triumphantly carried my new record crates upstairs and started to put my records into them… only to find out that they wouldn’t all fit. Fuck.

You know that old adage about measuring twice and cutting once? I measured twice, but I only measured a single-platter record sleeve, not realizing that gatefold sleeves and record sleeves that contain two platters are wider than their single-disk counterparts. Luckily, my wife had the bright idea of putting the records into the boxes sideways. It looks a little funny, but it works:

Photo 2015-09-07, 12 29 11 PM

The only problem is that my collection doesn’t have much space to grow. I guess I’ll have to make more boxes after all. Oh well. Back to the shop with me.

Playing the Simpsons Theme on an Arduino

A little while back, I picked up an Arduino Starter Kit. It contains an Arduino Uno, a bunch of common components, and an instruction book that walks beginners through building circuits and using the Arduino to interact with hardware.

One of the projects in the book is a basic synthesizer that lets you play tones on a piezo speaker. The schematic for this is dead simple:


After getting the Arduino to play a few notes, I decided to extend the project a bit and play a melody. After a bit of screwing around, I managed to get the thing to play the Simpsons theme.

The code for this sketch can be found on GitHub.

Building a Rubbermaid Friendly Shelving Unit for the Basement

I built a hefty 8’x2′ shelving unit for my basement for about $100. This is the corner that the shelf was built to fit into, with a 2×4 for scale. I would have used a banana, but we’re fresh out.


This simple mitre sled jig made cutting the pieces easy.

The block on the table saw fence sets the length of the piece that I’m cutting, but stays out of the way while cutting to avoid kickback.

The block on the mitre sled acts as a feather board, keeping the stock pressed firmly down while cutting. This really helps with longer pieces.


Each shelf consists of 1/2″ plywood over a simple 2×4 frame. The front and back are 96″ long, the end caps are 24″ long, and the middle supports are 21″ long.

In this shot, you can see that my basement floor is about 3″ out of level over the 8′ length of the piece. I propped it up with shims, then screwed on some temporary legs once it was level. This gave me a level surface to base the rest of the build on.


Next, I attached the five main legs. Each leg is a different height to account for the slope of the floor. The end result is that all of the legs are the same height relative to the shelves


With the legs attached, I built the second shelf in the same way as the first, and prepared to attach it to the frame.

To help with positioning, I clamped scrap blocks at the appropriate height on each leg. This gave me something to set the shelf on before I screwed it in place.

Note that from this point forward, all height measurements were taken from the bottom shelf, rather than from the floor.


With the guide blocks in place, the second shelf was easy to install.


The third shelf was installed in much the same way as the second.


I built the fourth shelf in place, because I was working alone and didn’t feel like throwing out my back while lifting it into the air. I used temporary blocks to position the middle supports at the correct height.


The top two shelves are half the height of the bottom two, since big stuff tends to be heavy, so it makes sense to keep it near the bottom.

The bottom shelves can accommodate a large Rubbermaid or two small Rubbermaids stacked on top of one another. The top shelves can accommodate a small Rubbermaid.

I had bought some hardware to lag the unit to the wall, but it’s heavy enough that I have to put my full body weight into moving it, so I don’t think it’s going anywhere.


Building a 2×4 Workbench for my Shop

This summer, we moved out of our apartment and into our first house. Although the house is in good shape, there is some work that needs to be done, so one of the first jobs was to set up a workshop space. It’s nice to have somewhere to store my tools instead of being confined to the corner of a closet.


If you’ve never built anything before, don’t worry. This bench is easy to make, and only costs about $50 in materials. It’s made of 2x4s, and you just need four of each length, plus a half sheet of good one side plywood, cut into two pieces about 2′ by 4′.

Start by cutting the frame pieces out of the 2x4s. My legs are 36″, my front and back stringers are 46″, and my side stringers are 23″.

Pieces of the 2x4 frame

I assembled the front and back first. Each consists of two legs (the vertical pieces) and two long stringers (the horizontal pieces).

Front and back frames

I attached all of the pieces of the bench with 2 1/2″ screws. Because I was screwing so close to the edges of the wood, I was sure to pre-drill the holes. It’s important to make sure that the edges of each corner that you drill are flush.

Make sure that the pieces are flush before drilling

I marked out where I was going to drive in my screws. An inch from each edge is good.

Marking out where to drill

To start with, only drive one screw per corner. This will allow you to push everything into square before driving the rest of the screws and locking the joints into place.

One screw per corner to start with

If the piece is square, then the distance from each top corner to the opposite bottom corner will be the same. If it’s out, just push the stringers in opposite directions until everything lines up.

Once the piece is square, drive the other three screws into each corner. This will lock all of the angles in place.

Making sure everything is square

Once the front and back are built, it’s time to attach the side stringers. I stood the front on end and clamped the side stringer to it so that I had both hands free to drive the screw in.

Clamps help to attach things while you affix them

Same as before, only drive one screw per corner to start. Because the screws for the front stringers were one inch in from each side, I put the screws for the side stringers 3/4″ in from each side.


Once the side stringers are attached to the front and back of the bench, it’s time to bring the two pieces together. Now it’s starting to look like a bench. An upside down bench, but a bench nevertheless.

Bringing all four sides together

Again, square everything up, and then drive the rest of the screws in to lock the angles.

Checking for square... again

After flipping the bench over, I put the top on. I used a 2’x4′ sheet of 1/2″ GIS plywood for the top of my bench. The size of the frame gives me an inch of overhang at the front and on both sides.

Putting the top on

The top is affixed to the bench with 1 1/4″ screws. I chose to countersink the screws around the bench top so that they’re flush with the work surface.

Attaching the top

My bench has a shelf below the top. It’s made of the same 3/4″ good one side plywood as the top, but I had to notch out space for the legs.

the bottom shelf

All set up and loaded with tools! I attached a peg board to the wall behind the bench for some extra storage space.

All finished