From d6e9a79cbe0a3c2c703f848c1a9f9bfd106eada0 Mon Sep 17 00:00:00 2001 From: Tamas Nepusz Date: Tue, 12 Dec 2023 14:30:58 +0100 Subject: [PATCH] refactor: do not include yawControl key when rendering show without yaw control --- src/modules/sbstudio/api/base.py | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/modules/sbstudio/api/base.py b/src/modules/sbstudio/api/base.py index 9afdc7c..c3844b9 100644 --- a/src/modules/sbstudio/api/base.py +++ b/src/modules/sbstudio/api/base.py @@ -338,9 +338,6 @@ def export( if lights is None: lights = {name: LightProgram() for name in trajectories.keys()} - if yaw_setpoints is None: - yaw_setpoints = {name: YawSetpointList() for name in trajectories.keys()} - environment = {"type": show_type} if time_markers is None: @@ -349,6 +346,16 @@ def export( # TODO(ntamas): add cameras to environment in the "environment" key # TODO: add music to the "media" key + def format_drone(name: str): + settings = { + "name": name, + "lights": lights[name].as_dict(ndigits=ndigits), + "trajectory": trajectories[name].as_dict(ndigits=ndigits, version=0), + } + if yaw_setpoints is not None: + settings["yawControl"] = yaw_setpoints[name].as_dict(ndigits=ndigits) + return {"type": "generic", "settings": settings} + data = { "input": { "format": "json", @@ -361,19 +368,7 @@ def export( }, "swarm": { "drones": [ - { - "type": "generic", - "settings": { - "name": name, - "lights": lights[name].as_dict(ndigits=ndigits), - "trajectory": trajectories[name].as_dict( - ndigits=ndigits, version=0 - ), - "yawControl": yaw_setpoints[name].as_dict( - ndigits=ndigits - ), - }, - } + format_drone(name) for name in natsorted(trajectories.keys()) ] },