18 #include "nav2_behavior_tree/plugins/action/compute_path_to_pose_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(
"goal", goal_.goal);
34 getInput(
"planner_id", goal_.planner_id);
37 if (!getInput(
"viapoints", goal_.viapoints)) {
38 goal_.viapoints = std::vector<geometry_msgs::msg::PoseStamped>();
43 goal_.use_start =
false;
44 if (getInput(
"use_start", goal_.use_start)) {
45 if (goal_.use_start && !getInput(
"start", goal_.start)) {
47 goal_.use_start =
false;
50 "use_start is set to true but no start pose was provided, falling back to default "
51 "behavior, i.e. using the current robot pose");
56 if (getInput(
"start", goal_.start)) {
57 goal_.use_start =
true;
64 setOutput(
"path", result_.result->path);
66 setOutput(
"error_code_id", ActionResult::NONE);
67 setOutput(
"error_msg",
"");
68 return BT::NodeStatus::SUCCESS;
73 nav_msgs::msg::Path empty_path;
74 setOutput(
"path", empty_path);
75 setOutput(
"error_code_id", result_.result->error_code);
76 setOutput(
"error_msg", result_.result->error_msg);
77 return BT::NodeStatus::FAILURE;
82 nav_msgs::msg::Path empty_path;
83 setOutput(
"path", empty_path);
85 setOutput(
"error_code_id", ActionResult::NONE);
86 setOutput(
"error_msg",
"");
87 return BT::NodeStatus::SUCCESS;
92 nav_msgs::msg::Path empty_path;
93 setOutput(
"path", empty_path);
101 #include "behaviortree_cpp/bt_factory.h"
102 BT_REGISTER_NODES(factory)
104 BT::NodeBuilder builder =
105 [](
const std::string & name,
const BT::NodeConfiguration & config)
107 return std::make_unique<nav2_behavior_tree::ComputePathToPoseAction>(
108 name,
"compute_path_to_pose", config);
112 "ComputePathToPose", builder);
Abstract class representing an action based BT node.
void halt() override
The other (optional) override required by a BT action. In this case, we make sure to cancel the ROS2 ...
A nav2_behavior_tree::BtActionNode class that wraps nav2_msgs::action::ComputePathToPose.
void on_tick() override
Function to perform some user-defined operation on tick.
void halt() override
Override required by the a BT action. Cancel the action and set the path output.
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.
ComputePathToPoseAction(const std::string &xml_tag_name, const std::string &action_name, const BT::NodeConfiguration &conf)
A constructor for nav2_behavior_tree::ComputePathToPoseAction.
BT::NodeStatus on_success() override
Function to perform some user-defined operation upon successful completion of the action.