Quickstart

This library provides convenient access of ROS2 concepts and functionalities in QML.

Installation

Note: Currently, only Linux is supported. Other platforms have not been tested.

From Source

To install qml_ros2_plugin from source, clone the repo. Now, you have two options: You can either install the plugin in your ROS2 overlay which makes the plugin available only if you’ve sourced the overlay in your environment. Alternatively, you can enable the global install, to install it system-wide on linux.

Local Install

cd into your workspace root directory and colcon build. Re-source your ìnstall/setup.bash.

Global install

cd into the repo folder. To install create a build folder, cd into that folder and run cmake -DGLOBAL_INSTALL=ON .. followed by make and sudo make install.

mkdir build && cd build
cmake -DGLOBAL_INSTALL=ON ..
make -j8 # Replace 8 by the number of cpu cores
sudo make install

Usage

To use the plugin import Ros2 in QML.

import Ros2 1.0

Now, you can use the provided components such as Subscription and TfTransform and the Ros2 Singleton to create a Publisher, a ServiceClient, or an ActionClient.

As a simple example, a Subscription can be created as follows:

1Subscription {
2  id: mySubscription
3  topic: "/intval"
4}

For more in-depth examples, check out the Examples section.

Initialization

Before a Subscription can receive messages, a Publisher can publish messages, etc. the node has to be initialized.

1ApplicationWindow {
2  /* ... */
3  Component.onCompleted: {
4    Ros2.init("node_name");
5  }
6}

Shutdown

To make your application quit when ROS shuts down, e.g., because of a Ctrl+C in the console, you can connect to the Shutdown signal:

1ApplicationWindow {
2  Connections {
3    target: Ros2
4    onShutdown: Qt.quit()
5  }
6  /* ... */
7}

For more on that, check out the Ros2 Singleton.