Skip to content

Commit

Permalink
fixing nearest row
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBaecker committed Dec 2, 2024
1 parent 314f635 commit 44f627b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions field_friend/automations/navigation/field_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,9 @@ async def prepare(self) -> bool:
nearest_row = self.get_nearest_row()
if nearest_row is None:
return False
self.row_index = self.field.rows.index(nearest_row)
self._state = State.APPROACH_START_ROW
self.plant_provider.clear()

self.automation_watcher.start_field_watch(self.field.outline)

self.log.info(f'Activating {self.implement.name}...')
await self.implement.activate()
return True
Expand All @@ -105,11 +102,12 @@ def get_nearest_row(self) -> Row | None:
row = min(self.field.rows, key=lambda r: r.line_segment().line.foot_point(
self.odometer.prediction.point).distance(self.odometer.prediction.point))
self.log.info(f'Nearest row is {row.name}')
self.row_index = self.field.rows.index(row)
if not self.field_provider.is_row_in_selected_beds(self.row_index):
try:
self.row_index = next(i for i, row in enumerate(self.rows_to_work_on) if row.id == row.id)
return self.rows_to_work_on[self.row_index]
except StopIteration:
rosys.notify('Please place the robot in front of a selected bed\'s row', 'negative')
return None
return row
return None

def set_start_and_end_points(self):
assert self.field is not None
Expand Down

0 comments on commit 44f627b

Please sign in to comment.