Skip to content

Commit

Permalink
Std and custom bt-studio visualization mode
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarMrZ committed Jul 30, 2024
1 parent ca25d0a commit 8c0dfa1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
18 changes: 18 additions & 0 deletions manager/manager/launcher/launcher_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
"internal_port": 5901,
}
],
"bt_studio": [
{
"type": "module",
"module": "console",
"display": ":1",
"external_port": 1108,
"internal_port": 5901,
},
{
"type": "module",
"width": 1024,
"height": 768,
"module": "gazebo_view",
"display": ":2",
"external_port": 6080,
"internal_port": 5900,
},
],
"gazebo_gra": [
{
"type": "module",
Expand Down
14 changes: 8 additions & 6 deletions manager/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,33 +206,33 @@ def on_launch_world(self, event):
cfg_dict = event.kwargs.get("data", {})
cfg = ConfigurationManager.validate(cfg_dict)
if "zip" in cfg_dict:
LogManager.logger.info("There is a zip in the msg!")
LogManager.logger.info("Launching universe from received zip")
self.prepare_custom_universe(cfg_dict)
else:
LogManager.logger.info("Normal, no zip")
LogManager.logger.info("Launching universe from the RB")

LogManager.logger.info(cfg)
except ValueError as e:
LogManager.logger.error(f"Configuration validation failed: {e}")

self.world_launcher = LauncherWorld(**cfg.model_dump())
LogManager.logger.info(str(self.world_launcher))
self.world_launcher.run()
self.world_launcher.run()
LogManager.logger.info("Launch transition finished")

def prepare_custom_universe(self, cfg_dict):
print("Custom universe")

# Unzip the app
if cfg_dict["zip"].startswith("data:"):
_, _, zip_file = cfg_dict["zip"].partition("base64,")

zip_destination = "/workspace/worlds/" + cfg_dict["name"] + ".zip"
universe_ref = "/workspace/worlds/" + cfg_dict["name"]
zip_destination = universe_ref + ".zip"
with open(zip_destination, "wb") as result:
result.write(base64.b64decode(zip_file))

# Create the folder if it doesn't exist
universe_folder = "/workspace/worlds/" + cfg_dict["name"] + "/"
universe_folder = universe_ref + "/"
if not os.path.exists(universe_folder):
os.makedirs(universe_folder)

Expand All @@ -241,6 +241,7 @@ def prepare_custom_universe(self, cfg_dict):
zip_ref.close()

def on_prepare_visualization(self, event):

LogManager.logger.info("Visualization transition started")

visualization_type = event.kwargs.get("data", {})
Expand All @@ -252,6 +253,7 @@ def on_prepare_visualization(self, event):
if visualization_type == "gazebo_rae":
self.gui_server = Server(2303, self.update)
self.gui_server.start()

LogManager.logger.info("Visualization transition finished")

def add_frequency_control(self, code):
Expand Down

0 comments on commit 8c0dfa1

Please sign in to comment.