Simplifying ROS2 Launch Files with a PyQt GUI for TurtleBot3 and Nav2

Introduction

Running a robotics demo with ROS2 can quickly become overwhelming. Multiple terminals, repeated source commands, and long ros2 launch strings are not friendly for live presentations or non-technical users.

This is where a ROS2 GUI launch system comes in. By wrapping launch files and nodes inside a graphical user interface (GUI), you can eliminate complexity and reduce errors. In this blog, we’ll explore how to use PyQt to build a custom ROS2 GUI launch for TurtleBot3 simulations and Nav2 navigation, making your robotics projects simpler, more reliable, and client-ready.

Why a GUI for ROS2 Launch Files Matters

When you ship a robotics project as software to clients, usability becomes as important as performance. Many users do not have a deep understanding of Linux, ROS2 commands, or terminal workflows.

Instead of asking them to:

  • Open multiple terminals
  • Run several ros2 launch commands
  • Manage process interruptions manually

you can give them a single GUI with buttons like “Launch Gazebo” or “Start Navigation.”

This improves:

  • Accessibility — non-technical users can run demos.
  • Efficiency — no repetitive typing.
  • Reliability — prevents missing steps that could crash the robot system.

For example, the TurtleBot3 demo typically requires commands like:

ros2 launch turtlebot3_gazebo empty_world.launch.py
ros2 launch turtlebot3_navigation2 navigation2.launch.py

Through PyQt, these can be executed by clicking a single button. For context, the ROS 2 launch file tutorial explains the role of launch files in detail.

Setting Up TurtleBot3 Simulation

Before creating the GUI, ensure that you have the required packages installed for TurtleBot3 simulation:

sudo apt install ros-humble-turtlebot3*

Next, export the model environment variable:

export TURTLEBOT3_MODEL=waffle

You can verify the setup by launching Gazebo:

ros2 launch turtlebot3_gazebo empty_world.launch.py

This brings up the TurtleBot3 simulation environment in Gazebo. If you’re new to Gazebo, the Gazebo Sim official docs provide a helpful overview of its physics engine and visualization tools.

Creating a Simple PyQt GUI

The GUI begins with a basic PyQt window and push buttons to control actions such as launching Gazebo, running a circular motion node, or starting navigation.

Example:

import sys
import subprocess
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton

commands = {
    "gazebo": "ros2 launch turtlebot3_gazebo empty_world.launch.py",
    "circular": "ros2 run turtlebot3_motion circular",
    "forward": "ros2 run turtlebot3_motion forward_backward",
    "square": "ros2 run turtlebot3_motion square"
}

processes = {}

def run_command(name):
    if name not in processes:
        processes[name] = subprocess.Popen(commands[name], shell=True)

def stop_command(name):
    if name in processes:
        processes[name].terminate()
        processes.pop(name)

app = QApplication(sys.argv)
window = QWidget()
layout = QVBoxLayout()

for cmd in commands.keys():
    button = QPushButton(f"Launch {cmd}")
    button.clicked.connect(lambda _, c=cmd: run_command(c))
    layout.addWidget(button)

stop_button = QPushButton("Stop All")
stop_button.clicked.connect(lambda: [stop_command(c) for c in list(processes.keys())])
layout.addWidget(stop_button)

window.setLayout(layout)
window.show()
sys.exit(app.exec_())

This example creates a GUI with four buttons for launching processes and one button to stop all running nodes. For more on how PyQt widgets work, the PyQt5 documentation offers deeper guidance.

Handling Process Management in ROS2

A major challenge is process control. If you repeatedly click a button, multiple instances of the same node may run in the background. To handle this, the GUI uses:

  • Process dictionary — track which nodes are active.
  • Stop functions — send termination signals (SIGINT) or force kill (SIGKILL) if needed.

This ensures Gazebo and all nodes can be stopped cleanly with a single click.

Extending the GUI for Navigation (Nav2)

Autonomous navigation requires several launch files:

  • Map server
  • AMCL localization
  • Costmaps
  • Nav2 controller and planner

Normally, this involves multiple ros2 launch commands, but with the GUI you can integrate them into one button click.

For example:

commands = {

    "gazebo_nav2": "ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py",

    "nav2": "ros2 launch turtlebot3_navigation2 navigation2.launch.py"
}

The GUI can also store waypoints by subscribing to AMCL pose estimates. These saved poses can be replayed later for demonstrations, reducing manual rework. If you’d like to see how AMCL and Nav2 fit together, Navigation2 official docs are an excellent resource.

Chart: Terminal vs GUI Workflow

To highlight the usability advantage, here’s a simple comparison:

TaskTerminal WorkflowGUI Workflow
Launch GazeboOpen terminal, run ros2 launch …Click Launch Gazebo
Start circular motion nodeOpen another terminal, source, run ros2 run …Click Circular Motion
Stop all nodesManually kill processes or close terminalsClick Stop All Nodes
Save waypoints in Nav2Write Python scripts or YAML filesClick Save Pose
Run navigation goalsLaunch Nav2 stack and set goals manually in RVizClick Start Navigation

This makes it clear why a GUI is more client-friendly.


Beyond PyQt: Other Options

While PyQt is a great choice for Python-based projects, you can also explore:

  • Foxglove Studio — a visualization and debugging tool with GUI features.
  • Qt (C++) — a native option for performance-critical applications.
  • rclnodejs (JavaScript) — for building web-based GUIs.

Each option has trade-offs in terms of language, ecosystem, and deployment.

Best Practices for GUI-based ROS2 Projects

  1. Avoid Multiple Click Issues — prevent duplicate process launches.
  2. Provide Clear Stop Functions — ensure nodes and Gazebo close gracefully.
  3. Keep Navigation Controls Intuitive — expose only essential buttons to non-technical users.
  4. Test on Client Machines — remember that many clients may not have Linux familiarity.
  5. Document the Workflow — provide a short user guide for your GUI.

Conclusion

Using a ROS2 GUI launch system with PyQt transforms the robotics workflow from terminal-heavy commands into intuitive button clicks. Whether it’s TurtleBot3 simulation or Nav2 navigation, GUIs improve usability, reduce setup time, and simplify client demos.

Instead of worrying about missed commands or terminal clutter, your users can focus on the robot’s behavior and performance. This is not just convenience it’s essential for making robotics projects practical and professional.

At Robotisim, we’re also providing structured learning paths for robotics, helping you build the skills and confidence to implement solutions like ROS2 GUIs effectively.

If you are working on a robotics project, consider adding a ROS2 launch files GUI. It will save time, prevent errors, and make your software much more accessible.

FAQs

1. Why use a PyQt GUI instead of terminal commands?
It saves time, reduces errors, and is easier for non-technical users.

2. Can this work on real TurtleBot3 hardware?
Yes, just configure the robot’s network and install the same ROS2 packages.

3. How to handle crashes or frozen nodes?
Add error handling or use QProcess to monitor and restart processes.

4. Can I launch multi-robot systems with this GUI?
Yes, extend the GUI with grouped buttons or tabs for each robot.

5. Are there alternatives to PyQt for ROS2 GUIs?
Yes, Foxglove Studio, Qt (C++), or rclnodejs/web dashboards.

Leave a Comment

Your email address will not be published. Required fields are marked *

Review Your Cart
0
Add Coupon Code
Subtotal

 
Scroll to Top