Skip to content

Commit

Permalink
cleaning up get_nearest_row
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBaecker committed Dec 2, 2024
1 parent b19a739 commit 94c57a9
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions field_friend/automations/navigation/field_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ 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}')
try:
self.row_index = next(i for i, r in enumerate(self.rows_to_work_on) if row.id == r.id)
return self.rows_to_work_on[self.row_index]
except StopIteration:
if row not in self.rows_to_work_on:
rosys.notify('Please place the robot in front of a selected bed\'s row', 'negative')
return None
return None
self.row_index = next(i for i, r in enumerate(self.rows_to_work_on) if row.id == r.id)
return self.rows_to_work_on[self.row_index]

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

0 comments on commit 94c57a9

Please sign in to comment.