Nav2 Navigation Stack - lyrical  lyrical
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/clock.hpp"
25 #include "rclcpp/logger.hpp"
26 
27 namespace nav2_behavior_tree
28 {
29 
39 class IsWithinPathTrackingBoundsCondition : public BT::ConditionNode
40 {
41 public:
48  const std::string & condition_name,
49  const BT::NodeConfiguration & conf);
50 
52 
56  void initialize();
57 
62  BT::NodeStatus tick() override;
63 
68  static BT::PortsList providedPorts()
69  {
70  return {
71  BT::InputPort<double>("max_error_left", 0.5,
72  "Maximum allowed position tracking error left side"),
73  BT::InputPort<double>("max_error_right", 0.5,
74  "Maximum allowed position tracking error on the right side"),
75  BT::InputPort<double>("max_error_heading", 3.14,
76  "Maximum allowed heading tracking error in radians"),
77  BT::InputPort<nav2_msgs::msg::TrackingFeedback>("tracking_feedback",
78  "Current tracking feedback message")
79  };
80  }
81 
82 protected:
83  rclcpp::Clock::SharedPtr clock_;
84  rclcpp::Logger logger_{rclcpp::get_logger("IsWithinPathTrackingBoundsCondition")};
85 
86  double max_error_left_;
87  double max_error_right_;
88  double max_error_heading_;
89  nav2_msgs::msg::TrackingFeedback tracking_feedback_;
90 };
91 
92 } // namespace nav2_behavior_tree
93 
94 #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.