18 #include "geometry_msgs/msg/pose_stamped.hpp"
19 #include "behaviortree_cpp/decorator_node.h"
20 #include "nav2_behavior_tree/plugins/decorator/goal_updated_controller.hpp"
22 namespace nav2_behavior_tree
26 const std::string & name,
27 const BT::NodeConfiguration & conf)
28 : BT::DecoratorNode(name, conf)
32 BT::NodeStatus GoalUpdatedController::tick()
34 if (!BT::isStatusActive(status())) {
38 BT::getInputOrBlackboard(
"goals", goals_);
39 BT::getInputOrBlackboard(
"goal", goal_);
41 goal_was_updated_ =
true;
44 setStatus(BT::NodeStatus::RUNNING);
46 nav_msgs::msg::Goals current_goals;
47 BT::getInputOrBlackboard(
"goals", current_goals);
48 geometry_msgs::msg::PoseStamped current_goal;
49 BT::getInputOrBlackboard(
"goal", current_goal);
51 if (goal_ != current_goal || goals_ != current_goals) {
53 goals_ = current_goals;
54 goal_was_updated_ =
true;
60 if ((child_node_->status() == BT::NodeStatus::RUNNING) || goal_was_updated_) {
61 goal_was_updated_ =
false;
62 return child_node_->executeTick();
70 #include "behaviortree_cpp/bt_factory.h"
71 BT_REGISTER_NODES(factory)
A BT::DecoratorNode that ticks its child if the goal was updated.
GoalUpdatedController(const std::string &name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::GoalUpdatedController.