How To Setup ROS Kinetic To Communicate Between Raspberry Pi 3 and a remote Linux PC

How To Setup ROS Kinetic To Communicate Between Raspberry Pi 3 and a remote Linux PC

I have a Raspberry Pi 3 running ROS Kinetic and I use it to control an autonomous robot. The plan is to improve my robot by adding computer vision capabilities. The Raspberry Pi has resources to build intelligent robots and the community helps me more in fixing a lot of problems. These are the reasons for this moment not to change it with another single board computer with advanced hardware resources. The bad thing is that Pi 3 has limited capabilities for graphics applications such as rviz or running computer vision applications.

My idea (I hope is a good one and will work) is to use Pi 3 and a Linux computer in the same network to exchange data from one to another while I run rviz and the Gazebo simulator on the PC.

The first step in implementing my idea is to setup ROS Kinetic to communicate between Pi 3 and the remote Linux computer. Below are the steps that I did to make both computers communicate with each other.

  • Step 1: I checked that everything was okay with ROS Kinetic on my Linux PC. I installed it some time ago using the steps described here.
  • Step 2: I re-installed a Linux image and ROS Kinetic on the Raspberry Pi 3 board. It took some time since I chose to install ROS on the Raspbian Stretch Lite. This operating system is what I need for my robot: it doesn’t have desktop applications or a GUI of any kind.
  • Step 3: At this step, I pay some attention at the IP address for the ROS master node (Pi) and the IP address for other ROS node (the Linux PC).
    1. on Raspberry Pi 3 type the following command:

      Navigate to the end of the file and add these two lines:

    2. on the Linux PC, type the following command:

      Navigate to the end of the file and add these lines:

These are all the steps to make two Linux computers communicate and share nodes, topics, and services.

How to Install ROS Kinetic on Raspberry Pi 3 running Raspbian Stretch Lite

I want to control an autonomous robot with a Raspberry Pi 3 board and ROS Kinetic. The Pi 3 will be connected to another Linux PC used for monitoring and control settings. The setup for computers are in this article.

Due to the lack of Pi resources in terms of processor and memory, I’m forced to use resources more efficiently. The first step is to install on Pi an operating system like Raspbian Stretch Lite. The interaction with this system is done through type commands. It doesn’t have GUI and other software included with the Desktop version. Theoretically speaking, it is a perfect operating system if you want to not stress the Pi board with too many tasks that you do not need anyway.

The system will use the Raspberry Pi board as the master while the PC is the slave. This configuration means to run the Roscore on the robot instead on the remote PC. The PC is used to see the message that coming from Pi or send some manual correction back to the robot.

I installed the ROS Kinetic version with no GUI tools on the Raspbian Stretch Lite and I put all the steps below.

  • Step 1: Download and install Raspbian Stretch Lite
    The installation steps for Raspberry Lite are described here.
  • Step 2:Connect via SSH to Pi and run the below commands:

    sudo sh -c ‘echo “deb $(lsb_release -sc) main” > /etc/apt/sources.list.d/ros-latest.list’

    wget -O – | sudo apt-key add –

    sudo apt-get update

    sudo apt-get install -y python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential cmake

    sudo apt install dirmngr

    sudo rosdep init

    rosdep update

    rosinstall_generator ros_comm –rosdistro kinetic –deps –wet-only –tar > kinetic-ros_comm-wet.rosinstall

    wstool init src kinetic-ros_comm-wet.rosinstall

    rosdep install -y –from-paths src –ignore-src –rosdistro kinetic -r –os=debian:stretch

    sudo ./src/catkin/bin/catkin_make_isolated –install -DCMAKE_BUILD_TYPE=Release –install-space /opt/ros/kinetic -j1

    (thanks CaJU and Bruce W)

    source /opt/ros/kinetic/setup.bash

    echo ‘source /opt/ros/kinetic/setup.bash’ >> ~/.bashrc

    mkdir -p ~/catkin_workspace/src

    cd catkin_workspace/src


    cd ~/catkin_workspace/


    source ~/catkin_workspace/devel/setup.bash

    echo ‘source ~/catkin_workspace/devel/setup.bash’ >> ~/.bashrc

    export | grep ROS

  • Step 3 (optional): The installation process takes several hours and sincerely, I don’t want to repeat the installation too soon. I decide to clone the memory card as soon as I finished the initial installation. Here are the steps needed to clone the memory card.

You can find additional information here and here.

4 and 6 Axis Arduino Robot Arm Kits

A robotic arm may seem complicated to be built and controlled. It involves teaching how to program a microcontroller to control some servo motors for repetitive tasks. But you can learn to do it quickly using robotic arm kits.

