Nav2 Navigation Stack - humble  humble
ROS 2 Navigation Stack
bt_navigator.hpp
1 // Copyright (c) 2018 Intel Corporation
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_BT_NAVIGATOR__BT_NAVIGATOR_HPP_
16 #define NAV2_BT_NAVIGATOR__BT_NAVIGATOR_HPP_
17 
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 #include "nav2_util/lifecycle_node.hpp"
23 #include "nav2_util/odometry_utils.hpp"
24 #include "rclcpp_action/rclcpp_action.hpp"
25 #include "tf2_ros/buffer.h"
26 #include "tf2_ros/transform_listener.h"
27 #include "tf2_ros/create_timer_ros.h"
28 #include "nav2_bt_navigator/navigators/navigate_to_pose.hpp"
29 #include "nav2_bt_navigator/navigators/navigate_through_poses.hpp"
30 
31 namespace nav2_bt_navigator
32 {
33 
40 {
41 public:
46  explicit BtNavigator(rclcpp::NodeOptions options = rclcpp::NodeOptions());
50  ~BtNavigator();
51 
52 protected:
61  nav2_util::CallbackReturn on_configure(const rclcpp_lifecycle::State & state) override;
67  nav2_util::CallbackReturn on_activate(const rclcpp_lifecycle::State & state) override;
73  nav2_util::CallbackReturn on_deactivate(const rclcpp_lifecycle::State & state) override;
79  nav2_util::CallbackReturn on_cleanup(const rclcpp_lifecycle::State & state) override;
85  nav2_util::CallbackReturn on_shutdown(const rclcpp_lifecycle::State & state) override;
86 
87  // To handle all the BT related execution
88  std::unique_ptr<nav2_bt_navigator::Navigator<nav2_msgs::action::NavigateToPose>> pose_navigator_;
89  std::unique_ptr<nav2_bt_navigator::Navigator<nav2_msgs::action::NavigateThroughPoses>>
90  poses_navigator_;
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  std::string odom_topic_;
101 
102  // Spinning transform that can be used by the BT nodes
103  std::shared_ptr<tf2_ros::Buffer> tf_;
104  std::shared_ptr<tf2_ros::TransformListener> tf_listener_;
105 };
106 
107 } // namespace nav2_bt_navigator
108 
109 #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 ...
Definition: navigator.hpp:51
A lifecycle node wrapper to enable common Nav2 needs such as manipulating parameters.