Nav2 Navigation Stack - kilted  kilted
ROS 2 Navigation Stack
bt_navigator.hpp
1 // Copyright (c) 2018 Intel Corporation
2 // Copyright (c) 2023 Samsung Research America
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef NAV2_BT_NAVIGATOR__BT_NAVIGATOR_HPP_
17 #define NAV2_BT_NAVIGATOR__BT_NAVIGATOR_HPP_
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "nav2_util/lifecycle_node.hpp"
24 #include "nav2_util/odometry_utils.hpp"
25 #include "rclcpp_action/rclcpp_action.hpp"
26 #include "tf2_ros/buffer.h"
27 #include "tf2_ros/transform_listener.h"
28 #include "tf2_ros/create_timer_ros.h"
29 #include "nav2_core/behavior_tree_navigator.hpp"
30 #include "pluginlib/class_loader.hpp"
31 
32 namespace nav2_bt_navigator
33 {
34 
41 {
42 public:
47  explicit BtNavigator(rclcpp::NodeOptions options = rclcpp::NodeOptions());
51  ~BtNavigator();
52 
53 protected:
62  nav2_util::CallbackReturn on_configure(const rclcpp_lifecycle::State & state) override;
68  nav2_util::CallbackReturn on_activate(const rclcpp_lifecycle::State & state) override;
74  nav2_util::CallbackReturn on_deactivate(const rclcpp_lifecycle::State & state) override;
80  nav2_util::CallbackReturn on_cleanup(const rclcpp_lifecycle::State & state) override;
86  nav2_util::CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override;
87 
88  // To handle all the BT related execution
89  pluginlib::ClassLoader<nav2_core::NavigatorBase> class_loader_;
90  std::vector<pluginlib::UniquePtr<nav2_core::NavigatorBase>> navigators_;
91  nav2_core::NavigatorMuxer plugin_muxer_;
92 
93  // Odometry smoother object
94  std::shared_ptr<nav2_util::OdomSmoother> odom_smoother_;
95 
96  // Metrics for feedback
97  std::string robot_frame_;
98  std::string global_frame_;
99  double transform_tolerance_;
100  double filter_duration_;
101  std::string odom_topic_;
102 
103  // Spinning transform that can be used by the node
104  std::shared_ptr<tf2_ros::Buffer> tf_;
105  std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
106 };
107 
108 } // namespace nav2_bt_navigator
109 
110 #endif // NAV2_BT_NAVIGATOR__BT_NAVIGATOR_HPP_
An action server that uses behavior tree for navigating a robot to its goal position.
nav2_util::CallbackReturn on_configure(const rclcpp_lifecycle::State &state) override
Configures member variables.
BtNavigator(rclcpp::NodeOptions options=rclcpp::NodeOptions())
A constructor for nav2_bt_navigator::BtNavigator class.
nav2_util::CallbackReturn on_activate(const rclcpp_lifecycle::State &state) override
Activates action server.
nav2_util::CallbackReturn on_cleanup(const rclcpp_lifecycle::State &state) override
Resets member variables.
~BtNavigator()
A destructor for nav2_bt_navigator::BtNavigator class.
nav2_util::CallbackReturn on_shutdown(const rclcpp_lifecycle::State &state) override
Called when in shutdown state.
nav2_util::CallbackReturn on_deactivate(const rclcpp_lifecycle::State &state) override
Deactivates action server.
A class to control the state of the BT navigator by allowing only a single plugin to be processed at ...
A lifecycle node wrapper to enable common Nav2 needs such as manipulating parameters.