Moved robot config to own folder structure

This commit is contained in:
Alex Davies 2024-11-07 12:18:53 -04:00
parent 4ae96ff8b9
commit 1a409a063a
5 changed files with 123 additions and 108 deletions

View File

@ -28,7 +28,8 @@ services:
#Auto reload on code changes #Auto reload on code changes
- ./guiTools/spiri_sdk_guitools/:/app/spiri_sdk_guitools/ - ./guiTools/spiri_sdk_guitools/:/app/spiri_sdk_guitools/
# Enable launching the SDK from the SDK # Enable launching the SDK from the SDK
- ./:/app/sdk # - ./:/app/sdk
- ./robots:/robots
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
devices: devices:
# Provide access to GPU devices # Provide access to GPU devices
@ -41,7 +42,6 @@ services:
privileged: true # Allow privileged access if necessary (e.g., for GPU access) privileged: true # Allow privileged access if necessary (e.g., for GPU access)
# restart: unless-stopped # restart: unless-stopped
# command: /bin/bash -c "source /opt/ros/foxy/setup.bash && rvis2" # Replace with the actual command to run Gazebo Ignition # command: /bin/bash -c "source /opt/ros/foxy/setup.bash && rvis2" # Replace with the actual command to run Gazebo Ignition
profiles: [ui]
deploy: deploy:
resources: resources:
reservations: reservations:
@ -50,102 +50,3 @@ services:
device_ids: device_ids:
- nvidia.com/gpu=all - nvidia.com/gpu=all
ardupilot:
env_file:
- .env
image: git.spirirobotics.com/spiri/ardupilot:spiri-master
command:
- /bin/bash
- -c
- |
./Tools/autotest/sim_vehicle.py $ARDUPILOT_VEHICLE --no-rebuild \
--no-mavproxy --enable-dds --sysid $DRONE_SYS_ID -I$INSTANCE
profiles:
- uav-sim
stdin_open: true
tty: true
network_mode: host
mavproxy:
env_file:
- .env
image: git.spirirobotics.com/spiri/services-mavproxy:main
command: >
mavproxy.py --non-interactive
--master tcp:127.0.0.1:$SERIAL0_PORT
--out udpout:0.0.0.0:$MAVROS2_PORT
--out udpout:0.0.0.0:$MAVROS1_PORT
--sitl 127.0.0.1:$SITL_PORT
--out udp:0.0.0.0:$GCS_PORT
profiles:
- uav-sim
ipc: host
network_mode: host
restart: always
mavros2:
env_file:
- .env
image: git.spirirobotics.com/spiri/services-ros2-mavros:main
command: ros2 launch mavros apm.launch fcu_url:="udp://0.0.0.0:$MAVROS2_PORT@:14555" namespace:="spiri$DRONE_SYS_ID" tgt_system:="$DRONE_SYS_ID"
profiles:
- uav-sim
ipc: host
network_mode: host
restart: always
depends_on:
ardupilot:
condition: service_started
mavproxy:
condition: service_started
deploy:
resources:
limits:
# cpus: '0.01'
memory: 200M
ulimits:
nofile:
soft: 1024
hard: 524288
mavros:
#This service bridges our mavlink-based robot-coprosessor into ROS
#In this example it connects to a simulated coprocessor.
env_file:
- .env
image: git.spirirobotics.com/spiri/services-ros1-mavros:master
command: rosrun mavros mavros_node __name:=spiri$DRONE_SYS_ID _fcu_url:="udp://0.0.0.0:$MAVROS1_PORT@:14559" _target_system_id:="$DRONE_SYS_ID"
profiles:
- uav-sim
ipc: host
network_mode: host
restart: always
deploy:
resources:
limits:
# cpus: '0.01'
memory: 200M
ulimits:
nofile:
soft: 1024
hard: 524288
ros-master:
env_file:
- .env
image: git.spirirobotics.com/spiri/services-ros1-core:main
command: stdbuf -o L roscore
profiles:
- ros-master
ipc: host
network_mode: host
restart: always
deploy:
resources:
limits:
memory: 1G
# Madness, setting a low ulimit here fixes memory leaks
# https://answers.ros.org/question/336963/rosout-high-memory-usage/
ulimits:
nofile:
soft: 1024
hard: 524288

View File

@ -46,7 +46,7 @@ async def main():
with ui.tab_panel(tab_robots): with ui.tab_panel(tab_robots):
new_robot_widget = ui.element().classes("w-1/2") new_robot_widget = ui.element().classes("w-1/2")
with ui.element().classes("w-1/2"): with ui.element().classes("w-1/2"):
ui.label("Debug") ui.label("Debug").classes("text-xl")
def cleanup_all_containers(): def cleanup_all_containers():
#Find all containers that start with spiri-sdk #Find all containers that start with spiri-sdk
containers = docker_client.containers.list(all=True) containers = docker_client.containers.list(all=True)
@ -59,16 +59,16 @@ async def main():
ui.button("Cleanup all containers", on_click=cleanup_all_containers) ui.button("Cleanup all containers", on_click=cleanup_all_containers)
ui.separator() ui.separator()
ui.label("Current robots") ui.label("Current robots").classes("text-3xl")
robots_widget = ui.element().classes("w-full") robots_widget = ui.element().classes("w-full")
#Add a new robot #Add a new robot
with new_robot_widget: with new_robot_widget:
ui.label("Add new robot") ui.label("Add new robot").classes("text-3xl")
newRobotParams = defaultdict(binding.BindableProperty) newRobotParams = defaultdict(binding.BindableProperty)
ui.number(value=1, label="SysID", min=1, max=254, ui.number(value=1, label="SysID", min=1, max=254,
).bind_value(newRobotParams, 'sysid') ).bind_value(newRobotParams, 'sysid')
ui.textarea(value="./sdk/docker-compose.yml", label="Compose files (comma or newline seperated)").bind_value(newRobotParams, 'compose_files') ui.textarea(value="/robots/spiri-mu/core/docker-compose.yaml", label="Compose files (comma or newline seperated)").bind_value(newRobotParams, 'compose_files')
async def new_robot(): async def new_robot():
robot = Robot(**newRobotParams) robot = Robot(**newRobotParams)
asyncio.tasks.create_task(robot.ui(robots_widget)) asyncio.tasks.create_task(robot.ui(robots_widget))

