From 5ee44b47475befc28f8f93581befa11d673d891e Mon Sep 17 00:00:00 2001 From: Rodja Trappe Date: Wed, 17 Jul 2024 05:43:00 +0200 Subject: [PATCH 1/3] display weed locations on real robot --- .../interface/components/camera_card.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/field_friend/interface/components/camera_card.py b/field_friend/interface/components/camera_card.py index d086d303..5da11c9f 100644 --- a/field_friend/interface/components/camera_card.py +++ b/field_friend/interface/components/camera_card.py @@ -10,8 +10,8 @@ from field_friend.automations.implements.weeding_implement import WeedingImplement -from ...automations import PlantLocator, Puncher -from ...hardware import FieldFriend, FlashlightPWM, FlashlightPWMV2, Tornado, ZAxis +from ...hardware import FlashlightPWM, FlashlightPWMV2, Tornado, ZAxis +from ...vision import SimulatedCam from .calibration_dialog import calibration_dialog if TYPE_CHECKING: @@ -232,17 +232,20 @@ def build_svg_for_implement(self) -> str: def build_svg_for_plant_provider(self) -> str: if self.camera is None or self.camera.calibration is None: return '' - if self.system.is_real: - return '' # NOTE: until https://github.com/zauberzeug/rosys/discussions/130 is resolved and integrated real robots will have problems with reverse projection position = rosys.geometry.Point(x=self.camera.calibration.extrinsics.translation[0], y=self.camera.calibration.extrinsics.translation[1]) svg = '' for plant in self.plant_provider.get_relevant_weeds(position): position_3d = rosys.geometry.Point3d(x=plant.position.x, y=plant.position.y, z=0) - screen = self.camera.calibration.project_to_image(position_3d) - if screen is not None: - svg += f'' - svg += f'{plant.id[:4]}' + if isinstance(self.camera, SimulatedCam): + screen = self.camera.calibration.project_to_image(position_3d) + else: + # TODO remove this when RoSys supports multiple extrinsics (see https://github.com/zauberzeug/rosys/discussions/130) + relative = self.system.odometer.prediction.relative_point(position) + screen = self.odometer.prediction.transform(relative.projection()) + if screen is not None: + svg += f'' + svg += f'{plant.id[:4]}' return svg # async def save_last_image(self) -> None: From 3351f1767b9b2b959730ad50e8f69b085d1c4a24 Mon Sep 17 00:00:00 2001 From: Pascal Schade Date: Wed, 17 Jul 2024 09:43:59 +0200 Subject: [PATCH 2/3] fix indentation --- field_friend/interface/components/camera_card.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/field_friend/interface/components/camera_card.py b/field_friend/interface/components/camera_card.py index 5da11c9f..17e253d1 100644 --- a/field_friend/interface/components/camera_card.py +++ b/field_friend/interface/components/camera_card.py @@ -243,9 +243,9 @@ def build_svg_for_plant_provider(self) -> str: # TODO remove this when RoSys supports multiple extrinsics (see https://github.com/zauberzeug/rosys/discussions/130) relative = self.system.odometer.prediction.relative_point(position) screen = self.odometer.prediction.transform(relative.projection()) - if screen is not None: - svg += f'' - svg += f'{plant.id[:4]}' + if screen is not None: + svg += f'' + svg += f'{plant.id[:4]}' return svg # async def save_last_image(self) -> None: From e4bde476d541ed1f030a9e1179b7c3697c6b691d Mon Sep 17 00:00:00 2001 From: Rodja Trappe Date: Wed, 17 Jul 2024 10:35:03 +0200 Subject: [PATCH 3/3] remove projection call --- field_friend/interface/components/camera_card.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/field_friend/interface/components/camera_card.py b/field_friend/interface/components/camera_card.py index 17e253d1..211b9769 100644 --- a/field_friend/interface/components/camera_card.py +++ b/field_friend/interface/components/camera_card.py @@ -242,7 +242,7 @@ def build_svg_for_plant_provider(self) -> str: else: # TODO remove this when RoSys supports multiple extrinsics (see https://github.com/zauberzeug/rosys/discussions/130) relative = self.system.odometer.prediction.relative_point(position) - screen = self.odometer.prediction.transform(relative.projection()) + screen = self.odometer.prediction.transform(relative) if screen is not None: svg += f'' svg += f'{plant.id[:4]}'