Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
append_goal_pose_to_goals_action.cpp
1 // Copyright (c) 2025 Open Navigation LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include <string>
16 #include <memory>
17 #include <limits>
18 
19 #include "nav2_util/geometry_utils.hpp"
20 
21 #include "nav2_behavior_tree/plugins/action/append_goal_pose_to_goals_action.hpp"
22 
23 namespace nav2_behavior_tree
24 {
25 
26 AppendGoalPoseToGoals::AppendGoalPoseToGoals(
27  const std::string & name,
28  const BT::NodeConfiguration & conf)
29 : BT::ActionNodeBase(name, conf)
30 {
31 }
32 
33 inline BT::NodeStatus AppendGoalPoseToGoals::tick()
34 {
35  setStatus(BT::NodeStatus::RUNNING);
36 
37  geometry_msgs::msg::PoseStamped goal_pose;
38  getInput("goal_pose", goal_pose);
39  nav_msgs::msg::Goals input, output;
40  getInput("input_goals", input);
41 
42  output = input;
43  output.goals.push_back(goal_pose);
44 
45  setOutput("output_goals", output);
46  return BT::NodeStatus::SUCCESS;
47 }
48 
49 } // namespace nav2_behavior_tree
50 
51 #include "behaviortree_cpp/bt_factory.h"
52 BT_REGISTER_NODES(factory)
53 {
54  factory.registerNodeType<nav2_behavior_tree::AppendGoalPoseToGoals>(
55  "AppendGoalPoseToGoals");
56 }