Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
is_within_path_tracking_bounds_condition.hpp
1 // Copyright (c) 2025 Berkan Tali
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 #ifndef NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_WITHIN_PATH_TRACKING_BOUNDS_CONDITION_HPP_
16 #define NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_WITHIN_PATH_TRACKING_BOUNDS_CONDITION_HPP_
17 
18 #include <string>
19 #include <memory>
20 
21 #include "behaviortree_cpp/condition_node.h"
22 #include "nav2_ros_common/lifecycle_node.hpp"
23 #include "nav2_msgs/msg/tracking_feedback.hpp"
24 #include "rclcpp/rclcpp.hpp"
25 
26 namespace nav2_behavior_tree
27 {
28 
38 class IsWithinPathTrackingBoundsCondition : public BT::ConditionNode
39 {
40 public:
47  const std::string & condition_name,
48  const BT::NodeConfiguration & conf);
49 
51 
55  void initialize();
56 
61  BT::NodeStatus tick() override;
62 
67  static BT::PortsList providedPorts()
68  {
69  return {
70  BT::InputPort<double>("max_error_left", 0.5,
71  "Maximum allowed position tracking error left side"),
72  BT::InputPort<double>("max_error_right", 0.5,
73  "Maximum allowed position tracking error on the right side"),
74  BT::InputPort<double>("max_error_heading", 3.14,
75  "Maximum allowed heading tracking error in radians"),
76  BT::InputPort<nav2_msgs::msg::TrackingFeedback>("tracking_feedback",
77  "Current tracking feedback message")
78  };
79  }
80 
81 protected:
82  rclcpp::Clock::SharedPtr clock_;
83  rclcpp::Logger logger_{rclcpp::get_logger("IsWithinPathTrackingBoundsCondition")};
84 
85  double max_error_left_;
86  double max_error_right_;
87  double max_error_heading_;
88  nav2_msgs::msg::TrackingFeedback tracking_feedback_;
89 };
90 
91 } // namespace nav2_behavior_tree
92 
93 #endif // NAV2_BEHAVIOR_TREE__PLUGINS__CONDITION__IS_WITHIN_PATH_TRACKING_BOUNDS_CONDITION_HPP_
A BT::ConditionNode that returns SUCCESS when the current path tracking error is within specified bou...
BT::NodeStatus tick() override
The main override required by a BT action.
void initialize()
Function to read parameters and initialize class variables.