Nav2 Navigation Stack - lyrical  lyrical
ROS 2 Navigation Stack
navigator.hpp
1 // Copyright (c) 2024 Open Navigation LLC
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 OPENNAV_DOCKING__NAVIGATOR_HPP_
16 #define OPENNAV_DOCKING__NAVIGATOR_HPP_
17 
18 #include <vector>
19 #include <memory>
20 #include <string>
21 #include <functional>
22 
23 #include "rclcpp/callback_group.hpp"
24 #include "rclcpp/duration.hpp"
25 #include "rclcpp/executors/single_threaded_executor.hpp"
26 #include "rclcpp_action/rclcpp_action.hpp"
27 #include "pluginlib/class_loader.hpp"
28 #include "pluginlib/class_list_macros.hpp"
29 
30 #include "nav2_msgs/action/navigate_to_pose.hpp"
31 #include "nav2_ros_common/node_utils.hpp"
32 #include "opennav_docking/utils.hpp"
33 #include "opennav_docking/types.hpp"
34 
35 namespace opennav_docking
36 {
41 class Navigator
42 {
43 public:
44  using Nav2Pose = nav2_msgs::action::NavigateToPose;
45  using ActionClient = nav2::ActionClient<Nav2Pose>;
46 
51  explicit Navigator(const nav2::LifecycleNode::WeakPtr & parent);
52 
56  ~Navigator() = default;
57 
61  void activate();
62 
66  void deactivate();
67 
77  void goToPose(
78  const geometry_msgs::msg::PoseStamped & pose,
79  rclcpp::Duration remaining_staging_duration,
80  std::function<bool()> isPreempted,
81  bool recursed = false);
82 
83 protected:
84  nav2::LifecycleNode::WeakPtr node_;
85  rclcpp::CallbackGroup::SharedPtr callback_group_;
86  rclcpp::executors::SingleThreadedExecutor executor_;
87  ActionClient::SharedPtr nav_to_pose_client_;
88  std::string navigator_bt_xml_;
89 };
90 
91 } // namespace opennav_docking
92 
93 #endif // OPENNAV_DOCKING__NAVIGATOR_HPP_
An object the call navigation to obtain initial staging pose.
Definition: navigator.hpp:42
void activate()
An activation method.
Definition: navigator.cpp:30
Navigator(const nav2::LifecycleNode::WeakPtr &parent)
A constructor for opennav_docking::Navigator.
Definition: navigator.cpp:23
~Navigator()=default
A destructor for opennav_docking::Navigator.
void goToPose(const geometry_msgs::msg::PoseStamped &pose, rclcpp::Duration remaining_staging_duration, std::function< bool()> isPreempted, bool recursed=false)
An method to go to a particular pose May throw exception if fails to navigate or communicate Blocks u...
Definition: navigator.cpp:47
void deactivate()
An deactivation method.
Definition: navigator.cpp:42