I’ve seen a lot of robotic arm kits around the web in the last year, but the ones below are the favorites today. The robotic arms from this article have 4 or 6 degrees of freedom to suit of any project.

  • 4DOF Robot Arm with Remote Control PS2

    4DOF Robot Arm with Remote Control PS2

    4DOF Robot Arm with Remote Control PS2

    The robotic arm kit from Banggood is controlled with two ps2 joysticks. It’s a simple way to control the arm and does not involve running an advanced programming code on the Arduino board.

    The range of applications for such a kit is small compared to a programmable kit, but for the price of $39.99, it is a good start for school students. It has a manual and a guide to install the code for the Arduino board.

  • LewanSoul LeArm 6DOF

    LewanSoul LeArm 6DOF

    LewanSoul LeArm 6DOF

    This robot arm is made entirely of metal and aluminum and can lift up a weight of about 250 grams.

    A Bluetooth module is added to the main board of the robot to control the arm with a smartphone or tablet. Also, you have an application that simulates all the joints of the robot arm, so that you can move it at a push of the touchscreen. This is the case if you do not want to use wires to control your arm. Otherwise, you can use wires and a remote control to move the arm on all the 6 axes.

    It is neither the cheapest 6-axis robotic arm nor the most expensive. It has a price of $129.99 on Amazon. The price does not include transport costs.

  • 6-Axis Desktop Robotic Arm

    6-Axis Desktop Robotic Arm

    6-Axis Desktop Robotic Arm

    At a price of $174.99, Sainsmart offers us a robotic arm made from simple components available to anyone like a PVC pipe. Such an approach is very good for the DIY users who can easily change the structure of the arm. The arm can be used for applications like pick and place, palletizing, and more.

    The robotic arm requires an external power supply, other than the 5V DC from Arduino Uno.

    Another good part of this kit is the documentation. Besides the wiki, you can find a lot of projects that use the robotic arm for different applications like pick and place an object or object detection.

  • uArm Swift Pro

    uArm Swift Pro

    uArm Swift Pro

    The range of applications for uArm Swift Pro is large compared to other kits. With a repeatability of 0.2mm and a maximum payload of 500g, the arm is suitable for pick&place applications to 3D printing.

    This is not a cheap kit. It has a price of $1,129.95 on Sparkfun. The arm is open-source and controlled by an Arduino Mega 2560 board. For documentation, you can access this link.

ROS 2 Ardent Apalone was officially released. I made a list of 5 reasons why you should use it for your robot.

Coincidentally or not, after 10 years of ROS 1, the Open Source Robotics Foundation has launched a new version called ROS 2. ROS 2 (the code name “Ardent Apalone” – Apalone is a genus of turtles in the family Trionychidae) was officially released at the end of 2017. The release of the new ROS has gone a little unobserved by the usual ROS users, and it is understandable since there are few articles in online about this release.

So in this article, I will try to describe why Ardent Apalone appeared and what gaps left by ROS 1 will be covered by the new ROS 2 version.

Before going into the subject, I will remind that ROS (The Robot Operating System) is not an operating system as we know. ROS (or ROS 1) is a solution designed to be hosted by an operating system like Linux. Or, as the majority calls it, this is a meta-operating system. And of course, it’s designed for robots.

Like ROS 1, the ROS 2 is the network of nodes that allows communication/exchange of information between the components used in the robot. So far, nothing new. Everything is the same as we know it today.

One of the reasons behind the launch of a completely new version (ROS 2) and not the improvement of ROS 1 is the significant changes to the framework. The team that developed ROS 2 has chosen to implement the new changes safely in the new framework. So, they did not want to alter the ROS 1 variant to not affect the performance and stability of the current versions of ROS. From my point of view, it’s a wise decision. Especially because there is a plan to implement the ROS 1 nodes to work with the ROS 2 nodes together on the same robot. So there will not be significant changes to the systems that will work with both ROS variants.

