Creating a Dawn Robotics SD Card

Update: This post is now out of date as we’ve released a new version of the software. You can find an updated version of the instructions here.

This post describes all the steps we go through to set up a Dawn Robotics SD Card. This SD card contains Raspbian with software installed on it to support a Raspberry Pi robot, and also to support the Pi Co-op Arduino add-on board we sell. If you want to get up and running quickly, then you can just download a complete version of the SD card image here, or alternatively buy a pre-installed SD card from us here. For people who want to build their SD card image from scratch however, or who want to customise it for their own Raspberry Pi robot, hopefully this set of notes will be a good guide to show you what we’ve done.

Set up a Basic SD Card

The SD card is built around the 2013-07-26-wheezy-raspbian Raspbian image which can be found here. The reason we use this image is that we found that we got very jerky, or non-functional camera streaming when using more recent distributions. This may be something to do with the new distributions, or possibly due to a bug in our code. If you’re able to get this setup working with more recent versions of Raspbian we’d be very interested to hear from you.

Anyway, download the Raspbian image and copy it to an SD card using the instructions here.

Log onto the Raspberry Pi and run

sudo raspi-config

In the configuration program, enable the camera, enable boot to desktop, and expand the disk image to fill the SD card.

Create a WiFi Access Point

Set up the Pi as an access point using this great tutorial from Adafruit. The USB WiFi adaptor we sell, the Edimax EW-7811Un uses the same driver as the one that Adafruit sells, so you don’t need to diverge from the tutorial. The only changes we make are that we set the SSID of the network to be Pi_Mini_Robot, and we don’t set up network address translation.

Set up Camera Streaming

In order to stream camera images from the Pi we use mjpg-streamer which sends a constant stream of JPEGs over the network to computers which request them. This doesn’t give the highest resolution video, typically we get a resolution of 640×480 at about 10fps. But it does have the advantage of working with a lot of web browsers, and providing a low lag connection which is very important when trying to teleoperate a robot.

First, we move the tmp directory to RAM. This potentially gives us a small speed advantage, as the JPEGs are not written to the SD card, and extends the life of the SD card as it is not being subjected to lots of repeated write operations.

Add the following line to the bottom of the file /etc/default/rcS

RAMTMP=yes

Now add the following line to /etc/fstab and reboot

tmpfs /tmp tmpfs nodev,nosuid,size=40M,mode=1777 0 0

Secondly we install mjpg-streamer by following this tutorial by Miguel Grinberg. You only need to follow this tutorial up to the end of step 6. We control the process of starting up raspistill and mjpg-streamer by using a Python script.

Install Dawn Robotics’ Software

These next steps set up the Pi so that it will work with our Arduino add-on board, the Pi Co-op, and also so that it runs our robot control web server on start up.

Install the following packages using apt-get

sudo apt-get install python-pip python-dev python-serial arduino

Install the Tornado web framework and the Ino Arduino tools using

sudo pip install tornado ino

Install SockJS

git clone https://github.com/mrjoes/sockjs-tornado.git
cd sockjs-tornado
sudo python setup.py install

Set up the Pi to work with the Pi Co-op

git clone https://bitbucket.org/DawnRobotics/pi_co-op.git
cd pi_co-op
sudo python setup_pi_co-op.py install

Get the scripts for the robot web server, by installing our Pi camera robot software

git clone https://DawnRobotics@bitbucket.org/DawnRobotics/raspberry_pi_camera_bot.git

Install the robot web server so that it starts up when the Raspberry Pi boots

cd raspberry_pi_camera_bot
sudo cp init.d/robot_web_server /etc/init.d/robot_web_server
sudo chmod a+x /etc/init.d/robot_web_server
sudo update-rc.d robot_web_server defaults

Finally, reboot your Pi and enjoy. :)

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>