Creating an example program to use Arduino

Now, we are going to upload an example program from the IDE to Arduino. Select the Hello World sample and upload the sketch:

Arduino IDE with roslib examples

The code in the preceding screenshot is very similar to the following code. In the following code, you can see an include line with the ros.h library. This library is the rosserial library, which we have installed before. Also, you can see a library with the message to send with a topic; in this case, it is the std_msgs/String type.

The following code snippet is present in the c8_arduino_string.ino file:

#include <ros.h> #include <std_msgs/String.h> ...

Get ROS Programming: Building Powerful Robots now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.