29 dock_(nh_,
"dock",
boost::bind(&
AutoDocking::dockCallback, this, _1), false),
30 undock_(nh_,
"undock",
boost::bind(&
AutoDocking::undockCallback, this, _1), false),
31 charge_lockout_(
"charge_lockout", true),
35 num_of_retries_(NUM_OF_RETRIES_),
36 cancel_docking_(true),
37 charging_timeout_set_(false)
73 charging_ = (state->charger.supply_voltage > 30.0);
78 fetch_auto_dock_msgs::DockFeedback feedback;
79 fetch_auto_dock_msgs::DockResult result;
82 result.docked =
false;
88 if (goal->use_move_base)
91 ROS_ERROR(
"Docking failure: use_move_base not yet supported");
105 geometry_msgs::PoseStamped dock_pose_base_link;
112 "Docking failed: Initial dock not found.");
119 if (!std::isfinite(dock_yaw))
127 backup_limit_ = sqrt(pow(dock_pose_base_link.pose.position.x, 2) + pow(dock_pose_base_link.pose.position.y, 2));
204 result.docked =
true;
207 "Docking success: Robot has docked");
214 ROS_WARN(
"Docking failed: timed out");
221 ROS_WARN(
"Docking failure: preempted");
236 geometry_msgs::PoseStamped dock_pose_base_link;
328 double distance = 1.0;
337 retry_constant = std::max(1.0, std::min(2.0, retry_constant));
338 distance *= retry_constant;
359 geometry_msgs::PoseStamped dock_pose_base_link;
390 fetch_driver_msgs::DisableChargingGoal lockout_goal;
420 fetch_auto_dock_msgs::UndockFeedback feedback;
421 fetch_auto_dock_msgs::UndockResult result;
422 result.undocked =
false;
426 double turn = goal->rotate_in_place ? 3.1 : 0.0;
442 ROS_WARN_NAMED(
"autodock_undock_callback",
"Undocking preempted");
450 result.undocked =
true;
469 ROS_WARN_NAMED(
"autodock_undock_callback",
"Undocking failed: timed out");
480 ROS_WARN_NAMED(
"autodock_undock_callback",
"Undocking failed: ROS no longer OK");
483 int main(
int argc,
char** argv)
bool approach(const geometry_msgs::PoseStamped &target)
Implements something loosely based on "A Smooth Control Law for Graceful Motion of Differential Wheel...
AutoDocking()
Autodocking constructor. Object builds action servers for docking and undocking.
void stop()
send stop command to robot base
void publishFeedback(const FeedbackConstPtr &feedback)
bool backup(double distance, double rotate_distance)
Back off dock, then rotate. Robot is first reversed by the prescribed distance, and then rotates with...
void undockCallback(const fetch_auto_dock_msgs::UndockGoalConstPtr &goal)
Method to execute the undocking behavior.
#define ROS_ERROR_STREAM_NAMED(name, args)
#define ROS_WARN_NAMED(name,...)
bool lockoutCharger(unsigned seconds)
Method to disable the charger for a finite amount of time.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void checkDockChargingConditions()
Method to see if the robot seems to be docked but not charging. If the robot does seem to be docked a...
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
static double getYaw(const Quaternion &bt_q)
void executeBackupSequence(ros::Rate &r)
Method to back the robot up under the abort conditon. Once complete, the method resets the abort flag...
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool isDockingTimedOut()
Method checks to see if we have run out of time or retries.
BaseController controller_
int main(int argc, char **argv)
bool getPose(geometry_msgs::PoseStamped &pose, std::string frame="")
Get the pose of the dock.
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
double DOCK_CONNECTOR_CLEARANCE_DISTANCE_
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...
void dockCallback(const fetch_auto_dock_msgs::DockGoalConstPtr &goal)
Method to execute the docking behavior.
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
#define ROS_DEBUG_NAMED(name,...)
bool getCommand(geometry_msgs::Twist &command)
Get the last command sent.
double DOCKED_DISTANCE_THRESHOLD_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
bool continueDocking(fetch_auto_dock_msgs::DockResult &result)
Method that checks success or failure of docking.
bool charging_timeout_set_
void stateCallback(const fetch_driver_msgs::RobotStateConstPtr &state)
Method to update the robot charge state.
void initDockTimeout()
Method sets the docking deadline and number of retries.
charge_lockout_client_t charge_lockout_
ros::Time deadline_not_charging_
DockPerception perception_
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?
bool isPreemptRequested()
def normalize_angle(angle)
ros::Time deadline_docking_
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
bool start(const geometry_msgs::PoseStamped &pose)
Start dock detection.
bool stop()
Stop tracking the dock.
#define ROS_WARN_STREAM_NAMED(name, args)