This guide will walk you through how to install and setting up an Arduino board to work with Raspberry Pi 3 having in common ROS Kinetic.
To walk through this guide, you must have a Raspberry Pi 3 with ROS Kinetic installed, an Arduino UNO board connected via the USB port to Pi, and some Linux knowledge.
Arduino is an open-source development tool very easy to use both as hardware and software. This development board simplifies the robot construction process and is therefore used together with Raspberry Pi and ROS to control sensors, motors or any other component that can be controlled with a microcontroller.
The Arduino microcontroller can only run one ROS node at a time.
Install the Arduino IDE
Arduino is connected to Raspberry Pi 3 through the USB port. To program Arduino, you need to install the Arduino IDE on the Pi.
To install the Arduino IDE on the Ubuntu Mate operating system, use the following commands in the Linux terminal.
sudo apt-get update
sudo apt-get install arduino arduino-core
After installing the Arduino IDE, the next step is installing the package that allows communication between ROS and the serial port of the Arduino board. The package is called rosserial_arduino and allows the node that will run on the Arduino to publish or subscribe to the nodes running on Raspberry Pi 3. The rosserial package contains three other packages: rosserial_msgs, rosserial_client, and rosserial_python.
sudo apt-get install ros-kinetic-rosserial-arduino
sudo apt-get install ros-kinetic-rosserial
After installing the Arduino IDE and the rosserial package, we will first check the IDE, but not before giving Administrator privileges to the current user for the Arduino Permission Checker.
The command is:
sudo usermod -a -G dialout your_user_here
To open the Arduino IDE, write the following command in the Ubuntu terminal:
Once we have checked the installation of the IDE, the next step is to close it and continue the setup operations. To close, use the Ctrl + C keys.
If you give the command ls in the Ubuntu terminal, you will find a new sketchbook directory. If you do not want to change your location or name, all Arduino sketches will be saved in this directory.
To write Arduino sketches for ROS, we need the ros_lib library.
Install the ros_lib library
The link between ROS and Arduino is through the ros_lib library. This library will be used as any other Arduino library.
To install the ros_lib library, type the following commands in the Ubuntu terminal:
rosrun rosserial_arduino make_library.py .
If you browse the sketchbook/libraries/make_library.py/ros_lib/examples folder, you will find a list of examples that can be used in ROS projects. One of these examples is Ultrasound. In another tutorial, I will use this example to control one or more HC-SR04 ultrasonic sensors with ROS and Arduino.
Before checking the latest IDE settings, you must rename the ‘make_library.py’ folder. The Arduino IDE does not allow the use of points in the name of the libraries. So the name of the bookstore will become ‘make_library’.
Check the Arduino IDE settings
To check the settings made, we will open the Arduino IDE again. To launch the application, we will use the command:
After opening the IDE, check if you have access to the ros_lib examples: File -> Examples -> make_library -> ros_lib
Check the serial port:
Tools-> Serial Ports
These are the steps to install and setup the Arduino IDE on Raspberry Pi 3 with ROS Kinetic.