From f3acf21c6a15fe5fbe2d685112ca68a407dbb524 Mon Sep 17 00:00:00 2001 From: Alex Davies Date: Thu, 19 Sep 2024 14:14:07 -0300 Subject: [PATCH] Added gui runner for tools like rqt and ignition --- README.md | 2 +- docker-compose.yml | 39 +++++++++++++++++++++++++++++++++++++++ guiTools/Dockerfile | 10 ++++++++++ guiTools/launcher.py | 30 ++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 guiTools/Dockerfile create mode 100644 guiTools/launcher.py diff --git a/README.md b/README.md index 216a121..b082e4d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ is the drone simulation component, which is the core of the SDK. Spiri Robots run a number of docker containers to achieve their core functionality, we try to keep these essential docker containers in one docker compose file. The -docker compose file you'll find in this repository start an ardupilot-based UAV simulation +docker compose file you'll find in this repository starts an ardupilot-based UAV simulation as well as a ROS master, and mavproxy to tie it together. To get started you can simply clone this repository and run `docker compose --profile uav-sim`. diff --git a/docker-compose.yml b/docker-compose.yml index f4dd788..9e35eb8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,45 @@ version: '3.8' services: + + gui-tools: + build: + context: ./guiTools/ + + environment: + # Display settings + - DISPLAY=${DISPLAY} + - WAYLAND_DISPLAY=${WAYLAND_DISPLAY} + # - QT_QPA_PLATFORM=${QT_QPA_PLATFORM:-xcb} # Default to X11 + # If running with Wayland + - XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} + - ROS_MASTER_URI=http://ros-master:11311 + volumes: + # X11 socket + - /tmp/.X11-unix:/tmp/.X11-unix + # Wayland socket + - ${XDG_RUNTIME_DIR}/wayland-0:${XDG_RUNTIME_DIR}/wayland-0 + # Allow access to the host's GPU + - /dev/dri:/dev/dri + devices: + # Provide access to GPU devices + - /dev/dri:/dev/dri + # network_mode: host + ipc: host + user: "${UID}:${GID}" + privileged: true # Allow privileged access if necessary (e.g., for GPU access) + # restart: unless-stopped + # command: /bin/bash -c "source /opt/ros/foxy/setup.bash && rvis2" # Replace with the actual command to run Gazebo Ignition + profiles: [ui,] + deploy: + resources: + reservations: + devices: + - driver: cdi + device_ids: + - nvidia.com/gpu=all + + ardupilot: image: git.spirirobotics.com/spiri/ardupilot:spiri-master command: > diff --git a/guiTools/Dockerfile b/guiTools/Dockerfile new file mode 100644 index 0000000..f8ed848 --- /dev/null +++ b/guiTools/Dockerfile @@ -0,0 +1,10 @@ +FROM osrf/ros:jazzy-desktop-full + +RUN apt-get update +RUN apt-get install qterminal -y + +COPY ./launcher.py /launcher.py +CMD python3 /launcher.py + + + diff --git a/guiTools/launcher.py b/guiTools/launcher.py new file mode 100644 index 0000000..e00047f --- /dev/null +++ b/guiTools/launcher.py @@ -0,0 +1,30 @@ +import tkinter as tk +import subprocess + +# Dictionary of applications: key is the button text, value is the command to execute +applications = { + "Launch rqt": ["rqt"], + "Launch rviz2": ["rviz2"], + "Launch Terminal": ['qterminal'], + # Add more applications here if needed +} + +# Function to launch an application +def launch_app(command): + try: + subprocess.Popen(command) + except FileNotFoundError: + print(f"{command[0]} not found. Make sure it's installed and accessible in the PATH.") + +# Create the main application window +root = tk.Tk() +root.title("Spiri SDK Launcher") + +# Create and place buttons dynamically based on the dictionary +for app_name, command in applications.items(): + button = tk.Button(root, text=app_name, command=lambda cmd=command: launch_app(cmd), width=20, height=2) + button.pack() + +# Run the Tkinter main loop +root.mainloop() +