Capturing images from the rover

One of the rover’s most important features is its ability to take photos, just in case the rover happens to be exploring Mars and a martian walks by.

To add this capability to the Euro RPy-Rover we used a Picamera programmatically to take photos and store them with a time-stamp.

Picamera connected to the RPi


This module is quite simple and we only need:

  • Raspberry Pi B+
  • Picamera


The Picamera comes with a ribbon that is connected to the Raspberry Pi in the labelled port. To do this we need to pull up the respective socket, that comes up and has a little joint. This opens up the socket in order to insert the ribbon, which must be done with the contacts facing away from the USB ports.

Configuring the Raspberry Pi

To enable the camera, type on the command line:

sudo raspi-config

In the menu displayed choose the “Enable camera” option, after which you’ll be prompted to reboot.


To control the rover camera with Python we installed the PiCamera library, as explained here.

In the rover main program we needed to be able to take photos with a specific size and to register the date/time at which the photos were taken. This actually quite simple.

The photos resolution is set with:


To capture a photo use:


This saves the image in a file with the name supplied in the file_name string variable.

As we want to preserve the time at which the photo was taken, we name the photo with the timestamp, which we have to put in the file_name variable.To do this we used:

file_name = time.strftime("%c")+".png"

The strftime takes the %c parameter in order to specify the timestamp format. You can see other available format options here.

The camera module code shown below is available at the Euro RPy-Rover GitHub Python repository.

import time
import picamera

# Takes 142x80 photo and stores in file with name equal to date/time
def cmd_take_photo():
    photo_name = time.strftime('%c') + '.png'
    with picamera.PiCamera() as camera:
        camera.resolution(142, 80)
    return (photo_name)

You can find out how we used the radios to transmit the photos from the rover to the command centre in the radio and integration tutorials (when available).

Next tutorial: Avoiding rover collisions

First tutorial: Controlling the RPy-Rover’s motors

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s