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

I used the above template to write a ROS node that will advertise the distance to an object detected by an ultrasonic sensor.

How to run the node
Step 1: Open a new Terminal, type roscore and press the Enter key
Step 2: Open another Terminal and type the following command:

Step 3: To verify the node’s output, open a new Terminal and type the following command:

  • Posted in: Tutorials

1 comment » Write a comment

  1. You may notice that the output:
    currentMillis-range_timer (will get the wrong value when currentMillis= intervalR) may change to: currentMillis>=range_timer + intervalR

Leave a Reply

Required fields are marked *.