Skip to content

Raspberry Pi Camera

The diffbot robot uses the UbiquityRobotics/raspicam_node to interface the Raspberry Pi Camera v2.

RPi Camera v2.

Setup

Currently there exists no binary of the raspicam_node for ROS noetic (only for kinetic there is the ros-kinetic-raspicam-node). To work with the raspicam_node for ROS Noetic, you have to build it from source with steps outlined in the build intstructions of the readme. For completeness, these steps are listed here:

First go to your catkin_ws cd ~/ros_ws/src and download the source for this node by running

1
git clone https://github.com/UbiquityRobotics/raspicam_node.git

There are some dependencies that are not recognized by ROS, so you need to create the file /etc/ros/rosdep/sources.list.d/30-ubiquity.list and add the following to it:

1
yaml https://raw.githubusercontent.com/UbiquityRobotics/rosdep/master/raspberry-pi.yaml

This will add ROS dependency sources, which are relevant for the Raspberry Pi.

For completeness you can list the content of this yaml file here:

Show content
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
libraspberrypi0:
  debian:
    apt:
      packages: [libraspberrypi0]
  ubuntu:
    apt:
      packages: [libraspberrypi0]
libraspberrypi-dev:
  debian:
    apt:
      packages: [libraspberrypi-dev]
  ubuntu:
    apt:
      packages: [libraspberrypi-dev]
libpigpio:
  debian:
    apt:
      packages: [libpigpio-dev]
  ubuntu:
    apt:
      packages: [libpigpio-dev]
libpigpiod-if:
  debian:
    apt:
      packages: [libpigpiod-if-dev]
  ubuntu:
    apt:
      packages: [libpigpiod-if-dev]

To make use of these sources run

1
rosdep update

Next, we parse the package.xml file for required dependencies and also install them with the rosdep command:

1
2
cd ~/ros_ws
rosdep install --from-paths src --ignore-src --rosdistro=noetic -y

Finally, you can compile the code with the catkin build command from catkin-tools or use the legacy catkin_make command.

Running the node

To publish the camera image on the /raw/image/compressed topic run the following on the SBC of the robot:

1
roslaunch raspicam_node camerav2_410x308_30fps.launch

Running rostopic list should show the topics of raspicam node:

1
2
3
4
/raspicam_node/camera_info
/raspicam_node/image/compressed
/raspicam_node/parameter_descriptions
/raspicam_node/parameter_updates

To view the compressed image run the following command on your development PC:

1
rosrun image_view image_view image:=/raspicam_node/image _image_transport:=compressed

This will open up a window where you can see the camera image. If it is dark, check if you removed the lense protection ;-)

Note

There is also a rpicamera.launch in the diffbot_bringup package which you can make use of:

1
roslaunch diffbot_bringup rpicamera.launch
Back to top