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
Last revisionBoth sides next revision
getting_started:ros [2019/06/11 11:51] – [Preparations and Building] grafgetting_started:ros [2023/02/09 10:10] – [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_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 15: Line 21:
 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]]. 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]].
  
-===== 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. This can be done with  
-<code> 
-source /path_to_ros_installation/setup.bash 
-</code> 
- 
-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. 
- 
-=== 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:\\ 
-''cmake -DCMAKE_INSTALL_PREFIX="$install_dir" -DUSE_ROS=TRUE ..'' 
- 
- 
-=== Building an EEROS application with ROS functionality === 
- 
-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.txt · Last modified: 2023/02/09 12:04 by ursgraf