18 #include "rclcpp/rclcpp.hpp"
19 #include "geometry_msgs/msg/pose_stamped.hpp"
20 #include "behaviortree_cpp/decorator_node.h"
21 #include "nav2_behavior_tree/plugins/decorator/goal_updated_controller.hpp"
23 namespace nav2_behavior_tree
27 const std::string & name,
28 const BT::NodeConfiguration & conf)
29 : BT::DecoratorNode(name, conf)
33 BT::NodeStatus GoalUpdatedController::tick()
35 if (!BT::isStatusActive(status())) {
39 BT::getInputOrBlackboard(
"goals", goals_);
40 BT::getInputOrBlackboard(
"goal", goal_);
42 goal_was_updated_ =
true;
45 setStatus(BT::NodeStatus::RUNNING);
47 std::vector<geometry_msgs::msg::PoseStamped> current_goals;
48 BT::getInputOrBlackboard(
"goals", current_goals);
49 geometry_msgs::msg::PoseStamped current_goal;
50 BT::getInputOrBlackboard(
"goal", current_goal);
52 if (goal_ != current_goal || goals_ != current_goals) {
54 goals_ = current_goals;
55 goal_was_updated_ =
true;
61 if ((child_node_->status() == BT::NodeStatus::RUNNING) || goal_was_updated_) {
62 goal_was_updated_ =
false;
63 return child_node_->executeTick();
71 #include "behaviortree_cpp/bt_factory.h"
72 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.