Skip to content

Commit 4c9f178

Browse files
authored
Merge pull request #195 from JdeRobot/terminate-harmonic-processes
Kill harmonic processes when switching universes
2 parents 4905113 + 8348a01 commit 4c9f178

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

manager/manager/manager.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def on_prepare_visualization(self, event):
324324

325325
self.visualization_launcher.run()
326326

327-
if self.visualization_type in ["gazebo_rae", "gzsim_rae"]:
327+
if self.visualization_type in ["gazebo_rae", "gzsim_rae", "console"]:
328328
self.gui_server = Server(2303, self.update)
329329
self.gui_server.start()
330330
elif self.visualization_type in ["bt_studio", "bt_studio_gz"]:
@@ -675,6 +675,7 @@ def terminate_harmonic_processes(self):
675675
"""
676676
Terminate all processes within the Docker container whose command line contains 'gz' or 'launch'.
677677
"""
678+
LogManager.logger.info("Terminate Harmonic process")
678679
keywords = ['gz', 'launch']
679680
for keyword in keywords:
680681
try:
@@ -734,6 +735,7 @@ def on_terminate_universe(self, event):
734735
self.world_launcher.terminate()
735736
if self.robot_launcher != None:
736737
self.robot_launcher.terminate()
738+
self.terminate_harmonic_processes()
737739

738740
def on_disconnect(self, event):
739741
self.terminate_harmonic_processes()
@@ -796,13 +798,13 @@ def on_resume(self, msg):
796798
def pause_sim(self):
797799
if self.visualization_type in ["gzsim_rae", "bt_studio_gz"]:
798800
self.call_gzservice("$(gz service -l | grep '^/world/\w*/control$')","gz.msgs.WorldControl","gz.msgs.Boolean","3000","pause: true")
799-
else:
801+
elif not self.visualization_type in ["console"]:
800802
self.call_service("/pause_physics", "std_srvs/srv/Empty")
801803

802804
def unpause_sim(self):
803805
if self.visualization_type in ["gzsim_rae", "bt_studio_gz"]:
804806
self.call_gzservice("$(gz service -l | grep '^/world/\w*/control$')","gz.msgs.WorldControl","gz.msgs.Boolean","3000","pause: false")
805-
else:
807+
elif not self.visualization_type in ["console"]:
806808
self.call_service("/unpause_physics", "std_srvs/srv/Empty")
807809

808810
def reset_sim(self):
@@ -815,7 +817,7 @@ def reset_sim(self):
815817
self.call_gzservice("$(gz service -l | grep '^/world/\w*/control$')","gz.msgs.WorldControl","gz.msgs.Boolean","3000","reset: {all: true}")
816818
if self.is_ros_service_available("/drone0/controller/_reset"):
817819
self.call_service("/drone0/controller/_reset", "std_srvs/srv/Trigger", "{}")
818-
else:
820+
elif not self.visualization_type in ["console"]:
819821
self.call_service("/reset_world", "std_srvs/srv/Empty")
820822

821823
if self.robot_launcher:

0 commit comments

Comments
 (0)