diff --git a/guiTools/spiri_sdk_guitools/sim_drone.py b/guiTools/spiri_sdk_guitools/sim_drone.py index b107d01..4a22d1b 100644 --- a/guiTools/spiri_sdk_guitools/sim_drone.py +++ b/guiTools/spiri_sdk_guitools/sim_drone.py @@ -271,25 +271,18 @@ class Robot: async def async_start(self): return await run.io_bound(self.start) + def extra_env(self): + return {} + def start(self): """Starts the simulated drone with a given sysid, each drone must have it's own unique ID. """ - instance = self.sysid - 1 - sysid = self.sysid - with logger.contextualize(syd_id=sysid): - env = os.environ + with logger.contextualize(drone=str(self)): with modified_environ( - SERIAL0_PORT=str(int(env["SERIAL0_PORT"]) + 10 * instance), - MAVROS2_PORT=str(int(env["MAVROS2_PORT"]) + 10 * instance), - MAVROS1_PORT=str(int(env["MAVROS1_PORT"]) + 10 * instance), - FDM_PORT_IN=str(int(env["FDM_PORT_IN"]) + 10 * instance), - GSTREAMER_UDP_PORT=str(int(env["GSTREAMER_UDP_PORT"]) + 10 * instance), - SITL_PORT=str(int(env["SITL_PORT"]) + 10 * instance), - INSTANCE=str(instance), - DRONE_SYS_ID=str(self.sysid), ROBOT_NAME=self.robot_name, WORLD_NAME="citadel_hill", + **self.extra_env(), ): self.spawn_gz_model() logger.info("Starting drone stack, this may take some time") @@ -329,6 +322,9 @@ class Robot: def delete_gz_model(self): pass + def spawn_gz_model(self): + pass + for file in Path("/robots").glob("**/robot_plugins.py"): logger.info(f"Loading plugin {file}") spec = importlib.util.spec_from_file_location("robot_plugins", file) @@ -368,6 +364,21 @@ class Spirimu(Robot): ui.number(value=1, label="SysID", min=1, max=254, ).bind_value(newRobotParams, 'sysid') + def extra_env(self): + instance = self.sysid - 1 + env = os.environ + return dict( + SERIAL0_PORT=str(int(env["SERIAL0_PORT"]) + 10 * instance), + MAVROS2_PORT=str(int(env["MAVROS2_PORT"]) + 10 * instance), + MAVROS1_PORT=str(int(env["MAVROS1_PORT"]) + 10 * instance), + FDM_PORT_IN=str(int(env["FDM_PORT_IN"]) + 10 * instance), + GSTREAMER_UDP_PORT=str(int(env["GSTREAMER_UDP_PORT"]) + 10 * instance), + SITL_PORT=str(int(env["SITL_PORT"]) + 10 * instance), + INSTANCE=str(instance), + DRONE_SYS_ID=str(self.sysid), + ) + + @logger.catch def spawn_gz_model(self): diff --git a/robots/ARC/example/docker-compose.yaml b/robots/ARC/example/docker-compose.yaml index 383c2c3..5822c61 100644 --- a/robots/ARC/example/docker-compose.yaml +++ b/robots/ARC/example/docker-compose.yaml @@ -1,4 +1,3 @@ services: whoami: image: "traefik/whoami" - container_name: "simple-service"