@@ -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