Revision 3 as of 2011-07-12 01:08:48

Clear message

Note: This tutorial assumes that you have completed the previous tutorials: Hello World Publisher.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

CMake with rosserial_arduino

Description: This tutorial shows how to use the CMake build system with rosserial_arduino.

Tutorial Level: ADVANCED

Next Tutorial: Servo Controller

When you are doing large software projects, the Arduino IDE quickly becomes unwieldy. You often want to be able to compile your project from the command line or use a different IDE like eclipse. By building your rosserial_arduino project using CMake, you can take advantage of both of these tools.

For this tutorial, we are going to make a hello world rosserial_arduino package.

Making Your Project

Making your rosserial_arduino project is just like making any other ROS package. You run

roscreate-pkg helloworld rosserial_arduino std_msgs

As usual, use roscreate-pkg to create a package named helloworld which depends on rosserial_arduino and std_msgs. You must depend on rosserial_arduino and since we are going to use String messages, the package depends on std_msgs.

Souce Code

CMakeList.txt

  • sdaf

Testing

# - Generate firmware for rosserial_arduino Devices
# generate_ros_firmware(TARGET_NAME)
#        TARGET_NAME - Name of target
# Creates a Arduino firmware target.
#
# The target options can be configured by setting options of
# the following format:
#      ${TARGET_NAME}${SUFFIX}
# The following suffixes are availabe:
#      _SRCS           # Sources
#      _HDRS           # Headers
#      _LIBS           # Libraries to linked in
#      _BOARD          # Board name (such as uno, mega2560, ...)
#      _PORT           # Serial port, for upload and serial targets [OPTIONAL]
#      _AFLAGS         # Override global Avrdude flags for target
#      _SERIAL         # Serial command for serial target           [OPTIONAL]
#      _NO_AUTOLIBS    # Disables Arduino library detection
#      _CUSTOM_COM     # use a custom implementation of fx_putc and fx_getc for rosserial

# Here is a short example for a target named test:
#       set(test_SRCS  test.cpp)
#       set(test_HDRS  test.h)
#       set(test_BOARD uno)
#       generate_ros_firmware(test)

Additional Info

rosserial_arduino CMake implementation is found under rosserial_arduino/cmake_scripts. It is based on this arduino-cmake project. You should never need to edit these files. You just need to include them into your CMakeList