Compound Pi Documentation

This project provides a means for controlling multiple cameras attached to Raspberry Pi‘s all of which are attached to the same subnet. Broadcast UDP packets are utilized to permit near-simultaneous triggering of all attach cameras.

The code is licensed under the GPL v3 or above. Packages can be downloaded from PyPI. The source code can be obtained frmo GitHub, which also hosts the bug tracker. The documentation (which includes installation and quick start examples) can be read on ReadTheDocs.

Table of Contents

Server Installation

The server component of Compound Pi can only be installed on the Raspberry Pi architecture. On Raspbian, the following command can be used to install the server package:

$ sudo apt-get install compoundpi-server

Warning

The Raspbian package will automatically install the cpid daemon in the boot sequence. This will make the camera inaccessible to other processes unless the daemon is manually stopped or prevented from starting.

On other platforms, the package can be installed from PyPI. Specify the server option to pull in all dependencies required by the server component:

$ sudo pip install "compoundpi[server]"

The PyPI package does not include init-scripts (because it can’t). You will need to write these for your platform manually if you wish the daemon to start automatically on boot-up.

Client Installation

The client component of Compound Pi can be installed on any machine with Python available. On Ubuntu, the Waveform PPA can be used for simple installation:

$ sudo add-apt-repository ppa:waveform/ppa
$ sudo apt-get update
$ sudo apt-get install compoundpi-client

On other platforms, the package can be installed from PyPI. Specify the client option to pull in all dependencies required by the client component:

$ sudo pip install "compoundpi[client]"

Quick Start

By far the easiest method of configuring a fleet of Compound Pi servers is to get a single Pi running the Compound Pi daemon successfully, using an automatic network configuration, then clone its SD card for all the other Pis.

This quick start tutorial assumes you are using the Raspbian operating system on your Pis, and Ubuntu as your client.

Server Network Configuration

On Raspbian, to configure the Pi to use DHCP to automatically obtain an IP address, edit the /etc/network/interfaces file and ensure that it looks similar to the following:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

This configuration should ensure that the first Ethernet and/or WiFi interfaces will pick up an address automatically from the local DHCP server. To complete the WiFi configuration, edit the /etc/wpa_supplicant/wpa_supplicant.conf file to look something like the following:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
        ssid="my_wireless_ssid"
        psk="my_wireless_password"
        proto=RSN
        key_mgmt=WPA-PSK
        pairwise=CCMP
        auth_alg=OPEN
}

Server Daemon Installation

Execute the following command to install the Compound Pi server package and the NTP daemon (the latter is required for time-synchronized image capture):

$ sudo apt-get install compoundpi-server ntp

This should pull in all necessary dependencies, and automatically install an init-script which will start the Compound Pi daemon on boot-up. Test this by rebooting the Pi with a camera module attached. You should see the camera module’s LED light up when the daemon starts. If it doesn’t, the most likely culprit is the camera: try running raspistill, ensure you’ve activated the camera with sudo raspi-config, and ensure the CSI cable is inserted correctly.

Clone the SD Card

Once you’ve got a Pi running the Compound Pi daemon successfully, shut it down and place its SD card in any Linux machine with an SD card reader. Unmount any partitions that auto-mount, then figure out which device node represents the SD card. For example, the following would tell you that the SD card is sdd:

$ dmesg | tail | grep "Attached SCSI removable disk"
[    3.428459] sd 8:0:0:0: [sdd] Attached SCSI removable disk

Clone the SD card into a disk file:

$ sudo dd if=/dev/sdd of=server.img

This will take some considerable time to finish. Once it has done so, eject the source SD card and insert the target one in its place. Remember to unmount any partitions which auto-mount, then execute the reverse command:

$ sudo dd if=server.img of=/dev/sdd

Repeat this last step for all remaining target cards. Finally, install the SD cards in your set of Pi servers and boot them all to ensure their camera modules activate.

Warning

Ensure your target SD cards are the same size or larger than the source SD card. If they are larger, they will still appear the same size as the source after cloning because you the cloning also duplicates the partition table of the smaller device.

Client Installation

Ensure your Ubuntu client machine is connected to the same network as your Pis (whether by Ethernet or Wifi doesn’t matter). Then, execute the following to install the client:

$ sudo add-apt-repository ppa:waveform/ppa
$ sudo apt-get update
$ sudo apt-get install compoundpi-client

Once installed, simply execute cpi to run the client. You will be presented with a command line like the following:

CompoundPi Client
Type "help" for more information, or "find" to locate Pi servers
cpi>

You can use the help command to discover the available commands, but as suggested the first step in using your Compound Pi servers is to locate them on the network. If you run find on its own it will send out a broadcast ping and wait for a fixed number of seconds for servers to respond. If you know exactly how many servers you have, specify a number with the find command and it will warn you if it doesn’t find that many servers (it will also finish faster if it does find the expected number of Pis):

