getting_started:ros
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
getting_started:ros [2017/11/20 17:28] – [Using ROS through EEROS HAL] graf | getting_started:ros [2021/03/29 15:27] – ursgraf | ||
---|---|---|---|
Line 8: | Line 8: | ||
===== 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:// |
- | If you adapt the *.json | + | It is also possible to use ROS-topics alongside real hardware. You could determine a motor position by reading |
- | 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 ===== | ===== Preparations and Building ===== | ||
ROS needs to be installed on the developer machine as well as on the target machine. | 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 '' | + | 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. \\ | 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 '' | 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: | The CMAKE file for the EEROS application using ROS has to be expanded as follows: | ||
< | < | ||
- | cmake_minimum_required(VERSION | + | cmake_minimum_required(VERSION |
project(testProject) | project(testProject) | ||
+ | set(CMAKE_CXX_STANDARD 14) | ||
+ | |||
## ROS | ## ROS | ||
message(STATUS " | message(STATUS " | ||
Line 50: | Line 61: | ||
include_directories(${EEROS_INCLUDE_DIR}; | include_directories(${EEROS_INCLUDE_DIR}; | ||
link_directories(${EEROS_LIB_DIR}; | link_directories(${EEROS_LIB_DIR}; | ||
- | |||
- | set(CMAKE_CXX_FLAGS " | ||
add_executable(testProject main.cpp) | add_executable(testProject main.cpp) | ||
Line 57: | Line 66: | ||
</ | </ | ||
- | ===== Make your EEROS Application a ROS Node ===== | + | Your test program might look like |
- | Initialize the ROS node in your main function and give it a name. | + | |
<code cpp> | <code cpp> | ||
- | | + | #include < |
| | ||
- | | + | int main(int argc, char **argv) { |
- | ... | + | ... |
- | rosTools:: | + | rosTools:: |
+ | ros:: | ||
log.trace() << "ROS node initialized."; | log.trace() << "ROS node initialized."; | ||
... | ... |
getting_started/ros.txt · Last modified: 2023/02/09 12:04 by ursgraf