User Tools

Site Tools


getting_started:ros

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
getting_started:ros [2017/11/20 16:43] – [Using ROS through EEROS HAL] grafgetting_started:ros [2023/02/09 12:04] (current) – [Interfacing with ROS] ursgraf
Line 1: Line 1:
 ====== Interfacing with ROS ====== ====== Interfacing with ROS ======
-[[http://www.ros.org/|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.+[[http://www.ros.org/|ROS]] is a flexible framework for writing robot software. It is great collection of tools, libraries, and conventions. EEROS supports the use of ROS1 or ROS2. 
 + 
 +  * [[getting_started:ros_prep|]] 
 +  * [[getting_started:ros_timing|]] 
 +  * [[getting_started:ros_example|]] 
 +  * [[getting_started:ros_run|]] 
 + 
 +You can make use of ROS within EEROS in the following two ways.
  
 ===== Using Publisher and Subscriber Blocks in the Control System ===== ===== Using Publisher and Subscriber Blocks in the Control System =====
Line 8: Line 15:
  
 ===== Using ROS through EEROS HAL ===== ===== Using ROS through EEROS HAL =====
-EEROS can communicate with the underlying hardware through its [[eeros_architecture:hal:start|]]. When using this, you need a wrapper library (see ).  +EEROS can communicate with the underlying hardware through its [[eeros_architecture:hal:start|]]. When using this, you need a special wrapper library (see [[eeros_architecture:hal:hardware_libraries|]]).  
-[{{ :getting_started:roshal.png?400 |//Connect with ROS topics through the HAL//}}]+[{{ :getting_started:roshal.png?350 |//Connect with ROS topics through the HAL//}}]
  
 The EEROS HAL signals can be comprised of digital or analog inputs or outputs. They are specified in a JSON file. \\ The EEROS HAL signals can be comprised of digital or analog inputs or outputs. They are specified in a JSON file. \\
-If you want to test your application with a [[http://gazebosim.org/|Gazebo]] simulation, you can define your inputs and outputs as ROS topics to connect your application with the simulation. For this no hardware is necessary.  +If you want to test your application with a [[http://gazebosim.org/|Gazebo]] simulation, you can define your inputs and outputs as ROS topics to connect your application with the simulation. For this no hardware is necessary. To use your application with hardware, you can use any of the available [[eeros_architecture:hal:hardware_libraries|]]By choosing the proper JSON file, you can easily switch between real hardware and simulation\\ 
-To use your application with hardware, you can, for example, use the wrapper library \textit{comedi-eeros} or \textit{flink-eeros}. +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://wiki.ros.org/rviz|rviz]] (if you have a model of your robot) or you could monitor the values with a ROS tool like [[http://wiki.ros.org/rqt|rqt]].
-If you adapt the *.json file correctlyyour application should now run on hardware with real encoders and motors without any problems+
-It is also possible to use ROS-topics alongside real hardware. +
-You can use \textit{comedi-eeros} to read an encoder and set a control value for a motor. +
-At the same time, you can publish the same values to ROS topics to visualize the state of the robot with \textit{rviz(if you have a model of your robot) or you can monitor the values with a ROS tool like ''\textit{rqt}'' and display them in a graph with \textit{Multiplot} or as numbers with \textit{TopicMonitor}. +
-With \textit{Multiplot} you can also store the values in a text file.  +
- +
-===== 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 ''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 If an integrated development environment such as ''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 [[getting_started:practical_problems:abort|]]), 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> 
  
getting_started/ros.1511192599.txt.gz · Last modified: 2017/11/20 16:43 (external edit)