Skip to content
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

Kill harmonic processes when switching universes #195

Merged
merged 2 commits into from
Mar 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions manager/manager/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def on_prepare_visualization(self, event):

self.visualization_launcher.run()

if self.visualization_type in ["gazebo_rae", "gzsim_rae"]:
if self.visualization_type in ["gazebo_rae", "gzsim_rae", "console"]:
self.gui_server = Server(2303, self.update)
self.gui_server.start()
elif self.visualization_type in ["bt_studio", "bt_studio_gz"]:
Expand Down Expand Up @@ -675,6 +675,7 @@ def terminate_harmonic_processes(self):
"""
Terminate all processes within the Docker container whose command line contains 'gz' or 'launch'.
"""
LogManager.logger.info("Terminate Harmonic process")
keywords = ['gz', 'launch']
for keyword in keywords:
try:
Expand Down Expand Up @@ -734,6 +735,7 @@ def on_terminate_universe(self, event):
self.world_launcher.terminate()
if self.robot_launcher != None:
self.robot_launcher.terminate()
self.terminate_harmonic_processes()

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

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

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

if self.robot_launcher:
Expand Down