Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mower behavior skip path option added #60

Merged
merged 12 commits into from
Oct 27, 2023
19 changes: 18 additions & 1 deletion src/mower_logic/src/mower_logic/behaviors/MowingBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Behavior *MowingBehavior::execute() {

void MowingBehavior::enter() {
skip_area = false;
skip_path = false;
paused = aborted = false;

for(auto& a : actions) {
Expand Down Expand Up @@ -252,7 +253,7 @@ bool MowingBehavior::execute_mowing_plan() {
update_actions();
mowerEnabled = true;
}


auto &path = currentMowingPaths.front();
ROS_INFO_STREAM("MowingBehavior: Path segment length: " << path.path.poses.size() << " poses.");
Expand Down Expand Up @@ -363,6 +364,13 @@ bool MowingBehavior::execute_mowing_plan() {
skip_area = false;
return true;
}
if(skip_path)
{
currentMowingPaths.erase(currentMowingPaths.begin());
skip_path=false;
return true;
midevil marked this conversation as resolved.
Show resolved Hide resolved
}

if (aborted) {
ROS_INFO_STREAM("MowingBehavior: (MOW) ABORT was requested - stopping path execution.");
mbfClientExePath->cancelAllGoals();
Expand Down Expand Up @@ -489,11 +497,17 @@ MowingBehavior::MowingBehavior() {
skip_area_action.enabled = false;
skip_area_action.action_name = "Skip Area";

xbot_msgs::ActionInfo skip_path_action;
skip_path_action.action_id = "skip_path";
skip_path_action.enabled = false;
skip_path_action.action_name = "Skip Path";

actions.clear();
actions.push_back(pause_action);
actions.push_back(continue_action);
actions.push_back(abort_mowing_action);
actions.push_back(skip_area_action);
actions.push_back(skip_path_action);
}

void MowingBehavior::handle_action(std::string action) {
Expand All @@ -515,6 +529,9 @@ void MowingBehavior::handle_action(std::string action) {
} else if(action == "mower_logic:mowing/skip_area") {
ROS_INFO_STREAM("got skip_area command");
skip_area = true;
} else if(action == "mower_logic:mowing/skip_path") {
ROS_INFO_STREAM("got skip_path command");
skip_path = true;
}
update_actions();
}
1 change: 1 addition & 0 deletions src/mower_logic/src/mower_logic/behaviors/MowingBehavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class MowingBehavior : public Behavior {
std::vector<xbot_msgs::ActionInfo> actions;

bool skip_area;
bool skip_path;
bool create_mowing_plan(int area_index);

bool execute_mowing_plan();
Expand Down