A simple ROS 2 node which cyclically reads the CPU usage from the ctrlX Data Layer by reading the address framework/metrics/system/cpu-utilisation-percent
and pushes on the ROS2 topic ros2_simple_talker_cpp
.
In the ctrlX Data Layer you can find any kind of information about the device, process, fieldbus and periphery.
Please note, that this is a very basic example which uses the simplest method of reading in the ctrlX Data Layer. For improved performance and scalability you should consider creating a subscription instead of performing synchronuous (blocking) reads.
ros-base
snap. The base snap which provides the ROS 2 runtime binaries. Has to be installed on ctrlX OS. See ROS 2 Humble Base Snap.- An Ubuntu based build environment to build an app. See ctrlX Automation SDK.
This project is based on the official ROS 2 Tutorial: Writing a simple publisher and subscriber (C++).
Building a snap has two steps:
- Colcon build:
CMakeLists.txt
defines how compile and link the C++ sources. - snap build:
snap/snapcraft.yaml
defines how the compiled binaries are packed into the snap and how they are called on ctrlX OS.
The colcon build tool is configured by CMakeLists.txt
.
This section defines the ROS 2 packages needed:
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
And here the executables and their dependencies are defined:
add_executable(listener src/subscriber_member_function.cpp)
ament_target_dependencies(listener rclcpp std_msgs)
snap/snapcraft.yaml
defines how the snap will be build:
install/
is dumped into the snap- also
wrapper/
- Two apps (talker and listener) are copied into the snap and started as services
- The snap - respectively the executables - uses the content interface of the
ros-base
snap (here the ROS 2 runtime is provided).
Start this script:
./build-snap-amd64.sh
SPDX-FileCopyrightText: Copyright (c) 2023 Bosch Rexroth AG
https://www.boschrexroth.com/en/dc/imprint/
SPDX-License-Identifier: Apache-2.0