- Project Overview
- Features
- System Requirements
- Installation Guide
- Project Setup
- Running the Project
- Project Structure
- Customization and Extension
- FAQ
- Contribution Guidelines
- Version History
- License
- Contact Information
Qt6 ROS Template is a human-machine interaction interface template based on Qt6 for ROS Noetic. This project aims to provide developers with a quick-start framework to facilitate the development of ROS human-machine interaction interfaces. It combines the modern UI design capabilities of Qt6 with the powerful robot development ecosystem of ROS, providing an ideal starting point for graphical interface development for robotic applications.
This project is inspired by the Qt5 version of the ros_qt_demo project. However, compared to the Qt5 version, this project has significant improvements:
- Dual Compilation Support: This template supports both
catkin_make
in the ROS environment and direct compilation in Qt Creator without complicated configuration steps. - Simplified Development Process: Compared to the Qt5 version, which required various configurations to develop in Qt Creator, this project offers an "out-of-the-box" experience, greatly simplifying the development process.
- Enhanced Flexibility: Developers can choose to use either the ROS toolchain or Qt Creator for development, offering greater flexibility.
- Integration of Qt6 and ROS Noetic, providing modern UI design and powerful robot development capabilities
- Dual compilation support: compatible with ROS
catkin_make
and Qt Creator's build system- Can be compiled using
catkin_make
in a ROS-only environment - Can be compiled and opened in Qt Creator in a Qt6-only environment
- Can be compiled using either
catkin_make
or Qt Creator in a ROS and Qt6 environment
- Can be compiled using
- No complex configuration required, can be directly opened in Qt Creator for development
- Pre-configured CMakeLists.txt, simplifying the integration process of Qt and ROS
- Includes basic ROS nodes and Qt main window implementation as a starting point for development
- Provides ROS launch files for easy startup and management of nodes
- Supports compilation and running in both ROS and non-ROS environments, enhancing project flexibility
- Compared to the Qt5 version, the development process is greatly simplified, improving development efficiency
- Operating System: Ubuntu 20.04 LTS
- ROS Version: Noetic
- Qt Version: 6.x
- CMake Version: 3.16 or higher
There are two ways to install ROS Noetic:
- Follow the Official Guide
- Use the Auto ROS Installer (recommended):
For detailed installation instructions, please refer to the Project Homepage.
git clone https://github.com/XKHoshizora/auto-ros-installer.git cd auto-ros-installer
It is recommended to use the official Qt installer to install Qt6:
-
Download the Qt Installer: Visit the Qt Official Download Page and download the online installer for Linux.
-
Grant execution permission:
chmod +x qt-online-installer-linux-<x64/arm64>-<version>.run
-
Run the installer:
./qt-online-installer-linux-<x64/arm64>-<version>.run
-
Configure the Qt Creator shortcut: Use the following command to create and open the
qtcreator
filesudo nano /usr/bin/qtcreator
Add the following content to the
qtcreator
file:#!/bin/sh export QT_HOME=/home/<user>/Qt/Tools/QtCreator/bin $QT_HOME/qtcreator $*
-
Add executable permission to the
qtcreator
file:sudo chmod a+x /usr/bin/
-
Start Qt Creator:
qtcreator
-
Install additional dependencies
If you encounter issues when running Qt Creator, install the following dependencies:
sudo apt install libxcb-xinerama0 libxcb-xinerama0-dev libxcb-cursor0
mkdir -p ~/qt6_ws/src
cd ~/qt6_ws/src
git clone https://github.com/XKHoshizora/qt6_ros_template.git
Execute the following commands in your workspace to compile the package:
cd ~/qt6_ws
catkin_make
- Open Qt Creator
- Select "File" > "Open File or Project"
- Navigate to the
~/qt6_ws/src/qt6_ros_template
directory and select theCMakeLists.txt
file to open - Configure and open the project. If the project files are displayed normally on the left side, it means the compilation is successful. If the compilation fails, only the
CMakeLists.txt
file will be displayed.
-
Execute the following commands in your workspace to compile the package:
cd ~/qt6_ws catkin_make
-
To open the project in Qt Creator for development, first compile it as described above. Then follow these steps:
- Open Qt Creator
- Select "File" > "Open File or Project"
- Navigate to
~/qt6_ws/src
and select theCMakeLists.txt
file (Note: select theCMakeLists.txt
file in the workspace, not the one inside the package) - In the configuration page, click the
Import Build From...
option'sDetails
button. Click theBrowse...
button to find theqt_ws/build
directory and click theOpen
button in the top right corner. Click theImport
button to complete the import. - Check the
Imported Kit
andBuild
options, and uncheck all other options. - Click the
Configure Project
button in the bottom right corner to complete the configuration and start building the project. - If the project files are displayed normally on the left side, it means the compilation is successful. If the compilation fails, only the
CMakeLists.txt
file will be displayed.
First, ensure that the project has been compiled according to the above steps. Then execute the following commands in your workspace:
source ~/qt6_ws/devel/setup.bash
roslaunch qt6_ros_template demo.launch
# If you want to specify different ROS_HOSTNAME or ROS_IP, use this:
roslaunch qt6_ros_template demo.launch ros_hostname:=your_hostname ros_ip:=your_ip
After compiling and opening the project in Qt Creator, click the green Run
button on the left, or use the Ctrl + R
shortcut to run it.
First, ensure that the project has been compiled according to the above steps. Then execute the following commands in your workspace:
source ~/qt6_ws/devel/setup.bash
roslaunch qt6_ros_template demo.launch
# If you want to specify different ROS_HOSTNAME or ROS_IP, use this:
roslaunch qt6_ros_template demo.launch ros_hostname:=your_hostname ros_ip:=your_ip
Or after compiling and opening the project in Qt Creator, click the green Run
button on the left, or use the Ctrl + R
shortcut to run it.
It is recommended to use the rosrun
command for testing. In this case, you need to run the roscore
command to run the ros master
in a new terminal in advance, and then enter the following command in another new terminal to start the ROS node:
rosrun qt6_ros_template qt6_ros_template_node
After the node runs successfully, follow these steps to test the various functions of the application:
-
Connect to ROS
- Click the "Connect" button in the application.
- Verify that the "ROS Status" label turns green and displays "Connected".
-
Change Topic
- Enter a new topic name in the "Change Topic" input box (e.g., "/test_topic").
- Click the "Change Topic" button.
-
Publish Message
- Enter a message in the "Publish" input box.
- Click the "Publish" button.
- Use the following command in a new terminal to verify the published message:
rostopic echo /test_topic
-
Subscribe to Message
- In a new terminal, publish a message to the subscribed topic:
rostopic pub /test_topic std_msgs/String "data: 'Greetings from the command line'" -1
- Verify that the message appears in the application's log view.
- In a new terminal, publish a message to the subscribed topic:
-
Test Disconnect
- Click the "Disconnect" button.
- Verify that the "ROS Status" label turns red and displays "Disconnected".
- Attempt to publish a message and verify that it fails.
-
Test ROS Master Failure
- Connect to ROS using the application.
- In the terminal running roscore, stop it using Ctrl+C.
- Observe the application's log view and console output for disconnection messages.
-
Use Environment Variables
- Check the "Use environment variables" checkbox.
- Verify that the master URL and ROS IP fields are populated from environment variables.
-
Save and Load Settings
- Change some settings in the application.
- Close and reopen the application.
- Verify that the settings are correctly restored.
If you encounter any issues:
- Ensure that
roscore
is running before starting the application. - Check that your ROS environment variables (
ROS_MASTER_URI
andROS_IP
) are set correctly. - If running ROS on multiple machines, verify network connectivity.
- Check the console output and application logs for any error messages.
This project uses a standard CMake build system and follows the directory structure of a Qt project.
qt6_ros_template/
โโโ CMakeLists.txt
โโโ package.xml
โโโ include/
โ โโโ qt6_ros_template/
โ โโโ mainwindow.h
โโโ msg/
โโโ resources/
โ โโโ images/
โ โ โโโ icon.png
โ โโโ resource.qrc
โโโ scripts/
โโโ src/
โ โโโ main.cpp
โ โโโ mainwindow.cpp
โ โโโ qt6_ros_template_node.cpp
โโโ srv/
โโโ ui/
โ โโโ mainwindow.ui
โโโ launch/
โโโ demo.launch
- Modify
src/mainwindow.cpp
andui/mainwindow.ui
to customize the UI. - Add ROS functionality in
src/qt6_ros_template_node.cpp
. - Update
CMakeLists.txt
to include new source files or dependencies.
-
Problem: "Qt6 not found" error during compilation. Solution: Ensure that Qt6 is installed correctly and that CMAKE_PREFIX_PATH includes the Qt6 installation path.
-
Problem: ROS-related functions are undefined. Solution: Ensure you have sourced devel/setup.bash and that all necessary dependencies are included in package.xml.
-
Problem: Unable to find ROS header files in Qt Creator. Solution: Add the ROS include path (usually /opt/ros/noetic/include) in the project settings of Qt Creator.
We welcome and appreciate any form of contribution! If you would like to contribute to the project, please follow these steps:
- Fork this repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Create a new Pull Request
- 0.1.0
- Initial release
- Basic integration of Qt6 and ROS Noetic
- Dual compilation support (ROS environment and Qt Creator)
This project is licensed under the MIT License - see the LICENSE file for details.
Project Maintainer: XKHoshizora - [email protected]
Project Link: https://github.com/XKHoshizora/qt6_ros_template