Below I made a list of the new features of ROS 2.

  1. Three compatible operating systems
    One of the news is that besides Linux, ROS 2 is compatible with Windows 10 and Mac OS X 10.12 (Sierra). If the support of OS X is not new (officially ROS 1 were compatible with OS X as an experimental part), the support for Windows is something new for ROS.
  2. Real-time support
    ROS 1 has not been designed for real-time applications. The goal of ROS 1 was to create a simple system that can be re-used on various platforms. In other words, the use of ROS has led to a significant reduction in the development of a robot.

    A real-time system must update periodically to meet deadlines. The tolerance to errors is very low for these systems.

    The example below is used by the ROS team to describe a situation when a system needs real-time support.

    A classic example of a controls problem commonly solved by real-time computing is balancing an inverted pendulum. If the controller blocked for an unexpectedly long amount of time, the pendulum would fall down or go unstable. But if the controller reliably updates at a rate faster than the motor controlling the pendulum can operate, the pendulum will successfully adapt react to sensor data to balance the pendulum. [source]

    In other words, the real-time support is more about computation delivered at the correct time and not performance. If a system fails to send a response is as bad as giving a wrong response. This new feature is very useful in safety- and mission-critical applications such as autonomous robots and space systems.

  3. Distributed discovery
    This new feature facilitates, in some way, the communication between nodes. In other words, the nodes in ROS 2 do not need the master node to change messages between them. If you run a C ++ written node and another in Python (a talker and a listener), the nodes will identify each other and start communicating automatically. You may be wondering how to identify the nodes if there is no master node to allow authentication. In ROS 2, the role of the master node was taken over by the ROS_DOMAIN_ID environment variable. When a ROS 2 node is launched, it makes its presence known in the network to other nodes that share the same ROS domain.
  4. Node lifecycle management

    Managed nodes are scoped within a state machine of a finite amount of states. These states can be changed by invoking a transition id which indicates the succeeding consecutive state. [source]

    The most important thing is that a managed node presents a known interface and is executed according to a known life cycle machine. This means that the developer can choose how to manage the life cycle functionality.

  5. Security
    ROS 1 had no security issues because it did not exist. With ROS 2 we can talk about security. It integrates the transport layer of ROS 1 with an industry standard transport layer that includes security. The layer is called Data Distribution Service (DDS).

I made a police light application with a tower light and Arduino

A few days ago I bought a three-color tower light with buzzer for visual and audible alerts. And because I’m a big kid, I thought to build as the first application a game of lights in the style of a police car. The result will be seen at the bottom of this article.

Before entering into the connection and programming area, I give you some details about the product. The tower light has three colors and a buzzer. The tower can be easily controlled by an Arduino board, four N-channel MOSFETs or NPN transistors, and four resistors.

The light tower is branded Adafruit and produced in China. At least this is written on the product that I use in this tutorial. Also, there is a schema somewhere on it with Chinese letters. Thank you Adafruit!

Everywhere I’ve been looking for information about how it works and how I can control it, I’ve given this tutorial. The tutorial is dedicated to the RGB LED strips and less to a light tower. Generally, Adafruit produces good tutorials, so I think that I don’t have to make a great effort to turn ON the lights. But this time I was a bit misguided by the schema with connections found in the tutorial. For the NPN Bipolar Transistors (PN2222), I recommend you carefully look how the three pins of the transistor are located or use the schema from this article. When I connected the light tower just like in the Adafruit’s tutorial (the NPN schema), the result was a tower light that just makes some noise and has two lights on. Obviously, the pins of the transistors were wrongly connected.

Let’s get to the practical side.


  • 1 X Tower Light – Red Yellow Green Alert Light & Buzzer (I buy it from here, but you can buy it also from Amazon)
  • 4 X NPN Bipolar Transistors (PN2222) (link on Amazon)
  • 4 X 100-220 Ohm resistors (link on Amazon)
  • 1 X Arduino board (I think you already have one, but in case I’m wrong, you can take one from here)
  • some wires (link on Amazon)

The schema:

Tower light and Arduino Schema

Tower light and Arduino Schema

The Arduino code:

Tower Light Demo:

How to use rosserial with two Arduinos and Raspberry Pi

Arduino is a great development board for reading data from various sensors and controlling the robot’s DC motors. Raspberry Pi is good at running ROS on Linux. So, we can benefit from both systems to build smart robots. The easiest way is to connect these boards via USB cable and make them communicate through ROS nodes.

In this tutorial, I’ll show you how to use two Arduino boards as an extension of the Raspberry Pi computer. Before starting writing the ROS nodes, I have to set the Pi to identify each Arduino. This identification becomes necessary when the robot’s architecture is complex.

Only one ROS node can run on an Arduino board. And because I have two Arduino, I will use one to generate a random number and another to control the LED connected to pin 13.

How To use rosserial with Two Arduinos and Raspberry Pi

I will run one ROS nodes that will send and receive data according to this flowchart

The description of the flowchart

  • The user will start all ROS nodes by running a .launch file.
  • The first Arduino board will run a random number script and send data to Raspberry Pi.
  • A ROS node will receive a random number from the first Arduino board. The node will run on Raspberry Pi and will command the LED on the second Arduino board.
  • The second Arduino board will turn ON and OFF the LED (pin 13) depending on the commands received from the ROS node running on the Pi board.

The ROS node to generate a random number

Testing the node
Step 1: Open a Linux Terminal and type the command:


Step 2: Open a second Linux Terminal and type the following command:

rosrun rosserial_python /dev/ttyACM*

Step 3: To see the random numbers generated by the Arduino node, open a third Terminal and type the following command:

rostopic echo /random_number

