Added gui runner for tools like rqt and ignition

This commit is contained in:
Alex Davies 2024-09-19 14:14:07 -03:00
parent 2970f78476
commit f3acf21c6a
4 changed files with 80 additions and 1 deletions

View File

@ -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`.

View File

@ -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: >

10
guiTools/Dockerfile Normal file
View File

@ -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

30
guiTools/launcher.py Normal file
View File

@ -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()