cpi> find 2
Found 2 servers

You can query the status of your servers with the status command which will give you the basics for the camera configuration, the time according to the server, and the number of images currently stored in memory on the server. If you only want to query a specific set of servers you can give their addresses as a parameter:

cpi> status 192.168.80.154
Address        Resolution Framerate Timestamp                  Images
-------------- ---------- --------- -------------------------- ------
192.168.80.154 1280x720   30.00fps  2014-04-15 20:53:06.826477 0

To shoot an image, use the capture command:

cpi> capture

Finally, to download the captured images from all Pis, simply use the download command:

cpi> download
Downloaded image 0 from 192.168.80.154
Downloaded image 0 from 192.168.80.168

You can use the config and set commands to configure capture options, the download target directory, and so on.

cpi

This is the Compound Pi client application which provides a command line interface through which you can query and interact with any Pi’s running the Compound Pi daemon on your configured subnet. Use the help command within the application for information on the available commands.

The application can be configured via command line switches, a configuration file (defaults to /etc/cpi.ini, /usr/local/etc/cpi.ini, or ~/.cpid.ini), or through the interactive command line itself.

Synopsis

cpi [-h] [--version] [-c CONFIG] [-q] [-v] [-l FILE] [-P] [-o PATH]
    [-n NETWORK] [-p PORT] [-b ADDRESS:PORT] [-t SECS]
    [--capture-delay SECS] [--capture-count NUM] [--video-port]

Description

-h, --help

show this help message and exit

--version

show program’s version number and exit

-c CONFIG, --config CONFIG

specify a configuration file to load

-q, --quiet

produce less console output

-v, --verbose

produce more console output

-l FILE, --log-file FILE

log messages to the specified file

-P, --pdb

run under PDB (debug mode)

-o PATH, --output PATH

specifies the directory that downloaded images will be written to (default: /tmp)

-n NETWORK, --network NETWORK

specifies the network that the servers belong to (default: 192.168.0.0/16)

-p PORT, --port PORT

specifies the port that the servers will be listening on (default: 5647)

-b ADDRESS:PORT, --bind ADDRESS:PORT

specifies the address and port that the client listens on for downloads (default: 0.0.0.0:5647)

-t SECS, --timeout SECS

specifies the timeout (in seconds) for network transactions (default: 5)

--capture-delay SECS

specifies the delay (in seconds) used to synchronize captures. This must be less than the network timeout (default: 0)

--capture-count NUM

specifies the number of consecutive pictures to capture when requested (default: 1)

--video-port

if specified, use the camera’s video port for rapid capture

Usage

The first command in a Compound Pi session is usually find to locate the servers on the specified subnet. If you know the number of servers available, specify it as an argument to the find command which will cause the command to return quicker in the case that all servers are found, or to warn you if less than the expected number are located.

The status command can be used to check that all servers have an equivalent camera configuration, and that time sync is reasonable.

The capture command is used to cause all located servers to capture an image. After capturing, use the download command to transfer all captured images to the client.

Finally, the help command can be used to query the available commands, and to obtain help on an individual command.

cpid

This is the server daemon for the Compound Pi application. Starting the application with no arguments starts the server in the foreground. The server can be configured through command line arguments or a configuration file (which defaults to /etc/cpid.ini, /usr/local/etc/cpid.ini, or ~/.cpid.ini).

Synopsis

cpid [-h] [--version] [-c CONFIG] [-q] [-v] [-l FILE] [-P] [-b ADDRESS]
     [-p PORT] [-d]

Description

-h, --help

show this help message and exit

--version

show program’s version number and exit

-c CONFIG, --config CONFIG

specify a configuration file to load

-q, --quiet

produce less console output

-v, --verbose

produce more console output

-l FILE, --log-file FILE

log messages to the specified file

-P, --pdb

run under PDB (debug mode)

-b ADDRESS, --bind ADDRESS

specifies the address to listen on for packets (default: 0.0.0.0)

-p PORT, --port PORT

specifies the UDP port for the server to listen on (default: 5647)

-d, --daemon

if specified, start as a background daemon

--pidfile FILE

specifies the location of the pid lock file

Usage

The Compound Pi server is typically started at boot time by the init service. The Raspbian package includes an init script for this purpose. Users on other platforms will need to write their own init script.

When the server starts successfully it will initialize the camera and hold it open. This will prevent other applications from using the camera but also makes it easy to see that the server has started as the camera’s LED will be lit (this is useful as Compound Pi servers are typically headless).

Change log

Release 0.1 (2014-04-15)

Initial release

License

This file is part of compoundpi.

compoundpi is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

compoundpi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with compoundpi. If not, see <http://www.gnu.org/licenses/>.

Indices and Tables