View File

@ -82,8 +82,8 @@ class Robot:
if container not in docker_elements: if container not in docker_elements:
docker_elements[container] = ui.element().classes("w-full") docker_elements[container] = ui.element().classes("w-full")
with docker_elements[container]: with docker_elements[container]:
ui.label().bind_text(container_status, container) ui.label().bind_text(container_status, container).classes("text-lg")
logelement = ui.expansion("Logs").style('margin: 10px;').classes('w-full') logelement = ui.expansion("Logs").style('margin: 10px;').classes('w-full outline outline-1')
asyncio.create_task(container_logs(container, logelement)) asyncio.create_task(container_logs(container, logelement))
#Check for containers that have been removed #Check for containers that have been removed
removed = set(docker_elements.keys()) - set(self.containers()) removed = set(docker_elements.keys()) - set(self.containers())
@ -98,7 +98,7 @@ class Robot:
with element: with element:
self.robot_ui = ui.element().classes("w-full outline p-4") self.robot_ui = ui.element().classes("w-full outline p-4")
with self.robot_ui: with self.robot_ui:
ui.label(f"{self.robot_type}") ui.label(f"{self.robot_type} {self.sysid}").classes("text-2xl")
ui.label(f"""Sysid: {self.sysid}""") ui.label(f"""Sysid: {self.sysid}""")
ui.button("Start", on_click=self.start).classes("m-2") ui.button("Start", on_click=self.start).classes("m-2")
ui.button("Stop", on_click=self.async_stop).classes("m-2") ui.button("Stop", on_click=self.async_stop).classes("m-2")

19
robots/spiri-mu/core/.env Normal file
View File

@ -0,0 +1,19 @@
DRONE_SYS_ID=1
INSTANCE=0
SERIAL0_PORT=5760
SITL_PORT=5501
MAVROS2_PORT=14560
MAVROS1_PORT=14561
FDM_PORT_IN=9002
GSTREAMER_UDP_PORT=5600
ROS_MASTER_URI="http://0.0.0.0:11311"
ARDUPILOT_VEHICLE="-v copter -f gazebo-mu --model=JSON -L CitadelHill"
WORLD_FILE_NAME="citadel_hill_world.sdf"
WORLD_NAME="citadel_hill"
DRONE_MODEL="spiri_mu"
SIM_DRONE_COUNT=1
GCS_PORT=14550

View File

@ -0,0 +1,95 @@
services:
ardupilot:
env_file:
- .env
image: git.spirirobotics.com/spiri/ardupilot:spiri-master
command:
- /bin/bash
- -c
- |
./Tools/autotest/sim_vehicle.py $ARDUPILOT_VEHICLE --no-rebuild \
--no-mavproxy --enable-dds --sysid $DRONE_SYS_ID -I$INSTANCE
stdin_open: true
tty: true
network_mode: host
mavproxy:
env_file:
- .env
image: git.spirirobotics.com/spiri/services-mavproxy:main
command: >
mavproxy.py --non-interactive
--master tcp:127.0.0.1:$SERIAL0_PORT
--out udpout:0.0.0.0:$MAVROS2_PORT
--out udpout:0.0.0.0:$MAVROS1_PORT
--sitl 127.0.0.1:$SITL_PORT
--out udp:0.0.0.0:$GCS_PORT
ipc: host
network_mode: host
restart: always
mavros2:
env_file:
- .env
image: git.spirirobotics.com/spiri/services-ros2-mavros:main
command: ros2 launch mavros apm.launch fcu_url:="udp://0.0.0.0:$MAVROS2_PORT@:14555" namespace:="spiri$DRONE_SYS_ID" tgt_system:="$DRONE_SYS_ID"
ipc: host
network_mode: host
restart: always
depends_on:
ardupilot:
condition: service_started
mavproxy:
condition: service_started
deploy:
resources:
limits:
# cpus: '0.01'
memory: 200M
ulimits:
nofile:
soft: 1024
hard: 524288
mavros:
#This service bridges our mavlink-based robot-coprosessor into ROS
#In this example it connects to a simulated coprocessor.
env_file:
- .env
image: git.spirirobotics.com/spiri/services-ros1-mavros:master
command: rosrun mavros mavros_node __name:=spiri$DRONE_SYS_ID _fcu_url:="udp://0.0.0.0:$MAVROS1_PORT@:14559" _target_system_id:="$DRONE_SYS_ID"
profiles:
- ros1
ipc: host
network_mode: host
restart: always
deploy:
resources:
limits:
# cpus: '0.01'
memory: 200M
ulimits:
nofile:
soft: 1024
hard: 524288
ros-master:
env_file:
- .env
image: git.spirirobotics.com/spiri/services-ros1-core:main
command: stdbuf -o L roscore
profiles:
- ros1-master
ipc: host
network_mode: host
restart: always
deploy:
resources:
limits:
memory: 1G
# Madness, setting a low ulimit here fixes memory leaks
# https://answers.ros.org/question/336963/rosout-high-memory-usage/
ulimits:
nofile:
soft: 1024
hard: 524288