From cbf468975441b0c2394978c7edba55241fa04b8c Mon Sep 17 00:00:00 2001 From: Mario Garzon Date: Wed, 3 Mar 2021 23:21:47 +0100 Subject: [PATCH] update reasoner Set objetive to false after deleting it --- mros2_reasoner/mros2_reasoner/ros_reasoner.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mros2_reasoner/mros2_reasoner/ros_reasoner.py b/mros2_reasoner/mros2_reasoner/ros_reasoner.py index bf3f8c3..f7b011d 100644 --- a/mros2_reasoner/mros2_reasoner/ros_reasoner.py +++ b/mros2_reasoner/mros2_reasoner/ros_reasoner.py @@ -115,19 +115,22 @@ def set_initial_fd(self, initial_fd): def objective_cancel_goal_callback(self, cancel_request): self.get_logger().info("Cancel Action Callback!") # Stop reasoning - self.hasObjective = False + if (cancel_request.qos_expected is None): # Checks if there are previously defined objectives. for old_objective in self.reasoner.search_objectives(): self.reasoner.remove_objective(old_objective.name) + self.hasObjective = False return CancelResponse.ACCEPT else: if self.reasoner.remove_objective(cancel_request.qos_expected.objective_id): self.get_logger().info("Objective Cancelled") + self.hasObjective = False return CancelResponse.ACCEPT else: self.get_logger().info("Not found") return CancelResponse.REJECT +