This is an old revision of the document!
Interfacing with ROS
ROS is a flexible framework for writing robot software. It is great collection of tools, libraries, and conventions. You can make use of ROS within EEROS in the following two ways.
Using Publisher and Subscriber Blocks in the Control System
You can insert blocks into the control system which publish or subscribe a given type of ROS message.
Special blocks in EEROS take care of sending signals to and receiving signals from ROS. These signals must be packed into ROS messages. Each topic transmits messages of a certain type. Depending on the message type you have to use certain blocks in your control system, see Blocks for Interfacing with ROS
Using ROS through EEROS HAL
EEROS can communicate with the underlying hardware through its Hardware Abstraction Layer. When using this, you need a wrapper library (see ).
![](https://wiki.eeros.org/_media/getting_started/roshal.png?w=400&h=350&tok=9b4948)
setup.bash
script of ROS.
The same applies for building the EEROS library with ROS support and for building an EEROS application with ROS support. ![IMPORTANT](https://wiki.eeros.org/lib/images/smileys/important.png)
kdevelop
or Qt Creator
is used, the IDE has to be started from a terminal after the setup.bash
script has run.
The CMAKE file for the EEROS application using ROS has to be expanded as follows:
<code>
cmake_minimum_required(VERSION 2.8)
project(testProject)
## ROS
message(STATUS “looking for package 'ROS'”)
find_package( roslib REQUIRED )
if (roslib_FOUND)
message( STATUS “→ ROS found”)
add_definitions(-DROS_FOUND)
include_directories( “${roslib_INCLUDE_DIRS}” )
message( STATUS “roslib_INCLUDE_DIRS: ” ${roslib_INCLUDE_DIRS} )
list(APPEND ROS_LIBRARIES “${roslib_LIBRARIES}”)
find_package( rosconsole REQUIRED)
list(APPEND ROS_LIBRARIES “${rosconsole_LIBRARIES}”)
find_package( roscpp REQUIRED )
list(APPEND ROS_LIBRARIES “${roscpp_LIBRARIES}”)
else()
message( STATUS “→ ROS NOT found”)
endif()
find_package(EEROS REQUIRED)
include_directories(${EEROS_INCLUDE_DIR};${EEROS_LIBUCL_INCLUDE_DIR})
link_directories(${EEROS_LIB_DIR};${EEROS_LIBUCL_LINK_DIR})
set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++11”)
add_executable(testProject main.cpp)
target_link_libraries(testProject eeros ucl ${CMAKE_DL_LIBS} ${ROS_LIBRARIES})
</code>
===== Make your EEROS Application a ROS Node =====
Initialize the ROS node in your main function and give it a name.
<code cpp>
#include <ros/ros.h>
int main(int argc, char **argv) {
…
rosTools::initNode(“rosTest”);
log.trace() « “ROS node initialized.”;
…
</code>
All ROS tools such as rqt
will list your EEROS application under this name. If you want to register a signal handler, e.g. for shutting down a system (see Shutting down a System Properly), you have to register it after the ROS node is initialized. The ROS node will properly shut down as soon as the last node handler is destroyed when going out of scope. ===== Running your Application ===== An EEROS application using ROS needs to be started with super user privileges. Further, ROS needs some system variables, like
ROS_MASTER_URI
, which are defined by the setup.bash
script of ROS.
To forward these variables to the super user process, the option -E has to be used.
<code>
$ sudo -E ./application
</code>