Skip to content

Commit

Permalink
feat: Docking behavior fixes (#26)
Browse files Browse the repository at this point in the history
Wait for GPS in docking approach.

If docking approach fails, it's not safe to undock, so just retry docking.
Reset retry count after docking approach.

When starting mowing, only undock if docked, otherwise just start mowing.

If docking needed, e.g low battery, do not abort the current behaviour if
it's already docking/undocking.
  • Loading branch information
olliewalsh authored May 3, 2023
1 parent b129ec5 commit 8df3b38
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/mower_logic/src/mower_logic/behaviors/DockingBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ std::string DockingBehavior::state_name() {
}

Behavior *DockingBehavior::execute() {
while(!isGPSGood){
ROS_WARN_STREAM("Waiting for good GPS");
ros::Duration(10.0).sleep();
}

bool approachSuccess = approach_docking_point();

Expand All @@ -181,14 +185,17 @@ Behavior *DockingBehavior::execute() {

retryCount++;
if(retryCount <= config.docking_retry_count) {
ROS_ERROR("Retrying docking");
return &UndockingBehavior::RETRY_INSTANCE;
ROS_ERROR("Retrying docking approach");
return &DockingBehavior::INSTANCE;
}

ROS_ERROR("Giving up on docking");
return &IdleBehavior::INSTANCE;
}

// Reset retryCount
reset();

// Disable GPS
inApproachMode = false;
setGPS(false);
Expand Down
5 changes: 4 additions & 1 deletion src/mower_logic/src/mower_logic/behaviors/IdleBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ Behavior *IdleBehavior::execute() {
if(last_status.v_charge > 5.0) {
ROS_INFO_STREAM("Currently inside the docking station, we set the robot's pose to the docks pose.");
setRobotPose(docking_pose_stamped.pose);
return &UndockingBehavior::INSTANCE;
}
return &UndockingBehavior::INSTANCE;
// Not docked, so just mow
setGPS(true);
return &MowingBehavior::INSTANCE;
}

if(start_area_recorder) {
Expand Down
6 changes: 5 additions & 1 deletion src/mower_logic/src/mower_logic/mower_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,11 @@ void checkSafety(const ros::TimerEvent &timer_event) {
dockingNeeded = true;
}

if (dockingNeeded) {
if (
dockingNeeded &&
currentBehavior != &DockingBehavior::INSTANCE &&
currentBehavior != &UndockingBehavior::RETRY_INSTANCE
) {
abortExecution();
}
}
Expand Down

0 comments on commit 8df3b38

Please sign in to comment.