Good afternoon, dear readers of Habr!
I am starting a series of articles on the practical use of ROS on the Raspberry Pi for robotic projects in conjunction with the Arduino. This cycle has the following structure:
- Install and configure the working environment
- Computer Vision with RPi Camera Board
- Controlling the robot from the keyboard using the teleop
- Robot control with PS3 Dualshock game controller
Who cares, I ask under the cat.
In the first article of the cycle, I will talk about installing the necessary ROS modules and setting up the working environment on the Raspberry Pi to perform specific tasks using ROS. Since in the
previous article I described in detail the procedure for installing ROS and setting up the environment for the Raspberry Pi with the Raspbian version of Wheezy installed, in this article I will discuss the pitfalls when installing and configuring ROS on the Raspbian version of Jessie. Also note that in the previous article I used the Raspberry Pi Model B for testing, whereas at the time of writing this article I performed experiments on the Raspberry Pi version B +. The main difference between version B + and B is the number of available USB ports on the board (there are two in model B, and four in model B +) and support for microSD cards (in model B +, the SD card slot is replaced by the microSD card slot). I recommend using the B + model because you will need USB ports to connect the power supply, the Arduino board, and possibly also to connect the keyboard and mouse (if you work on the Raspberry Pi locally, not via SSH over the network).
Installing ROS Indigo
A little advice: for a more comfortable work with ROS on the Raspberry Pi, it is better to use a microSD card of 16 GB or more. When using a card with 8 GB, after installing ROS Comm, all the necessary libraries for computer vision and various drivers for external devices, less than 1 GB of free space remains on the card. On a 16 GB card after installing similar packages, I had 7 GB of free space. I recommend installing the version of ROS Comm, and then, if necessary, installing the necessary packages for ROS (I'll show how this is done later in the article).
Instructions for installing ROS Indigo on the Raspberry Pi are available on the
website . Please note that you need to execute the commands assigned to your version of Rasbian (Jessie in my case).
When executing the final compilation of ./src/catkin/bin/catkin_make_isolated, an error may appear when compiling the roscpp component with a similar output:
')
CMakeFiles/Makefile2:308: recipe for target 'CMakeFiles/roscpp.dir/all' failed make[1]: *** [CMakeFiles/roscpp.dir/all] Error 2 Makefile:127: recipe for target 'all' failed
The problem is the lack of a swap partition on the SD card. A 1 GB swap partition is required. Set the desired swap as follows. First, select a place under the swap:
dd if=/dev/zero of=/swap bs=1M count=1024
Let's format the new section for swap:
mkswap /swap
Let the system know that it can use the new swap section:
swapon /swap
To automatically enable swap on our section, after reboot, we write the rule in / etc / fstab:
/swap none swap sw 0 0
After that, simply rerun the installation procedure.
Installing additional ROS packages
Install all the necessary ROS packages that we will need in the future for various tasks. Packages can be installed using the rosinstall script. Installation will take several hours.
We will need the following packages:
- cv_bridge is used to convert OpenCV images to ROS Image format and vice versa.
- image_transport is intended for subscription and publication of images in ROS, hidden implements the compression of images for faster transport
- joystick_drivers provides hardware support for game controllers like the PS3 Dualshock
- rqt_image_view is a graphical program for visualizing RGB images published in a topic.
- rqt_graph is used to visualize the scheme of the computational graph ROS (shows all the active nodes and topics and the connections between them)
- rqt_plot is a graphical utility for visualizing values posted to a topic as a graph.
- teleop_twist_keyboard provides a user interface for controlling the robot by pressing keys on the keyboard
Run the following commands to install all the packages:
$ rosinstall_generator ros_comm cv_bridge image_transport joystick_drivers rqt_image_view rqt_graph rqt_plot teleop_twist_keyboard --rosdistro indigo --deps --wet-only --exclude roslisp --tar > indigo-custom_ros.rosinstall $ wstool merge -t src indigo-custom_ros.rosinstall $ wstool update -t src $ rosdep install --from-paths src --ignore-src --rosdistro indigo -y -r --os=debian:jessie $ sudo ./src/catkin/bin/catkin_make_isolated --install -DCMAKE_BUILD_TYPE=Release --install-space /opt/ros/indigo
Setting up the working environment for working with Arduino
Unlocking serial ports in the Raspbian version of Jessie is slightly different from that described in the
previous article .
The fact is that the / etc / inittab file is missing from Raspbian Jessie. inittab was part of sysvinit, which has been replaced by systemd in the Jessie version. serial getty is now a regular service. Therefore, we will need to disable the serial getty service:
$ sudo systemctl stop serial-getty@ttyAMA0.service
The procedure for disabling debug logging to the serial port remains unchanged as in the Raspbian version of Wheezy — the file / boot / cmdline.txt is edited as described in the
previous article .
The rosserial_arduino installation is performed according to the scheme from the previous article.
The installation of the main modules of the ROS platform and the setting of the working environment are complete. It's time to get down to specific tasks. To be continued…