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

Display weed locations as white dots in camera augmentation on real robot #122

Closed
wants to merge 3 commits into from
Closed
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
13 changes: 8 additions & 5 deletions field_friend/interface/components/camera_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -232,14 +232,17 @@ 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 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)
if screen is not None:
svg += f'<circle cx="{int(screen.x/self.shrink_factor)}" cy="{int(screen.y/self.shrink_factor)}" r="5" fill="white" />'
svg += f'<text x="{int(screen.x/self.shrink_factor)}" y="{int(screen.y/self.shrink_factor)+16}" fill="black" font-size="9" text-anchor="middle">{plant.id[:4]}</text>'
Expand Down
Loading