18 #include "nav2_behavior_tree/plugins/action/compute_and_track_route_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)
29 nav_msgs::msg::Path empty_path;
30 nav2_msgs::msg::Route empty_route;
31 feedback_.last_node_id = 0;
32 feedback_.next_node_id = 0;
33 feedback_.current_edge_id = 0;
34 feedback_.route = empty_route;
35 feedback_.path = empty_path;
36 feedback_.rerouted =
false;
41 bool use_poses =
false, use_start =
false;
42 getInput(
"use_poses", use_poses);
44 goal_.use_poses =
true;
45 getInput(
"goal", goal_.goal);
47 goal_.use_start =
false;
48 getInput(
"use_start", use_start);
50 getInput(
"start", goal_.start);
51 goal_.use_start =
true;
54 getInput(
"start_id", goal_.start_id);
55 getInput(
"goal_id", goal_.goal_id);
56 goal_.use_start =
false;
57 goal_.use_poses =
false;
64 setOutput(
"execution_duration", result_.result->execution_duration);
65 setOutput(
"error_code_id", ActionResult::NONE);
66 setOutput(
"error_msg",
"");
67 return BT::NodeStatus::SUCCESS;
73 setOutput(
"execution_duration", builtin_interfaces::msg::Duration());
74 setOutput(
"error_code_id", result_.result->error_code);
75 setOutput(
"error_msg", result_.result->error_msg);
76 return BT::NodeStatus::FAILURE;
83 setOutput(
"execution_duration", builtin_interfaces::msg::Duration());
84 setOutput(
"error_code_id", ActionResult::NONE);
85 setOutput(
"error_msg",
"");
86 return BT::NodeStatus::SUCCESS;
90 std::shared_ptr<const Action::Feedback> feedback)
93 bool use_poses =
false, use_start =
false;
94 getInput(
"use_start", use_start);
95 getInput(
"use_poses", use_poses);
97 if (goal_.use_poses != use_poses) {
102 geometry_msgs::msg::PoseStamped goal;
103 getInput(
"goal", goal);
104 if (goal_.goal != goal) {
105 goal_updated_ =
true;
108 if (goal_.use_start != use_start) {
109 goal_updated_ =
true;
112 geometry_msgs::msg::PoseStamped start;
113 getInput(
"start", start);
114 if (goal_.start != start) {
115 goal_updated_ =
true;
120 unsigned int start_id = 0;
121 unsigned int goal_id = 0;
122 getInput(
"start_id", start_id);
123 getInput(
"goal_id", goal_id);
124 if (goal_.start_id != start_id) {
125 goal_updated_ =
true;
127 if (goal_.goal_id != goal_id) {
128 goal_updated_ =
true;
139 feedback_ = *feedback;
140 setOutput(
"last_node_id", feedback_.last_node_id);
141 setOutput(
"next_node_id", feedback_.next_node_id);
142 setOutput(
"current_edge_id", feedback_.current_edge_id);
143 setOutput(
"route", feedback_.route);
144 setOutput(
"path", feedback_.path);
145 setOutput(
"rerouted", feedback_.rerouted);
151 nav_msgs::msg::Path empty_path;
152 nav2_msgs::msg::Route empty_route;
153 feedback_.last_node_id = 0;
154 feedback_.next_node_id = 0;
155 feedback_.current_edge_id = 0;
156 feedback_.route = empty_route;
157 feedback_.path = empty_path;
158 feedback_.rerouted =
false;
159 setOutput(
"last_node_id", feedback_.last_node_id);
160 setOutput(
"next_node_id", feedback_.next_node_id);
161 setOutput(
"current_edge_id", feedback_.current_edge_id);
162 setOutput(
"route", feedback_.route);
163 setOutput(
"path", feedback_.path);
164 setOutput(
"rerouted", feedback_.rerouted);
169 #include "behaviortree_cpp/bt_factory.h"
170 BT_REGISTER_NODES(factory)
172 BT::NodeBuilder builder =
173 [](
const std::string & name,
const BT::NodeConfiguration & config)
175 return std::make_unique<nav2_behavior_tree::ComputeAndTrackRouteAction>(
176 name,
"compute_and_track_route", config);
180 "ComputeAndTrackRoute", builder);
Abstract class representing an action based BT node.
A nav2_behavior_tree::BtActionNode class that wraps nav2_msgs::action::ComputeAndTrackRoute.
BT::NodeStatus on_cancelled() override
Function to perform some user-defined operation upon cancellation of the action.
BT::NodeStatus on_aborted() override
Function to perform some user-defined operation upon abortion of the action.
ComputeAndTrackRouteAction(const std::string &xml_tag_name, const std::string &action_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::ComputeAndTrackRouteAction.
BT::NodeStatus on_success() override
Function to perform some user-defined operation upon successful completion 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...
void on_tick() override
Function to perform some user-defined operation on tick.
void resetFeedbackAndOutputPorts()
Function to set all feedbacks and output ports to be null values.