Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use GNSS RTK in simulation #188

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion field_friend/localization/gnss_simulation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional

import numpy as np
import rosys
from rosys.geometry import Pose

Expand Down Expand Up @@ -27,7 +28,7 @@ async def _create_new_record(self) -> Optional[GNSSRecord]:
new_position = GeoPoint(lat=51.983159, long=7.434212)
else:
new_position = localization.reference.shifted(pose.point)
record = GNSSRecord(timestamp=pose.time, location=new_position)
record = GNSSRecord(timestamp=pose.time, location=new_position, heading=-np.rad2deg(pose.yaw))
record.gps_qual = self.gps_quality
record.mode = self.mode
await rosys.sleep(0.1) # NOTE simulation does not be so fast and only eats a lot of cpu time
Expand Down
6 changes: 2 additions & 4 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,20 @@ async def test_follow_crops_outlier_last(system: System, detector: rosys.vision.


async def test_follow_crops_with_slippage(system: System, detector: rosys.vision.DetectorSimulation):
end = rosys.geometry.Point(x=0, y=0)
for i in range(20):
x = i/10.0
p = rosys.geometry.Point3d(x=x, y=(x/3) ** 3, z=0)
p = system.odometer.prediction.transform3d(p)
detector.simulated_objects.append(rosys.vision.SimulatedObject(category_name='maize', position=p))
end = p.projection()
system.gnss.min_seconds_between_updates = 1
system.gnss.ensure_gnss = True
system.current_navigation = system.follow_crops_navigation
assert isinstance(system.field_friend.wheels, rosys.hardware.WheelsSimulation)
system.field_friend.wheels.slip_factor_right = 0.05
system.automator.start()
await forward(until=lambda: system.automator.is_running)
await forward(until=lambda: system.odometer.prediction.distance(end) < 0.2)
assert system.odometer.prediction.yaw_deg == pytest.approx(25.0, abs=5.0)
await forward(until=lambda: system.automator.is_stopped)
assert system.odometer.prediction.yaw_deg == pytest.approx(16.5, abs=0.2)


async def test_approaching_first_row(system: System, field: Field):
Expand Down
Loading