The ROS node that displays and calculates the LED’s stage

This ROS node in Python will run on Raspberry Pi. Before you start writing the Python code, you must create the workspace and the package that contains the node. All you need to do is in this article.

The ROS node that controls the LED

Write the launch file

<node pkg=”rosserial_python” type=”” name=”twoArduino_LED” output=”screen”>
<param name=”port” value=”/dev/ttyACM0″/>
<param name=”baud” value=”57600″/>
<node pkg=”rosserial_python” type=”” name=”twoArduinos_RandNo” output=”screen”>
<param name=”port” value=”/dev/ttyACM1″/>
<param name=”baud” value=”57600″/>
<node name=”random_number” pkg=”pi_and_arduino” type=”” output=”screen” />



Fruit Picking Robots

The robotics designers offer to the farmers the opportunity to significantly reduce the costs of manual labor for harvesting. The robots can replace the seasonal manual work or even permanent employees on farms.

In this article, I made a presentation of the robots designed to replace the manual work in harvesting the fruits. All of the below robots have the ability to detect, recognize, and determine if these are ripe enough to be picked. In addition, they are able to harvest the fruits without damaging them.

Apple-Picking robot with vacuum

Thanks to the start-up Abundant Robotics, apple orchard farmers will be able to use robots instead of seasonal pickers. The AR startup uses the vacuum to pick apples from trees.

The robot uses computer vision algorithms to identify and locate apples in the tree. The technology used is not specifically designed for agriculture. The same technology can be applied in a wide range of industries, but for now they are using it into the agriculture.

Apples require attention at harvesting. The robot is designed to work with precision in harvesting and to store the apples. The collection is made through a flexible hose and the storage is made in the same big boxes as used by the human workers.

The company is already planning the next version of the robot that will have many more robotic arms.

The transition from the prototype to the mass production of the robot is scheduled to start in 2018.
Read more →

Template for a ROS Subscriber Using rosserial on Arduino

A few weeks ago I started writing a series of tutorials that ease the work of beginners in ROS. The first tutorial was about a template for a publisher node, the second tutorial was about a template for a subscriber node in ROS, the third tutorial was a simple ROS subscriber and publisher in Python, and the fourth template is about a publisher using rosserial.

Today, I continue the series of tutorials with a template for a ROS subscriber using rosserial on the Arduino board. In addition, I’ll write a subscriber node based on the below template.

Below you will find the template for a ROS subscriber using rosserial on the Arduino board. To write your own subscriber using rosserial on Arduino, copy the template into Arduino IDE, delete the information that you don’t need and replace the text in capital letters.

ROS and Arduino

I used the above template to write a ROS node that will subscribe to a node that generates random numbers.

How to run the node
Step 1: Open a new Terminal, type roscore and press the Enter key;
Step 2: Open a new Terminal and run the node to publish the messages;
Step 3: Open another Terminal and start the subscriber node by typing the following command:

Template for a ROS Publisher Using rosserial on Arduino

A few weeks ago I started writing a series of tutorials that ease the work of beginners in ROS. The first tutorial was about a template for a publisher node, the second tutorial was about a template for a subscriber node in ROS, and the third tutorial was a simple ROS subscriber and publisher in Python.

Today, I continue the series of tutorials with a template for a ROS publisher using rosserial on the Arduino board. In addition, I’ll test the template and write a publisher node.

Below you will find the template for a ROS publisher using rosserial on the Arduino board. To write your own publisher using rosserial on Arduino, copy the template into Arduino IDE, delete the information that you don’t need and replace the text in capital letters.

ROS and Arduino

Read more →

How To setup Raspberry Pi to identify two Arduino devices

The applications that run on Raspberry Pi can’t always identify the serial port that belongs to each Arduino board. If we don’t use an identifier for each board, the serial port may change every time we disconnect or connect the Arduino board to Raspberry Pi.

In this tutorial, I’ll show you how to configure Raspberry Pi to automatically identify two Arduino boards. The procedure can be extended to multiple boards, but in this tutorial, I’ve used two identical Arduino boards.

How To setup Raspberry Pi to identify two Arduino devices

How To setup Raspberry Pi to identify two Arduino devices

Below are the steps to identify each board separately, regardless of which USB port of the Pi is used.

Step 1: navigate to /etc/udev/rules.d/99-arduino.rules
Step 2: this command returns the two serial ports connected to the Arduino boards

ls /dev/ttyACM* for two Arduino boards

ls /dev/ttyACM* for two Arduino boards

Step 3: after finding the KERNEL of the two Arduino boards, run for each board the command:

Instead of ttyACM00, use the serial port of the Arduino board
Step 4: for each Arduino’s KERNEL, add a line to the file 99-arduino.rules

Setup Raspberry Pi

Step 5: refresh udev