# Notes for using Arduino with ROS
# Setup Notes
# ROS Libraries
Install ros libraries
$ sudo apt-get install ros-indigo-rosserial-arduino
$ sudo apt-get install ros-indigo-rosserial
# Arduino Libraries
The rosserial Arduino library does not support the M0 Pro so a few changes have to be made. Install the latest version from github via the instruction on the ROS wiki. Then replace the file '/rol_lib/ArduinoHardware.h' with ArduinoHardware.h. In summary of the changes, some cases have been added to force the serial definitions based upon use of the M0 Pro:
...
#elif defined(USE_M0PRO_NATIVE)
#define SERIAL_CLASS Serial_
#elif defined(USE_M0PRO_PROGRAMMING)
#include <HardwareSerial.h> // Arduino AVR
#define SERIAL_CLASS HardwareSerial
...
#elif defined(USE_M0PRO_NATIVE)
iostream = &SerialUSB;
...
In the Arduino sketch file it must have definitions:
#define USE_USBCON
// Use this for Native USB port
#define USE_M0PRO_NATIVE
// Use this for Programming USB port
// #define USE_M0PRO_PROGRAMMING
# Custom Messages
To use custom messages with Arduino, first create the custom message, then make sure ros_serial is installed. This can be done by adding it as a build dependency in the relevant package.xml
file:
<build_depend>rosserial_arduino</build_depend>
and installing dependencies for the project:
$ rosdep install --from-paths src --ignore-src -r -y
Then from your catkin workspace run:
$ source devel/setup.bash
$ rosrun rosserial_arduino make_libraries.py ~/Arduino/libraries
This will create the ros_lib
arduino library folder in the arduino library directory. Any desired location can be specified.