Nav2 Navigation Stack - lyrical  lyrical
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_ros_common/lifecycle_node.hpp"
24 #include "nav2_ros_common/tf2_factories.hpp"
25 #include "nav2_util/odometry_utils.hpp"
26 #include "rclcpp_action/rclcpp_action.hpp"
27 #include "nav2_core/behavior_tree_navigator.hpp"
28 #include "pluginlib/class_loader.hpp"
29 
30 namespace nav2_bt_navigator
31 {
32 
39 {
40 public:
45  explicit BtNavigator(rclcpp::NodeOptions options = rclcpp::NodeOptions());
49  ~BtNavigator();
50 
51 protected:
60  nav2::CallbackReturn on_configure(const rclcpp_lifecycle::State & state) override;
66  nav2::CallbackReturn on_activate(const rclcpp_lifecycle::State & state) override;
72  nav2::CallbackReturn on_deactivate(const rclcpp_lifecycle::State & state) override;
78  nav2::CallbackReturn on_cleanup(const rclcpp_lifecycle::State & state) override;
84  nav2::CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override;
85 
86  // To handle all the BT related execution
87  pluginlib::ClassLoader<nav2_core::NavigatorBase> class_loader_;
88  std::vector<pluginlib::UniquePtr<nav2_core::NavigatorBase>> navigators_;
89  nav2_core::NavigatorMuxer plugin_muxer_;
90 
91  // Odometry smoother object
92  std::shared_ptr<nav2_util::OdomSmoother> odom_smoother_;
93 
94  // Metrics for feedback
95  std::string robot_frame_;
96  std::string global_frame_;
97  double transform_tolerance_;
98  double filter_duration_;
99  std::string odom_topic_;
100 
101  // Spinning transform that can be used by the node
102  nav2::TransformBuffer::SharedPtr tf_;
103  nav2::TransformListener::SharedPtr tf_listener_;
104 };
105 
106 } // namespace nav2_bt_navigator
107 
108 #endif // NAV2_BT_NAVIGATOR__BT_NAVIGATOR_HPP_
A lifecycle node wrapper to enable common Nav2 needs such as manipulating parameters.
An action server that uses behavior tree for navigating a robot to its goal position.
nav2::CallbackReturn on_shutdown(const rclcpp_lifecycle::State &state) override
Called when in shutdown state.
nav2::CallbackReturn on_deactivate(const rclcpp_lifecycle::State &state) override
Deactivates action server.
nav2::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::CallbackReturn on_cleanup(const rclcpp_lifecycle::State &state) override
Resets member variables.
~BtNavigator()
A destructor for nav2_bt_navigator::BtNavigator class.
nav2::CallbackReturn on_activate(const rclcpp_lifecycle::State &state) override
Activates action server.
A class to control the state of the BT navigator by allowing only a single plugin to be processed at ...