Note: This tutorial assumes that you have completed the previous tutorials: ROS Tutorials.

Arduino IDE Setup

Description: This tutorial shows step-by-step how to setup up the Arduino IDE to use rosserial.

Tutorial Level: BEGINNER

Next Tutorial: Hello World (example publisher)

Introduction

The Arduino and Arduino IDE are great tools for quickly and easily programming hardware. Using the rosserial_arduino package, you can use ROS directly with the Arduino IDE. rosserial provides a ROS communication protocol that works over your Arduino's UART. It allows your Arduino to be a full fledged ROS node which can directly publish and subscribe to ROS messages, publish TF transforms, and get the ROS system time.

NOTE: If you do not already have an Arduino IDE installed, download it from the Arduino website. It is best to install the application into a folder on the application PATH, the desktop, or home folder. Once installed, launch the application to select your sketchbook location. (See arduino official website, sketchbook is a standard place to store your programs, or sketches). Close the IDE when done.

Our ROS bindings are implemented as an Arduino library. Like all Arduino libraries, ros_lib works by putting its library implementation into the libraries folder of your sketchbook. If there is not already a libraries folder in your sketchbook, make one. You can then install the library from either debs (sudo apt-get install ros-electric-rosserial) or source.

In order to use the rosserial libraries in your own code, you must first put

#include <ros.h>

prior to including any other header files, e.g.

#include <std_msgs/String.h>

otherwise the Arduino IDE will not be able to locate them.

Installing from Source

If you want to install from source, you'll need to do a few extra steps:

hg clone https://kforge.ros.org/rosserial/hg rosserial
rosdep install rosserial_arduino
rosmake rosserial_arduino

These commands clone the rosserial repository using mercurial, install the packages dependencies, generate the rosserial_msgs needed for communication, and generate a libraries folder containing the ros_lib library.

Finishing Up

Now that you've installed either from source or debs, all you have to do is copy the rosserial_arduino/libraries directory into your Arduino sketchbook:

roscd rosserial_arduino/libraries
cp -r ros_lib <sketchbook>/libraries/

After restarting your IDE, you should see ros_lib listed under examples:

arduino_ide_examples_screenshot.png

Wiki: rosserial_arduino/Tutorials/Arduino IDE Setup (last edited 2012-02-27 03:37:29 by EricaKane)