auto_dock.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015, Fetch Robotics, Inc.
3  * Author: Michael Ferguson, Griswald Brooks
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef FETCH_AUTO_DOCK_H
20 #define FETCH_AUTO_DOCK_H
21 
22 // Custom Includes.
25 
26 // ROS Includes.
27 #include <ros/ros.h>
30 
31 // Fetch Includes.
32 #include <fetch_driver_msgs/RobotState.h>
33 #include <fetch_driver_msgs/DisableChargingAction.h>
34 #include <fetch_auto_dock_msgs/DockAction.h>
35 #include <fetch_auto_dock_msgs/UndockAction.h>
36 
38 {
42 
43 public:
47  AutoDocking();
48 
49  ~AutoDocking();
50 
51 private:
56  void stateCallback(const fetch_driver_msgs::RobotStateConstPtr& state);
57 
62  void dockCallback(const fetch_auto_dock_msgs::DockGoalConstPtr& goal);
63 
69  bool continueDocking(fetch_auto_dock_msgs::DockResult& result);
70 
77 
82  void undockCallback(const fetch_auto_dock_msgs::UndockGoalConstPtr& goal);
83 
87  void initDockTimeout();
88 
93  bool isDockingTimedOut();
94 
103 
110  double backupDistance();
111 
120  bool isApproachBad(double & dock_yaw);
121 
129  bool lockoutCharger(unsigned seconds);
130 
131  // Configuration Constants.
132  int NUM_OF_RETRIES_; // Number of times the robot gets to attempt
133  // docking before failing.
134  double DOCK_CONNECTOR_CLEARANCE_DISTANCE_; // The amount to back off in order to clear the
135  // dock connector.
136  double DOCKED_DISTANCE_THRESHOLD_; // Threshold distance that indicates that the
137  // robot might be docked.
138  // Nodes and servers.
140  dock_server_t dock_; // Action server to manage docking.
141  undock_server_t undock_; // Action server to manage undocking.
142  charge_lockout_client_t charge_lockout_; // Action client to request charger lockouts.
143 
144  // Helper objects.
145  BaseController controller_; // Drives the robot during docking and undocking phases.
146  DockPerception perception_; // Used to detect dock pose.
147 
148  // Subscribe to robot_state, determine if charging
150  bool charging_;
151 
152  // Failure detection
153  double abort_distance_; // Distance below which to check abort criteria.
154  double abort_threshold_; // Y-offset that triggers abort.
155  double abort_angle_; // Angle offset that triggers abort.
156  double correction_angle_; // Yaw correction angle the robot should use to line up with the dock.
157  double backup_limit_; // Maximum distance the robot will backup when trying to retry.
158  // Based on range of initial dock pose estimate.
159  bool aborting_; // If the robot realizes it won't be sucessful, it needs to abort.
160  int num_of_retries_; // The number of times the robot gets to abort before failing.
161  // This variable will count down.
162  bool cancel_docking_; // Signal that docking has failed and the action server should abort the goal.
163  ros::Time deadline_docking_; // Time when the docking times out.
164  ros::Time deadline_not_charging_; // Time when robot gives up on the charge state and retries docking.
165  bool charging_timeout_set_; // Flag to indicate if the deadline_not_charging has been set.
166 };
167 
168 #endif // FETCH_AUTO_DOCK_H
AutoDocking()
Autodocking constructor. Object builds action servers for docking and undocking.
Definition: auto_dock.cpp:28
int num_of_retries_
Definition: auto_dock.h:160
dock_server_t dock_
Definition: auto_dock.h:140
double abort_distance_
Definition: auto_dock.h:153
void undockCallback(const fetch_auto_dock_msgs::UndockGoalConstPtr &goal)
Method to execute the undocking behavior.
Definition: auto_dock.cpp:413
bool cancel_docking_
Definition: auto_dock.h:162
bool lockoutCharger(unsigned seconds)
Method to disable the charger for a finite amount of time.
Definition: auto_dock.cpp:382
double correction_angle_
Definition: auto_dock.h:156
double backup_limit_
Definition: auto_dock.h:157
void checkDockChargingConditions()
Method to see if the robot seems to be docked but not charging. If the robot does seem to be docked a...
Definition: auto_dock.cpp:233
void executeBackupSequence(ros::Rate &r)
Method to back the robot up under the abort conditon. Once complete, the method resets the abort flag...
Definition: auto_dock.cpp:294
bool isDockingTimedOut()
Method checks to see if we have run out of time or retries.
Definition: auto_dock.cpp:277
BaseController controller_
Definition: auto_dock.h:145
double DOCK_CONNECTOR_CLEARANCE_DISTANCE_
Definition: auto_dock.h:134
double abort_threshold_
Definition: auto_dock.h:154
bool isApproachBad(double &dock_yaw)
Method to check approach abort conditions. If we are close to the dock but the robot is too far off s...
Definition: auto_dock.cpp:356
void dockCallback(const fetch_auto_dock_msgs::DockGoalConstPtr &goal)
Method to execute the docking behavior.
Definition: auto_dock.cpp:76
double DOCKED_DISTANCE_THRESHOLD_
Definition: auto_dock.h:136
ros::Subscriber state_
Definition: auto_dock.h:149
bool aborting_
Definition: auto_dock.h:159
bool continueDocking(fetch_auto_dock_msgs::DockResult &result)
Method that checks success or failure of docking.
Definition: auto_dock.cpp:199
bool charging_timeout_set_
Definition: auto_dock.h:165
void stateCallback(const fetch_driver_msgs::RobotStateConstPtr &state)
Method to update the robot charge state.
Definition: auto_dock.cpp:62
void initDockTimeout()
Method sets the docking deadline and number of retries.
Definition: auto_dock.cpp:267
charge_lockout_client_t charge_lockout_
Definition: auto_dock.h:142
bool charging_
Definition: auto_dock.h:150
ros::Time deadline_not_charging_
Definition: auto_dock.h:164
DockPerception perception_
Definition: auto_dock.h:146
double backupDistance()
Method to compute the distance the robot should backup when attemping a docking correction. Method uses a number of state variables in the class to compute distance. TODO(enhancement): Should these be parameterized instead?
Definition: auto_dock.cpp:325
ros::Time deadline_docking_
Definition: auto_dock.h:163
double abort_angle_
Definition: auto_dock.h:155
actionlib::SimpleActionServer< fetch_auto_dock_msgs::DockAction > dock_server_t
Definition: auto_dock.h:40
actionlib::SimpleActionClient< fetch_driver_msgs::DisableChargingAction > charge_lockout_client_t
Definition: auto_dock.h:39
actionlib::SimpleActionServer< fetch_auto_dock_msgs::UndockAction > undock_server_t
Definition: auto_dock.h:41
undock_server_t undock_
Definition: auto_dock.h:141
ros::NodeHandle nh_
Definition: auto_dock.h:139
int NUM_OF_RETRIES_
Definition: auto_dock.h:132


fetch_open_auto_dock
Author(s): Michael Ferguson, Griswald Brooks
autogenerated on Mon Feb 28 2022 22:21:37