Skip to content

Commit

Permalink
test navigation + weeding with failing gnss
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Jul 17, 2024
1 parent 6af88a4 commit 0238113
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from field_friend.automations import Field
from field_friend.automations.implements import Recorder
from field_friend.automations.navigation import StraightLineNavigation
from field_friend.localization import GnssSimulation


async def test_straight_line(system: System):
Expand All @@ -22,6 +23,30 @@ async def test_straight_line(system: System):
assert system.odometer.prediction.point.x == pytest.approx(system.straight_line_navigation.length, abs=0.1)


async def test_straight_line_with_failing_gnss(system: System, gnss: GnssSimulation, detector: rosys.vision.DetectorSimulation):
async def empty():
return None
create_new_record = gnss._create_new_record
detector.simulated_objects.append(rosys.vision.SimulatedObject(category_name='thistle',
position=rosys.geometry.Point3d(x=0.1, y=0, z=0)))
detector.simulated_objects.append(rosys.vision.SimulatedObject(category_name='thistle',
position=rosys.geometry.Point3d(x=0.16, y=0, z=0)))
detector.simulated_objects.append(rosys.vision.SimulatedObject(category_name='thistle',
position=rosys.geometry.Point3d(x=0.26, y=0, z=0)))
detector.simulated_objects.append(rosys.vision.SimulatedObject(category_name='thistle',
position=rosys.geometry.Point3d(x=0.36, y=0, z=0)))
system.current_implement = system.implements['Weed Screw']
system.automator.start()
await forward(10)
gnss._create_new_record = empty # type: ignore
await forward(0.5)
gnss._create_new_record = create_new_record
await forward(20)
assert system.automator.is_running
assert len(detector.simulated_objects) == 0
assert system.odometer.prediction.yaw_deg == pytest.approx(0, abs=1)


async def test_follow_crops(system: System, detector: rosys.vision.DetectorSimulation):
for i in range(10):
x = i/10.0
Expand Down

0 comments on commit 0238113

Please sign in to comment.