Update: Blog Migration to Github

For over a year now I have been running this blog on the Ghost platform inside a cheap Digital Ocean instance. I needed a server for
some hobby projects, so it was not a big deal, I am not expecting big traffic here anyway. Recently I grew more ambitious (see Engineering Learning Machines), therefore I don’t have much use for the Digital Ocean instance anymore, so it didn’t make sense to support it only for the blog. Fortunately, GitHub offers a free hosting solution called GitHub Pages (which I did use a couple of years back) that is free for lower-traffic sites like this one. This platform is based on Jekyll, a static web page generator.

The migration was a breeze, mostly due to the Jekyll Ghost Importer plugin. The following post by Nikhita Raghunath also
offers some valuable tips on how to configure your Jekyll instance as a blog.

Raspicam Installation Tutorial

In order to use the Raspberry Pi 3 camera v2, we need to install a third-party ROS node from source, since it is not part of the ROS distribution at the moment. The installation is not that straightforward using only the barebones ROS installation, since there are a few dependencies on other packages. Looking at the package definition package.xml, we see the following dependencies:

catkin

compressed_image_transport

roscpp

std_msgs

std_srvs

sensor_msgs

camera_info_manager

dynamic_reconfigure

libraspberrypi0

The highlighted ones are missing from the ros_comm stack, so we need to install them manually. The approach here is simply to fetch the missing packages and then merge them into the existing barebones catkin workspace. Lastly, we build and test raspicam_node.

1. Install all dependencies

Fetch the package information for all the missing packages and their ROS dependencies:

Finally, build and install raspicam_node. It should be possible to do this more specifically with --pkg raspicam and save some time, but this hasn’t been tried yet. Two compilation processes -j2 are a safe option here:

Installation Instructions

An easier way to install ROS on Raspberry Pi is to use the Linux Mate distribution for Raspberry. However, I am unwilling to use bloated software, so here we do it the hard way :).

This guide describes how to install a barebone kinetic ROS distribution. The installation of additional packages is described in follow-up posts.

Preparation

We need to install some catkin bootstrap packages first. In order to do this, we must add the ros software repository. It seems that Raspbian Stretch is missing the certificate management service by default, so we have to install it first:

This will pull some other package dependencies, for instance build-essentials.

Installation

1. Initialize the ROS package system

The first step is to initialize the rosdep package manager. As per the documentation, do not use sudo for rosdep update:

sudo rosdep init
rosdep update

2. Create the catkin workspace

mkdir ~/ros_catkin_ws
cd ~/ros_catkin_ws

3. Build a list of packages and dependencies

The command rosinstall_generator is used to plan out the build process by generating a *.rosinstall file. It resolves all dependencies for the specified package and writes them down in the rosinstall file. That file is used by the wstool to fetch the source code for all packages.

4. Fetch the packages

The command wstool is used to obtain the source code automatically. It can download the packages in parallel, controlled by the -j option. In this step, a higher parallelization (-j8) is fine:

wstool init -j8 src kinetic-ros_comm-wet.rosinstall

If the wstool init command fails or it gets interrupted, the download can be resumed as follows:

wstool update -j4 -t src

When finished, the source code for the required packages can be found in

~/ros_catkin_ws/src

Even though we have downloaded the packages in ros_comm, there might be external dependencies (libraries and tools) that are not yet installed on the Raspbian OS. In order to fetch them automatically, we invoke the following command:

rosdep install --from-paths src --ignore-src --rosdistro kinetic -y

It installs everything via the apt package manager. The dependecies are resolved for all ROS source packages in the --from-paths directory. Since the above command is recursive, we tell it via --ignore-src not to install the packages already in the src directory. As we are not working in the ROS environment yet, we have to also specify the distribution name with the --rosdistro parameter.

5. Build the ROS packages

The command for building the packages has been fetched with wstool along with the source code and is located in the src directory. The catkin_make_isolated is used for a mix of catkin and cmake packages. If only catkin packages are to be built, the catkin_make should be used instead (custom-built ROS packages).

The Raspberry 3 has limited memory. With the default parallel setting -j4, it overflows and the build process fails. Empirically, -j2 is a good parameter.

Finally, the install location can be specified with the --make-space parameter. In order to simplify the process, we can make the current user owner of the target directory where we want to install ROS:

If there is a problem with the compilation (crash due to memory exhaustion), the command can be issued again and the packages that are already compiled will be skipped, so it continues from where it left off.

6. Test the installation

ROS uses a few environment variables that have to be set up prior to using it. According to the build command above, we can find a setup script at:

Overview

This guide will show how to install the latest Arduino IDE and supporting packages to enable the programming of Arduino devices from the Raspberry Pi 3.

You will need a USB to Serial FTDI converter in order to program the Arduino devices and to receive the output of the serial console when testing them.

The complete setup allows us to develop and program Arduino devices on the command line, without any IDE. We are going to use up-to-date versions of the software, so most of the packages will have to be fetched from Github and installed locally.

Preliminary Steps

First, let’s organize the locally installed packages on the Raspberry. I like to use a directory called “local” for this purpose. Since there are no other users, it makes no sense to install anything in system directories. We will place them in ~/local:

mkdir ~/local
cd local

Arduino IDE

Because of some compatibility issues, I prefer to install an up-to-date version of the Arduino IDE. The official Debian package is just too old and not compatible anymore with newer libraries.

Download to the website https://www.arduino.cc/en/Main/Software. Make sure that you select the Linux ARM (experimental) version. The AMD64 architecture doesn’t work on the Raspberry. The current version is

ARDUINO 1.6.13

Download the package and move it to the Raspberry with something like:

scp arduino-1.6.13-linuxarm.tar.xz raspi:local

The package can be decompressed inside the ~/local directory using:

cd ~/local
tar -xf arduino-1.6.13-linuxarm.tar.xz

Now we have the Arduino IDE installed under

~/local/arduino-1.6.13

It contains libraries, board description files, etc.

We can not compile the source files (Arduino sketches) with a plain old Make file, because there are many dependencies and hidden parts from the developer. Therefore, we need Arduino.mk which enables us to work on the command line. It lives on Github, so we just need to clone it to the ~/local directory:

We can now program the Arduino. Make sure that you have correctly connected the RX/TX and the reset pins, as well as the Vcc/Ground. You need the 100nF capacitor on the reset line, for it to work correctly.

Please, also make sure that the Python python-serial package is installed, since it is used by Arduino.mk:

Preliminary Configuration

Useful Software Packages

First, let’s install a familiar text editor. This goes a little bit against the minimalist concept, but since I am also using the Raspberry for development, it is actually useful to have something like that here. You are free to choose your tools, of course.

sudo apt-get install emacs

A mandatory package is Git

sudo apt-get install -y git

If you plan to program Arduino from the Raspberry Pi on the command line, then one very useful tool is the Python serial library.

sudo apt-get install -y python-serial

I like to use a terminal multiplexer to run long-running processes that I haven’t daemonized yet:

sudo apt-get install -y tmux

A useful resource monitoring tool is a modern version of top:

sudo apt-get install htop

One of the most important commands is gpio utility of the wiringpi library. It can be used directly to turn on/off gpio pins and also to show their state.