This project implements a ROS 2 talker, which reads a ctrlX Data Layer value and publishes it as ROS 2 message.
Writing a simple publisher and subscriber (Python) was used as template.
See also:
- Canonical Snapcraft - Deploying robotics applications
- Canonical - How to build a snap using ROS 2 Humble
- The directory structure is according colcon packages.
- In
setup.py
andsetup.cfg
the colcon package is defined. src/talker/talker/main.py
provides the main functionsrc/talker/ros2/datalayer_reader_ros2_publisher.py
reads a ctrlX Data Layer value, creates a ROS 2 message and publishes it under the topicctrlXCpuUtilisationPercent
.src/talker/ctrlx_datalayer/ctrlx_datalayer_helper.py
contains helper functions regarding ctrlX Data Layersnap/snapcraft.yaml
defines which files are packed into the snap.
To build a snap run
./build-snap-amd64.sh
The script contains following build steps:
-
Build the colcon package:
colcon build
-
Clean the snapcraft helper directories:
snapcraft clean --destructive-mode
-
Update helper directories and build the snap:
snapcraft --destructive-mode
Hint: Arm64-cross-build is not supported.
The ros2-base
snap must already be installed.
Install the created snap on ctrlX OS.
It publishes at the ROS 2 topic MinimalPublisher
.
The output can be checked with:
sudo snap logs -f ros2-simple-talker
With following command you can combine the build, installation and test steps - here the target is a ctrlX COREvirtual with port forwarding.
../../../public/scripts/build-upload-log-snap.sh -PF
SPDX-FileCopyrightText: Copyright (c) 2023 Bosch Rexroth AG
https://www.boschrexroth.com/en/dc/imprint/
SPDX-License-Identifier: Apache-2.0