Skip to content

Commit

Permalink
feat: Automatic mow angle increment (#45)
Browse files Browse the repository at this point in the history
* Semi automatic mowing (#1)

* feat: add semi-automatic mode

* updated logic based on PR comments, shared_state obj proposal

* use shared_ptr for the shared state object

* minor improvements

* added min/max to automatic_mode parm

* feat: add automatic mowing angle increment

Signed-off-by: Tom Marek <[email protected]>

* remove a typo

---------

Signed-off-by: Tom Marek <[email protected]>
  • Loading branch information
tommarek authored Jul 19, 2023
1 parent 199d372 commit 937caac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mower_logic/cfg/MowerLogic.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gen.add("outline_count", int_t, 0, "Outline count to mow before filling", 3, 0,
gen.add("outline_offset", double_t, 0, "Additional outer outline offset, use positive values for safety, negative values to enlarge the area", 0.0, -1.0, 1.0)
gen.add("mow_angle_offset", double_t, 0, "Mowing angle offset", 0, -180, 180)
gen.add("mow_angle_offset_is_absolute", bool_t, 0, "If true then the offset is relative to East, if false then the offset is relative to the auto-detected angle.", False)
gen.add("mow_angle_increment", double_t, 0, "Mowing angle automatic increment. Will be added to the offset every time the entire map is finished", 0, 0, 180)
gen.add("tool_width", double_t, 0, "Width of the mower", 0.14, 0.1, 2)
gen.add("enable_mower", bool_t, 0, "True to enable mow motor", False)
gen.add("manual_pause_mowing", bool_t, 0, "True to disable mowing automatically", False)
Expand Down
7 changes: 7 additions & 0 deletions src/mower_logic/src/mower_logic/behaviors/MowingBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,17 @@ void MowingBehavior::reset() {
currentMowingPaths.clear();
auto config = getConfig();
config.current_area = 0;

if (config.automatic_mode == eAutoMode::SEMIAUTO) {
ROS_INFO_STREAM("MowingBehavior: Finished semiautomatic task");
shared_state->active_semiautomatic_task = false;
}

// increment mowing angle offset and return into the <-180, 180> range
config.mow_angle_offset = std::fmod(config.mow_angle_offset + config.mow_angle_increment + 180, 360);
if (config.mow_angle_offset < 0) config.mow_angle_offset += 360;
config.mow_angle_offset -= 180;

setConfig(config);
}

Expand Down
2 changes: 2 additions & 0 deletions src/open_mower/config/mower_config.sh.example
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export OM_OUTLINE_COUNT=4
# Mowing angle offset -180 deg - +180 deg, 0 = east, -90 = north. If mowing angle offset is not absolute it gets added to the auto detected angle which is set by the first 2 m of recorded outline.
export OM_MOWING_ANGLE_OFFSET=0
export OM_MOWING_ANGLE_OFFSET_IS_ABSOLUTE=False
# The increment value will automatically add specified number of degrees to the mowing angle everytime the whole map is finished
export OM_MOWING_ANGLE_INCREMENT=0

# The width of mowing paths.
# Choose it smaller than your actual mowing tool in order to have some overlap.
Expand Down
1 change: 1 addition & 0 deletions src/open_mower/launch/open_mower.launch
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<param name="outline_offset" value="$(env OM_OUTLINE_OFFSET)"/>
<param name="mow_angle_offset" value="$(optenv OM_MOWING_ANGLE_OFFSET 0)"/>
<param name="mow_angle_offset_is_absolute" value="$(optenv OM_MOWING_ANGLE_OFFSET_IS_ABSOLUTE False)"/>
<param name="mow_angle_increment" value="$(optenv OM_MOWING_ANGLE_INCREMENT 0)"/>
<param name="battery_full_voltage" value="$(env OM_BATTERY_FULL_VOLTAGE)"/>
<param name="motor_hot_temperature" value="$(env OM_MOWING_MOTOR_TEMP_HIGH)"/>
<param name="motor_cold_temperature" value="$(env OM_MOWING_MOTOR_TEMP_LOW)"/>
Expand Down

0 comments on commit 937caac

Please sign in to comment.