15 #ifndef OPENNAV_DOCKING__SIMPLE_CHARGING_DOCK_HPP_
16 #define OPENNAV_DOCKING__SIMPLE_CHARGING_DOCK_HPP_
22 #include "std_srvs/srv/trigger.hpp"
23 #include "geometry_msgs/msg/pose_stamped.hpp"
24 #include "sensor_msgs/msg/battery_state.hpp"
25 #include "sensor_msgs/msg/joint_state.hpp"
26 #include "tf2_geometry_msgs/tf2_geometry_msgs.hpp"
27 #include "tf2/utils.hpp"
28 #include "nav2_ros_common/tf2_factories.hpp"
29 #include "nav2_ros_common/lifecycle_node.hpp"
31 #include "opennav_docking_core/charging_dock.hpp"
32 #include "opennav_docking/pose_filter.hpp"
34 namespace opennav_docking
53 const nav2::LifecycleNode::WeakPtr & parent,
54 const std::string & name, nav2::TransformBuffer::SharedPtr tf);
80 const geometry_msgs::msg::Pose & pose,
const std::string & frame);
87 virtual bool getRefinedPose(geometry_msgs::msg::PoseStamped & pose, std::string
id);
120 void jointStateCallback(
const sensor_msgs::msg::JointState::ConstSharedPtr & state);
123 nav2::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr dock_pose_sub_;
124 nav2::Publisher<geometry_msgs::msg::PoseStamped>::SharedPtr dock_pose_pub_;
125 nav2::Publisher<geometry_msgs::msg::PoseStamped>::SharedPtr filtered_dock_pose_pub_;
126 nav2::Publisher<geometry_msgs::msg::PoseStamped>::SharedPtr staging_pose_pub_;
128 geometry_msgs::msg::PoseStamped detected_dock_pose_;
131 geometry_msgs::msg::PoseStamped dock_pose_;
134 nav2::Subscription<sensor_msgs::msg::BatteryState>::SharedPtr battery_sub_;
136 bool use_battery_status_;
139 nav2::Subscription<sensor_msgs::msg::JointState>::SharedPtr joint_state_sub_;
140 std::vector<std::string> stall_joint_names_;
141 double stall_velocity_threshold_, stall_effort_threshold_;
145 bool use_external_detection_pose_;
146 double external_detection_timeout_;
147 tf2::Quaternion external_detection_rotation_;
148 double external_detection_translation_x_;
149 double external_detection_translation_y_;
152 std::shared_ptr<PoseFilter> filter_;
155 double charging_threshold_;
157 double docking_threshold_;
158 std::string base_frame_id_;
160 double staging_x_offset_;
161 double staging_yaw_offset_;
163 nav2::LifecycleNode::SharedPtr node_;
164 nav2::TransformBuffer::SharedPtr tf2_buffer_;
167 std::string detector_service_name_;
168 double detector_service_timeout_{5.0};
169 bool subscribe_toggle_{
false};
172 nav2::ServiceClient<std_srvs::srv::Trigger>::SharedPtr detector_client_;
175 bool detection_active_{
false};
176 bool initial_pose_received_{
false};
bool stopDetectionProcess() override
Stop external detection process.
virtual geometry_msgs::msg::PoseStamped getStagingPose(const geometry_msgs::msg::Pose &pose, const std::string &frame)
Method to obtain the dock's staging pose. This method should likely be using TF and the dock's pose i...
virtual bool disableCharging()
Undocking while current is still flowing can damage a charge dock so some charge docks provide the ab...
SimpleChargingDock()
Constructor.
void deactivate() override
Method to deactivate Behavior and any threads involved in execution.
void cleanup() override
Method to cleanup resources used on shutdown.
virtual bool isCharging()
Are we charging? If a charge dock requires any sort of negotiation to begin charging,...
virtual bool isDocked()
Have we made contact with dock? This can be implemented in a variety of ways: by establishing communi...
virtual bool hasStoppedCharging()
Similar to isCharging() but called when undocking.
bool startDetectionProcess() override
Start external detection process (service call + subscribe).
virtual bool getRefinedPose(geometry_msgs::msg::PoseStamped &pose, std::string id)
Method to obtain the refined pose of the dock, usually based on sensors.
void activate() override
Method to active Behavior and any threads involved in execution.
virtual void configure(const nav2::LifecycleNode::WeakPtr &parent, const std::string &name, nav2::TransformBuffer::SharedPtr tf)
Abstract interface for a charging dock for the docking framework.