1r0b1n0 / libros2qt

A library used to merge the event loops of ros2 and qt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

librosqt

This is a simple library that merges the event loop of ROS2 and Qt. This is done by providing a custom executor.

Usage

In your main.cpp init the node in the following way :

#include <QCoreApplication>
#include <rclcpp/rclcpp.hpp>
#include <lib_ros2_qt/qt_executor.h>

using namespace rclcpp;
int main(int argc, char* argv[]) {
    QCoreApplication a(argc, argv);
    rclcpp::init(argc, argv);

    auto server = std::make_shared<TestNode>();

    QtExecutor executor;
    executor.add_node(server);

    executor.start();

    auto res = a.exec();    
    rclcpp::shutdown();
    return res;
}

Examples

Motivations

The Qt library can be useful for ROS nodes when developping GUI applications, or even in headless nodes using network communications (tcp/ip, modbus, canbus, bluetooth ...).

Both Qt and ROS2 need to have their own event loop spinning : rclcpp::executors::SingleThreadedExecutor::spin() for ROS, QCoreApplication::exec() for Qt.

License

MIT

About

A library used to merge the event loops of ros2 and qt


Languages

Language:C++ 61.0%Language:CMake 39.0%