Skip to content

Commit bdcc32b

Browse files
authored
Merge pull request #206 from JdeRobot/prepare-premium
RI premium and custom universes
2 parents ca324cb + d5c2f6a commit bdcc32b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

manager/manager/docker_thread/docker_thread.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88

9-
109
class DockerThread(threading.Thread):
1110
"""Threaded Docker Thread Class"""
1211
def __init__(self, cmd, shell=True):
@@ -17,7 +16,7 @@ def __init__(self, cmd, shell=True):
1716

1817
def run(self):
1918
self.process = subprocess.Popen(self.cmd, shell=self.shell, stdout=subprocess.PIPE, stderr=subprocess.PIPE, start_new_session=True,
20-
bufsize=1024, universal_newlines=True)
19+
bufsize=1024, universal_newlines=True, executable="/bin/bash")
2120
self.process.communicate()
2221

2322
def terminate(self):

manager/manager/launcher/launcher_ros2_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ def run(self, callback):
2929

3030
if ACCELERATION_ENABLED:
3131
exercise_launch_cmd = (
32-
f"export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}"
32+
f"source /.env;export VGL_DISPLAY={DRI_PATH}; vglrun ros2 launch {self.launch_file}"
3333
)
3434
else:
35-
exercise_launch_cmd = f"ros2 launch {self.launch_file}"
35+
exercise_launch_cmd = f"source /.env;ros2 launch {self.launch_file}"
3636

3737
exercise_launch_thread = DockerThread(exercise_launch_cmd)
3838
exercise_launch_thread.start()

manager/manager/manager.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,26 @@ def prepare_custom_universe(self, cfg_dict):
294294
if cfg_dict["zip"].startswith("data:"):
295295
_, _, zip_file = cfg_dict["zip"].partition("base64,")
296296

297-
universe_ref = "/workspace/worlds/" + cfg_dict["name"]
298-
zip_destination = universe_ref + ".zip"
299-
with open(zip_destination, "wb") as result:
300-
result.write(base64.b64decode(zip_file))
297+
universe_ref = "/workspace/worlds/src/" + cfg_dict["name"]
298+
# Remove old content
299+
if os.path.exists("/workspace/worlds"):
300+
shutil.rmtree("/workspace/worlds", ignore_errors=False)
301301

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

307+
zip_destination = universe_ref + ".zip"
308+
with open(zip_destination, "wb") as result:
309+
result.write(base64.b64decode(zip_file))
310+
307311
zip_ref = zipfile.ZipFile(zip_destination, "r")
308312
zip_ref.extractall(universe_folder + "/")
309313
zip_ref.close()
310314

315+
os.system('/bin/bash -c "cd /workspace/worlds; source /opt/ros/humble/setup.bash; colcon build --symlink-install; source install/setup.bash; cd ../.."')
316+
311317
def on_prepare_visualization(self, event):
312318

313319
LogManager.logger.info("Visualization transition started")
@@ -327,7 +333,7 @@ def on_prepare_visualization(self, event):
327333
self.gui_server = Server(2303, self.update)
328334
self.gui_server.start()
329335
elif self.visualization_type in ["bt_studio", "bt_studio_gz"]:
330-
self.gui_server = FileWatchdog('/tmp/tree_state', self.update_bt_studio) # TODO: change if type bt
336+
self.gui_server = FileWatchdog('/tmp/tree_state', self.update_bt_studio)
331337
self.gui_server.start()
332338

333339
LogManager.logger.info("Visualization transition finished")
@@ -568,7 +574,6 @@ def on_code_autocomplete(self, event):
568574
except Exception as e:
569575
LogManager.logger.info('Error formating code' + str(e))
570576

571-
572577
def on_run_application(self, event):
573578
def find_docker_console():
574579
"""Search console in docker different of /dev/pts/0"""

0 commit comments

Comments
 (0)