Nav2 Navigation Stack - rolling  main
ROS 2 Navigation Stack
charging_dock.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_CORE__CHARGING_DOCK_HPP_
16 #define OPENNAV_DOCKING_CORE__CHARGING_DOCK_HPP_
17 
18 #include <string>
19 #include <memory>
20 
21 #include "nav2_ros_common/lifecycle_node.hpp"
22 #include "geometry_msgs/msg/pose_stamped.hpp"
23 #include "tf2_ros/buffer.hpp"
24 
25 
26 namespace opennav_docking_core
27 {
28 
33 enum class DockDirection { UNKNOWN, FORWARD, BACKWARD };
34 
40 {
41 public:
42  using Ptr = std::shared_ptr<ChargingDock>;
43 
47  virtual ~ChargingDock() {}
48 
54  virtual void configure(
55  const nav2::LifecycleNode::WeakPtr & parent,
56  const std::string & name, std::shared_ptr<tf2_ros::Buffer> tf) = 0;
57 
61  virtual void cleanup() = 0;
62 
66  virtual void activate() = 0;
67 
71  virtual void deactivate() = 0;
72 
81  virtual geometry_msgs::msg::PoseStamped getStagingPose(
82  const geometry_msgs::msg::Pose & pose, const std::string & frame) = 0;
83 
89  virtual bool getRefinedPose(geometry_msgs::msg::PoseStamped & pose, std::string id) = 0;
90 
99  virtual bool isDocked() = 0;
100 
109  virtual bool isCharging() = 0;
110 
120  virtual bool disableCharging() = 0;
121 
125  virtual bool hasStoppedCharging() = 0;
126 
130  virtual bool isCharger() {return true;}
131 
137  DockDirection getDockDirection() {return dock_direction_;}
138 
144  bool shouldRotateToDock() {return rotate_to_dock_;}
145 
146  std::string getName() {return name_;}
147 
148 protected:
149  std::string name_;
150  DockDirection dock_direction_{DockDirection::UNKNOWN};
151  bool rotate_to_dock_{false};
152 };
153 
154 } // namespace opennav_docking_core
155 
156 #endif // OPENNAV_DOCKING_CORE__CHARGING_DOCK_HPP_
Abstract interface for a charging dock for the docking framework.
virtual void cleanup()=0
Method to cleanup resources used on shutdown.
virtual bool isCharger()
Gets if this is a charging-typed dock.
virtual bool hasStoppedCharging()=0
Similar to isCharging() but called when undocking.
virtual void activate()=0
Method to active Behavior and any threads involved in execution.
virtual bool isCharging()=0
Are we charging? If a charge dock requires any sort of negotiation to begin charging,...
virtual geometry_msgs::msg::PoseStamped getStagingPose(const geometry_msgs::msg::Pose &pose, const std::string &frame)=0
Method to obtain the dock's staging pose. This method should likely be using TF and the dock's pose i...
virtual bool disableCharging()=0
Undocking while current is still flowing can damage a charge dock so some charge docks provide the ab...
virtual ~ChargingDock()
Virtual destructor.
virtual void deactivate()=0
Method to deactivate Behavior and any threads involved in execution.
virtual bool getRefinedPose(geometry_msgs::msg::PoseStamped &pose, std::string id)=0
Method to obtain the refined pose of the dock, usually based on sensors.
virtual bool isDocked()=0
Have we made contact with dock? This can be implemented in a variety of ways: by establishing communi...
DockDirection getDockDirection()
Indicates the direction of the dock. This is used to determine if the robot should drive forwards or ...
virtual void configure(const nav2::LifecycleNode::WeakPtr &parent, const std::string &name, std::shared_ptr< tf2_ros::Buffer > tf)=0
bool shouldRotateToDock()
Determines whether the robot should rotate 180ยบ to face away from the dock. For example,...