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

Some formatting #123

Merged
merged 1 commit into from
Jul 17, 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: 1 addition & 2 deletions field_friend/automations/automation_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def __init__(self, system: 'System') -> None:
rosys.on_repeat(self.try_resume, 0.1)
rosys.on_repeat(self.check_field_bounds, 1.0)
if self.field_friend.bumper:
self.field_friend.bumper.BUMPER_TRIGGERED.register(
lambda name: self.pause(f'Bumper {name} was triggered'))
self.field_friend.bumper.BUMPER_TRIGGERED.register(lambda name: self.pause(f'Bumper {name} was triggered'))
self.gnss.GNSS_CONNECTION_LOST.register(lambda: self.pause('GNSS connection lost'))
self.gnss.RTK_FIX_LOST.register(lambda: self.pause('GNSS RTK fix lost'))

Expand Down
15 changes: 7 additions & 8 deletions field_friend/automations/plant_locator.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import asyncio
import logging
from typing import TYPE_CHECKING, Any, Optional
import aiohttp
from typing import TYPE_CHECKING, Any

import aiohttp
import rosys
from nicegui import ui
from nicegui.events import ValueChangeEventArguments
from rosys.vision import Autoupload

from ..vision import SimulatedCam
Expand Down Expand Up @@ -38,7 +36,7 @@ def __init__(self, system: 'System') -> None:
self.tags: list[str] = []
self.is_paused = True
self.autoupload: Autoupload = Autoupload.DISABLED
self.upload_images: bool = False
self.upload_images: bool = False
self.weed_category_names: list[str] = WEED_CATEGORY_NAME
self.crop_category_names: list[str] = CROP_CATEGORY_NAME
self.minimum_weed_confidence: float = MINIMUM_WEED_CONFIDENCE
Expand Down Expand Up @@ -140,14 +138,14 @@ def resume(self) -> None:

async def get_outbox_mode(self, port: int) -> bool:
# TODO: not needed right now, but can be used when this code is moved to the DetectorHardware code
url = f'http://localhost:{port}/outbox_mode'
url = f'http://localhost:{port}/outbox_mode'
async with aiohttp.request('GET', url) as response:
if response.status != 200:
self.log.error(f'Could not get outbox mode on port {port} - status code: {response.status}')
return None
response_text = await response.text()
return response_text == 'continuous_upload'

async def set_outbox_mode(self, value: bool, port: int) -> None:
url = f'http://localhost:{port}/outbox_mode'
async with aiohttp.request('PUT', url, data='continuous_upload' if value else 'stopped') as response:
Expand All @@ -172,7 +170,8 @@ def settings_ui(self) -> None:
.bind_value(self, 'autoupload') \
.classes('w-24').tooltip('Set the autoupload for the weeding automation')
if isinstance(self.detector, rosys.vision.DetectorHardware):
ui.checkbox('Upload images', on_change=self.request_backup).bind_value(self, 'upload_images').on('click', lambda: self.set_outbox_mode(value=self.upload_images, port=self.detector.port))
ui.checkbox('Upload images', on_change=self.request_backup).bind_value(self, 'upload_images') \
.on('click', lambda: self.set_outbox_mode(value=self.upload_images, port=self.detector.port))

@ui.refreshable
def chips():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gnss.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import pytest
from copy import deepcopy

import pytest
import rosys
from conftest import ROBOT_GEO_START_POSITION
from rosys.testing import assert_point, forward
Expand Down
Loading