19 #include "nav2_util/geometry_utils.hpp"
21 #include "nav2_behavior_tree/plugins/action/extract_route_nodes_as_goals_action.hpp"
23 namespace nav2_behavior_tree
26 ExtractRouteNodesAsGoals::ExtractRouteNodesAsGoals(
27 const std::string & name,
28 const BT::NodeConfiguration & conf)
29 : BT::ActionNodeBase(name, conf)
33 inline BT::NodeStatus ExtractRouteNodesAsGoals::tick()
35 setStatus(BT::NodeStatus::RUNNING);
37 nav2_msgs::msg::Route route;
38 getInput(
"route", route);
40 if (route.nodes.empty()) {
41 return BT::NodeStatus::FAILURE;
44 nav_msgs::msg::Goals goals;
45 goals.header = route.header;
46 goals.goals.reserve(route.nodes.size());
48 for (
const auto & node : route.nodes) {
49 geometry_msgs::msg::PoseStamped goal;
50 goal.header = route.header;
51 goal.pose.position.x = node.position.x;
52 goal.pose.position.y = node.position.y;
53 goals.goals.push_back(goal);
56 setOutput(
"goals", goals);
57 return BT::NodeStatus::SUCCESS;
62 #include "behaviortree_cpp/bt_factory.h"
63 BT_REGISTER_NODES(factory)
66 "ExtractRouteNodesAsGoals");