getting_started:ros
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
getting_started:ros [2017/11/20 16:43] – [Using ROS through EEROS HAL] graf | getting_started:ros [2023/02/09 10:10] – [Interfacing with ROS] ursgraf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Interfacing with ROS ====== | ====== Interfacing with ROS ====== | ||
- | [[http:// | + | [[http:// |
+ | |||
+ | * [[getting_started: | ||
+ | * [[getting_started: | ||
+ | * [[getting_started: | ||
+ | |||
+ | 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 14: | ||
===== Using ROS through EEROS HAL ===== | ===== Using ROS through EEROS HAL ===== | ||
- | EEROS can communicate with the underlying hardware through its [[eeros_architecture: | + | EEROS can communicate with the underlying hardware through its [[eeros_architecture: |
- | [{{ : | + | [{{ : |
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:// | + | If you want to test your application with a [[http:// |
- | To use your application with hardware, you can, for example, | + | It is also possible to use ROS-topics alongside real hardware. You could determine a motor position by reading |
- | If you adapt the *.json | + | |
- | 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 '' | + | |
- | 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 '' | + | |
- | 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 '' | + | |
- | + | ||
- | The CMAKE file for the EEROS application using ROS has to be expanded as follows: | + | |
- | < | + | |
- | cmake_minimum_required(VERSION 2.8) | + | |
- | project(testProject) | + | |
- | + | ||
- | ## 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}; | + | |
- | + | ||
- | set(CMAKE_CXX_FLAGS " | + | |
- | + | ||
- | 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 < | ||
- | | ||
- | int main(int argc, char **argv) { | ||
- | ... | ||
- | rosTools:: | ||
- | log.trace() << "ROS node initialized."; | ||
- | ... | ||
- | </ | ||
- | 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.txt · Last modified: 2023/02/09 12:04 by ursgraf