Skip to content

RI premium and custom universes #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
May 21, 2025
3 changes: 1 addition & 2 deletions manager/manager/docker_thread/docker_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@




class DockerThread(threading.Thread):
"""Threaded Docker Thread Class"""
def __init__(self, cmd, shell=True):
Expand All @@ -17,7 +16,7 @@ def __init__(self, cmd, shell=True):

def run(self):
self.process = subprocess.Popen(self.cmd, shell=self.shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True,
bufsize=1024, universal_newlines=True)
bufsize=1024, universal_newlines=True, executable="/bin/bash")
self.process.communicate()

def terminate(self):
Expand Down
4 changes: 2 additions & 2 deletions manager/manager/launcher/launcher_ros2_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ def run(self, callback):

if ACCELERATION_ENABLED:
exercise_launch_cmd = (
f"export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}"
f"source /.env;export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}"
)
else:
exercise_launch_cmd = f"ros2 launch {self.launch_file}"
exercise_launch_cmd = f"source /.env;ros2 launch {self.launch_file}"

exercise_launch_thread = DockerThread(exercise_launch_cmd)
exercise_launch_thread.start()
Expand Down
17 changes: 11 additions & 6 deletions manager/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,26 @@ def prepare_custom_universe(self, cfg_dict):
if cfg_dict["zip"].startswith("data:"):
_, _, zip_file = cfg_dict["zip"].partition("base64,")

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))
universe_ref = "/workspace/worlds/src/" + cfg_dict["name"]
# Remove old content
if os.path.exists("/workspace/worlds"):
shutil.rmtree("/workspace/worlds", ignore_errors=False)

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

zip_destination = universe_ref + ".zip"
with open(zip_destination, "wb") as result:
result.write(base64.b64decode(zip_file))

zip_ref = zipfile.ZipFile(zip_destination, "r")
zip_ref.extractall(universe_folder + "/")
zip_ref.close()

os.system('/bin/bash -c "cd /workspace/worlds; source /opt/ros/humble/setup.bash; colcon build --symlink-install; source install/setup.bash; cd ../.."')

def on_prepare_visualization(self, event):

LogManager.logger.info("Visualization transition started")
Expand All @@ -328,7 +334,7 @@ def on_prepare_visualization(self, event):
self.gui_server = Server(2303, self.update)
self.gui_server.start()
elif self.visualization_type in ["bt_studio", "bt_studio_gz"]:
self.gui_server = FileWatchdog('/tmp/tree_state', self.update_bt_studio) # TODO: change if type bt
self.gui_server = FileWatchdog('/tmp/tree_state', self.update_bt_studio)
self.gui_server.start()

LogManager.logger.info("Visualization transition finished")
Expand Down Expand Up @@ -569,7 +575,6 @@ def on_code_autocomplete(self, event):
except Exception as e:
LogManager.logger.info('Error formating code' + str(e))


def on_run_application(self, event):
def find_docker_console():
"""Search console in docker different of /dev/pts/0"""
Expand Down