diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp index 505a7895c5..357903df7d 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_action_node.hpp @@ -194,6 +194,10 @@ class BtActionNode : public BT::ActionNodeBase // reset the flag to send the goal or not, allowing the user the option to set it in on_tick should_send_goal_ = true; + // Clear the input and output messages to make sure we have no leftover from previous calls + goal_ = typename ActionT::Goal(); + result_ = typename rclcpp_action::ClientGoalHandle::WrappedResult(); + // user defined callback, may modify "should_send_goal_". on_tick(); diff --git a/nav2_behavior_tree/include/nav2_behavior_tree/bt_service_node.hpp b/nav2_behavior_tree/include/nav2_behavior_tree/bt_service_node.hpp index 746ef61049..a774db4384 100644 --- a/nav2_behavior_tree/include/nav2_behavior_tree/bt_service_node.hpp +++ b/nav2_behavior_tree/include/nav2_behavior_tree/bt_service_node.hpp @@ -138,6 +138,9 @@ class BtServiceNode : public BT::ActionNodeBase // allowing the user the option to set it in on_tick should_send_request_ = true; + // Clear the input request to make sure we have no leftover from previous calls + request_ = std::make_shared(); + // user defined callback, may modify "should_send_request_". on_tick();