@@ -47,7 +47,7 @@ class BtActionNode : public BT::ActionNodeBase
4747 const std::string & xml_tag_name,
4848 const std::string & action_name,
4949 const BT::NodeConfiguration & conf)
50- : BT::ActionNodeBase(xml_tag_name, conf), action_name_(action_name)
50+ : BT::ActionNodeBase(xml_tag_name, conf), action_name_(action_name), should_send_goal_( true )
5151 {
5252 node_ = config ().blackboard ->template get <rclcpp::Node::SharedPtr>(" node" );
5353 callback_group_ = node_->create_callback_group (
@@ -191,7 +191,10 @@ class BtActionNode : public BT::ActionNodeBase
191191 // setting the status to RUNNING to notify the BT Loggers (if any)
192192 setStatus (BT::NodeStatus::RUNNING);
193193
194- // user defined callback
194+ // reset the flag to send the goal or not, allowing the user the option to set it in on_tick
195+ should_send_goal_ = true ;
196+
197+ // user defined callback, may modify "should_send_goal_".
195198 on_tick ();
196199
197200 if (!should_send_goal_) {
@@ -453,6 +456,9 @@ class BtActionNode : public BT::ActionNodeBase
453456 std::shared_ptr<std::shared_future<typename rclcpp_action::ClientGoalHandle<ActionT>::SharedPtr>>
454457 future_goal_handle_;
455458 rclcpp::Time time_goal_sent_;
459+
460+ // Can be set in on_tick or on_wait_for_result to indicate if a goal should be sent.
461+ bool should_send_goal_;
456462};
457463
458464} // namespace nav2_behavior_tree
0 commit comments