1. Arduino

1.1. Installation

Installing the rosserial metapackage:

sudo apt-get install ros-kinetic-rosserial

Install the rosserial-arduino client package:

sudo apt-get install ros-kinetic-rosserial-arduino

Clone

git clone https://github.com/ros-drivers/rosserial.git

Download and install Arduino IDE.

To use the serial port without root permissions:

ls -l /dev/ttyACM*

or

ls -l /dev/ttyUSB*
//
sudo usermod -a -G dialout <username>

In Arduino IDE set the Sketchbook location to /home/robot/arduino. Arduino should create a folder called libraries inside it.

Open the terminal and navigate to

cd /home/robot/arduino/libraries

Don’t forget the dot . at the end of the following commands, it indicate current directory

rosrun rosserial_arduino make_libraries.py .

After these steps, you should find the ros_lib voice in the examples of Arduino IDE.

1.1.1. Test the installation

Open the example string_test from Arduino IDE:

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

ros::NodeHandle  nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

char hello[19] = "chapter8_tutorials";

void setup()
{
  nh.initNode();
  nh.advertise(chatter);
}

void loop()
{
  str_msg.data = hello;
  chatter.publish( &str_msg );
  nh.spinOnce();
delay(1000);
}

Upload the sketch to the arduino board.

Open 3 different terminals and launch:

roscore

rosrun rosserial_python serial_node.py /dev/ttyACM0

rostopic echo chatter

Download string_test.ino