From 80117c5b78fdf5944c32415e0cf8cfcae65c583d Mon Sep 17 00:00:00 2001 From: ReykCS Date: Tue, 14 Feb 2023 00:11:35 +0100 Subject: [PATCH] send task progress messages only once when in docker --- task_generator/robot_setup/rosnav_agents.yaml | 5 ++++- task_generator/scripts/task_generator_node.py | 9 +++++---- .../task_generator/simulators/gazebo_simulator.py | 2 +- training/scripts/train_agent.py | 10 +++++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/task_generator/robot_setup/rosnav_agents.yaml b/task_generator/robot_setup/rosnav_agents.yaml index c3bb1c2b..ea2653b4 100644 --- a/task_generator/robot_setup/rosnav_agents.yaml +++ b/task_generator/robot_setup/rosnav_agents.yaml @@ -12,7 +12,10 @@ robots: - model: jackal planner: rosnav amount: 3 - agent: new_jackal + agent: jackal + - model: rto + planner: teb + amount: 3 # - model: jackal # planner: rosnav # amount: 1 diff --git a/task_generator/scripts/task_generator_node.py b/task_generator/scripts/task_generator_node.py index e1f947ef..db6d88ce 100644 --- a/task_generator/scripts/task_generator_node.py +++ b/task_generator/scripts/task_generator_node.py @@ -106,11 +106,12 @@ def _send_end_message_on_end(self, is_end): rospy.loginfo("Shutting down. All tasks completed") - # Send this message 10 times to make sure it is received - for _ in range(10): - self.pub_scenario_finished.publish(Bool(True)) + # Send Task finished to Backend + if rospy.get_param("/is_webapp_docker", False): + while self.pub_scenario_finished.get_num_connections() <= 0: + pass - rospy.sleep(0.1) + self.pub_scenario_finished.publish(Empty()) rospy.signal_shutdown("Finished all episodes of the current scenario") diff --git a/task_generator/task_generator/simulators/gazebo_simulator.py b/task_generator/task_generator/simulators/gazebo_simulator.py index 1e7229a5..3d792d58 100644 --- a/task_generator/task_generator/simulators/gazebo_simulator.py +++ b/task_generator/task_generator/simulators/gazebo_simulator.py @@ -28,7 +28,7 @@ def __init__(self, namespace): self._goal_pub = rospy.Publisher(self._ns_prefix("/goal"), PoseStamped, queue_size=1, latch=True) - self._robot_name = rospy.get_param("robot_model") + self._robot_name = rospy.get_param("robot_model", "") rospy.wait_for_service("/gazebo/spawn_urdf_model") rospy.wait_for_service("/gazebo/set_model_state") diff --git a/training/scripts/train_agent.py b/training/scripts/train_agent.py index 90c50e3e..340fbe83 100644 --- a/training/scripts/train_agent.py +++ b/training/scripts/train_agent.py @@ -74,11 +74,15 @@ def main(): model.env.close() - publisher = rospy.Publisher("training_finished", Empty, queue_size=10) + # Send Task finished to Backend + if rospy.get_param("/is_webapp_docker", False): + publisher = rospy.Publisher("training_finished", Empty, queue_size=10) + + while publisher.get_num_connections() <= 0: + pass - for _ in range(10): publisher.publish(Empty()) - rospy.sleep(0.1) + sys.exit()