ROS¹ on Raspberry PI with docker: Picamera and custom Dockerfile

This is the second story of the 3-part series: ROS on Raspberry PI. I have divided the topic in 3 parts as below:

PI Camera:

Create new file: /etc/udev/rules.d/99-camera.rules on the host raspberry pi and paste below line in it:

SUBSYSTEM==”vchiq”,MODE=”0666"

Make sure that your host rpi has picamera installed as per the picamera instructions. All the picamera and raspistill dependencies are in /opt/vc folder on your host rpi. We can use -v /opt/vc:/opt/vc command to mount/share this folder on the docker container. We would also need to create an env variable called in order to make this work. We can add the env variable using below command while launching docker container:

--env LD_LIBRARY_PATH=/opt/vc/lib

Make sure that your Dockerfile has below environment variable set before installing the picamera:

...
ENV READTHEDOCS=True
RUN pip3 install picamera
...

Run docker:

Start your container with below command from rpi:

pi@raspberrypi:~ $ docker run --privileged --device /dev/vchiq -it --rm -v /opt/vc:/opt/vc --env LD_LIBRARY_PATH=/opt/vc/lib <<imageId>

Once docker container is launched test the camera using the command:

root@f266081cf35b $ /opt/vc/bin/raspistill -o output.jpg

Similarly you can also add other devices as below

docker run --device /dev/i2c-0 --device /dev/i2c-1 <imageId>

--

--

Data Science, IoT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store