getting_started:ros
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| getting_started:ros [2021/03/29 15:35] – [Example for Making your EEROS Application a ROS Node] ursgraf | getting_started:ros [2025/03/18 10:42] (current) – [EEROS Messages] ursgraf | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Interfacing with ROS ====== | ====== Interfacing with ROS ====== | ||
| - | [[http:// | + | [[http:// | 
| + | |||
| + | * [[getting_started: | ||
| + | * [[getting_started: | ||
| + | * [[getting_started: | ||
| + | * [[getting_started: | ||
| + | |||
| + | You can make use of ROS within EEROS in the following two ways. | ||
| + | |||
| + | ===== EEROS Messages ===== | ||
| + | EEROS defines its own ROS message types. They correspond to EEROS [[eeros_architecture: | ||
| + | * Analog Signal → **eeros_msgs:: | ||
| + | - timestamp | ||
| + | - array of float64 values | ||
| + | * Digital Signal → **eeros_msgs:: | ||
| + | - timestamp | ||
| + | - array of boole values | ||
| + | These messages are fetched and built when building EEROS with ROS supprt and will be installed into the same directory as EEROS itself. | ||
| ===== Using Publisher and Subscriber Blocks in the Control System ===== | ===== Using Publisher and Subscriber Blocks in the Control System ===== | ||
| Line 15: | Line 32: | ||
| It is also possible to use ROS-topics alongside real hardware. You could determine a motor position by reading an encoder and set a control value for a motor. In parallel, you could publish the same values to ROS topics to visualize the state of the robot with [[http:// | It is also possible to use ROS-topics alongside real hardware. You could determine a motor position by reading an encoder and set a control value for a motor. In parallel, you could publish the same values to ROS topics to visualize the state of the robot with [[http:// | ||
| - | ===== Preparations and Building ===== | ||
| - | ROS needs to be installed on the developer machine as well as on the target machine. | ||
| - | Before a ROS application can be started, you need to run the '' | ||
| - | < | ||
| - | source / | ||
| - | </ | ||
| - | |||
| - | The same applies for building the EEROS library with ROS support and for building an EEROS application with ROS support. \\ | ||
| - | IMPORTANT If an integrated development environment such as '' | ||
| - | |||
| - | === Building the EEROS library with ROS === | ||
| - | If you build the library with cmake, make sure you use the -DUSE_ROS=TRUE switch. | ||
| - | An example of a cmake call could look like this:\\ | ||
| - | '' | ||
| - | Our build scripts already include this switch. | ||
| - | |||
| - | |||
| - | ===== Example for Making your EEROS Application a ROS Node ===== | ||
| - | |||
| - | The CMAKE file for the EEROS application using ROS has to be expanded as follows: | ||
| - | < | ||
| - | cmake_minimum_required(VERSION 3.5.1) | ||
| - | project(testProject) | ||
| - | |||
| - | set(CMAKE_CXX_STANDARD 14) | ||
| - | |||
| - | ## ROS | ||
| - | message(STATUS " | ||
| - | find_package( roslib REQUIRED ) | ||
| - | if (roslib_FOUND) | ||
| - | message( STATUS "-> ROS found" | ||
| - | add_definitions(-DROS_FOUND) | ||
| - | include_directories( " | ||
| - | message( STATUS " | ||
| - | list(APPEND ROS_LIBRARIES " | ||
| - | find_package( rosconsole REQUIRED) | ||
| - | list(APPEND ROS_LIBRARIES " | ||
| - | find_package( roscpp REQUIRED ) | ||
| - | list(APPEND ROS_LIBRARIES " | ||
| - | else() | ||
| - | message( STATUS "-> ROS NOT found" | ||
| - | endif() | ||
| - | |||
| - | find_package(EEROS REQUIRED) | ||
| - | include_directories(${EEROS_INCLUDE_DIR}; | ||
| - | link_directories(${EEROS_LIB_DIR}; | ||
| - | |||
| - | add_executable(testProject main.cpp) | ||
| - | target_link_libraries(testProject eeros ucl ${CMAKE_DL_LIBS} ${ROS_LIBRARIES}) | ||
| - | </ | ||
| - | |||
| - | Your test program might look like | ||
| - | <code cpp> | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - |  | ||
| - | int main(int argc, char **argv) { | ||
| - | ... | ||
| - | eeros:: | ||
| - | ros:: | ||
| - | log.info() << "ROS node initialized."; | ||
| - | signal(SIGINT, | ||
| - | ... | ||
| - | </ | ||
| - | All ROS tools such as '' | ||
| - | If you want to register a signal handler, e.g. for shutting down a system (see [[getting_started: | ||
| - | 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 '' | ||
| - | To forward these variables to the super user process, the option //-E// has to be used. | ||
| - | < | ||
| - | $ sudo -E ./ | ||
| - | </ | ||
getting_started/ros.1617024910.txt.gz · Last modified: 2021/03/29 15:35 by ursgraf
                
                