Skip to content

Commit

Permalink
rework simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalzauberzeug committed Sep 30, 2024
1 parent 53bc39a commit 9eff6eb
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions field_friend/automations/navigation/field_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ async def _run_approaching_row_start(self) -> State:
await self._wait_for_gnss()
await self._drive_to_row()
await self._wait_for_gnss()
# self.log.info(f'Following "{self.current_row.name}"...')
self.plant_provider.clear()
self.set_start_and_end_points()
self.update_target()
if isinstance(self.detector, rosys.vision.DetectorSimulation) and not rosys.is_test:
self.create_simulation()
else:
self.plant_provider.clear()
return State.FOLLOWING_ROW

async def _run_following_row(self, distance: float) -> State:
Expand Down Expand Up @@ -261,14 +261,18 @@ def _set_field(self, field_id: str) -> None:

def create_simulation(self, crop_distance: float = 0.5) -> None:
self.detector.simulated_objects.clear()
self.plant_provider.clear()
if self.field is None:
return
for row in self.field.rows:
if len(row.points) < 2:
continue
cartesian = row.cartesian()
start = cartesian[0]
end = cartesian[-1]
# for row in self.field.rows:
# if len(row.points) < 2:
# continue
# cartesian = row.cartesian()
# start = cartesian[0]
# end = cartesian[-1]
if self.start_point is not None and self.end_point is not None:
start = self.start_point
end = self.end_point
length = start.distance(end)
# self.log.info(f'Adding plants from {start} to {end} (length {length:.1f} m)')
crop_count = length / crop_distance
Expand Down

0 comments on commit 9eff6eb

Please sign in to comment.