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
2 changes: 2 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ on:
branches:
- 'main'
- 'releases/**'
- 'startinzone'
ClemensElflein marked this conversation as resolved.
Show resolved Hide resolved
tags:
- 'v*.*.*'
pull_request:
branches:
- 'main'
- 'startinzone'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to remove

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, thank you


# Allow to stop obsolete workflows
concurrency:
Expand Down
2 changes: 1 addition & 1 deletion src/mower_logic/cfg/MowerLogic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ gen.add("add_fake_obstacle", bool_t, 0, "True to add a fake obstacle to hopefull
gen.add("ignore_gps_errors", bool_t, 0, "True to ignore gps errors. USE ONLY FOR SIMULATION!", False)
gen.add("max_first_point_attempts", int_t, 0, "Maximum attempts to reach the first point of the mow path before trimming", 3, 1, 10)
gen.add("max_first_point_trim_attempts", int_t, 0, "After <max_first_point_attempts> we start to trim the path beginning this often", 3, 1, 10)

gen.add("clear_path_on_start", bool_t, 0, "True to reset current mowing path on start, useful to start in given area", False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

exit(gen.generate("mower_logic", "mower_logic", "MowerLogic"))
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 false;
}

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