preface

Believe that a lot of robots do the human-computer interaction interface development related personnel will contact or use Qt, exist on the wiki of ros qt_ros use plan, but most of them are interface is given priority to with the UI files, but sometimes it doesn’t meet our requirements, we need to develop more cool interface, or add some animation effects, At this point we can use the use of QML for mixed development, next we will introduce you to the development of human interface in Qt using QML to render the interface in order to make more graphics effects.

Procedure: 1. Create a qT_ROS package.

Add Qt5::QuickWidgets to set() add Qt5::QuickWidgets to set() To solve the problem, run the sudo apt-get install qtxxxxxxx-dev command.

3, create a QML file, and add it to the resource file, and then write the QML file.

4. Select the QQuickWidget in the UI design to add a QML file to the property, or use the setSource function to add it.

Module “Qtxxxxxx” is not installed 解决 : sudo apt-get install qml-module-qtxxxxxx

6. Then compile again to see that the QML file is implemented in the spatial QQuickWidget.

7. C++ interacts with QML in this case, it is possible to interact using the signal-and-slot method. First, add the header file to the C++ file

#include #include QObject *root = ui->quickWidget->rootObject(); QObject::connect(this,SIGNAL(set(double,double)),root,SIGNAL(test(double,double))); QObject::connect(root,SIGNAL(clickedMap(double,double)),this,SLOT(onMap(double,double))); xx.qml

signal test(double value1,double value2); signal clickedMap(double value1,double value2); onTest:{ }

ClickedMap (double Value1,double) is used in a CPP file to trigger the test signal and call onTest:{} in QML Value2) also calls the slot function bound in the CPP file.

The interaction is complete.

Case demonstration: REALIZED a cacheable offline map with QML, and then moved the UAV icon on the map through the real-time longitude and latitude of the UAV, marked the route, and changed the yaw Angle of the UAV icon on the map according to the change of yaw Angle. Original video demo: mp.weixin.qq.com/s?__biz=MzI…

Since there is no GPS signal in the room, latitude and longitude information is released through RQT, so that there is a movement with animation effect. Then, the uav releases the corresponding yaw Angle by rotating the UAV, and then moves the yaw Angle accordingly on the UAV icon on the map.

  • End –

With the rapid development of technology, AMu Lab will keep up with the pace of technology and constantly recommend the latest technology and hardware in the robot industry to everyone. The greatest value of our training is to see our trainees make rapid progress in technology. If you are in the robotics industry, please follow our official account, we will continue to publish the most valuable information and technology in the robotics industry.

Amu Lab is committed to cutting-edge IT technology education and intelligent equipment, so that robot research and development more efficient!