18 #include "nav2_behavior_tree/plugins/action/follow_path_action.hpp"
20 namespace nav2_behavior_tree
24 const std::string & xml_tag_name,
25 const std::string & action_name,
26 const BT::NodeConfiguration & conf)
33 getInput(
"path", goal_.path);
34 getInput(
"controller_id", goal_.controller_id);
35 getInput(
"goal_checker_id", goal_.goal_checker_id);
36 getInput(
"progress_checker_id", goal_.progress_checker_id);
37 getInput(
"path_handler_id", goal_.path_handler_id);
43 setOutput(
"error_code_id", ActionResult::NONE);
44 setOutput(
"error_msg",
"");
45 return BT::NodeStatus::SUCCESS;
51 setOutput(
"error_code_id", result_.result->error_code);
52 setOutput(
"error_msg", result_.result->error_msg);
53 return BT::NodeStatus::FAILURE;
60 setOutput(
"error_code_id", ActionResult::NONE);
61 setOutput(
"error_msg",
"");
62 return BT::NodeStatus::SUCCESS;
68 setOutput(
"error_code_id", ActionResult::CONTROLLER_TIMED_OUT);
72 std::shared_ptr<const Action::Feedback> feedback)
75 nav_msgs::msg::Path new_path;
76 getInput(
"path", new_path);
79 if (goal_.path != new_path && !new_path.poses.empty()) {
81 goal_.path = new_path;
85 std::string new_controller_id;
86 getInput(
"controller_id", new_controller_id);
88 if (goal_.controller_id != new_controller_id) {
89 goal_.controller_id = new_controller_id;
93 std::string new_goal_checker_id;
94 getInput(
"goal_checker_id", new_goal_checker_id);
96 if (goal_.goal_checker_id != new_goal_checker_id) {
97 goal_.goal_checker_id = new_goal_checker_id;
101 std::string new_progress_checker_id;
102 getInput(
"progress_checker_id", new_progress_checker_id);
104 if (goal_.progress_checker_id != new_progress_checker_id) {
105 goal_.progress_checker_id = new_progress_checker_id;
106 goal_updated_ =
true;
109 std::string new_path_handler_id;
110 getInput(
"path_handler_id", new_path_handler_id);
112 if (goal_.path_handler_id != new_path_handler_id) {
113 goal_.path_handler_id = new_path_handler_id;
114 goal_updated_ =
true;
118 setOutput(
"tracking_feedback", feedback->tracking_feedback);
124 nav2_msgs::msg::TrackingFeedback empty_feedback;
125 setOutput(
"tracking_feedback", empty_feedback);
130 #include "behaviortree_cpp/bt_factory.h"
131 BT_REGISTER_NODES(factory)
133 BT::NodeBuilder builder =
134 [](
const std::string & name,
const BT::NodeConfiguration & config)
136 return std::make_unique<nav2_behavior_tree::FollowPathAction>(
137 name,
"follow_path", config);
141 "FollowPath", builder);
Abstract class representing an action based BT node.
virtual void on_timeout()
Function to perform work in a BT Node when the action server times out Such as setting the error code...
A nav2_behavior_tree::BtActionNode class that wraps nav2_msgs::action::FollowPath.
void on_tick() override
Function to perform some user-defined operation on tick.
void on_timeout() override
Function to perform work in a BT Node when the action server times out Such as setting the error code...
BT::NodeStatus on_success() override
Function to perform some user-defined operation upon successful completion of the action.
FollowPathAction(const std::string &xml_tag_name, const std::string &action_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::FollowPathAction.
BT::NodeStatus on_aborted() override
Function to perform some user-defined operation upon abortion of the action.
void on_wait_for_result(std::shared_ptr< const Action::Feedback > feedback) override
Function to perform some user-defined operation after a timeout waiting for a result that hasn't been...
BT::NodeStatus on_cancelled() override
Function to perform some user-defined operation upon cancellation of the action.
void resetFeedbackAndOutputPorts()
Function to set all feedbacks and output ports to be null values.