-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·46 lines (37 loc) · 1.86 KB
/
main.py
File metadata and controls
executable file
·46 lines (37 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
import rosys
from nicegui import app, ui
from rosys.automation import Automator, automation_controls
from rosys.driving import Driver, Steerer, keyboard_control, robot_object
import feldfreund_devkit
from feldfreund_devkit.config import FeldfreundConfiguration, Secrets, config_from_id
from feldfreund_devkit.implement import ImplementDummy
from feldfreund_devkit.navigation import StraightLineNavigation
class System(feldfreund_devkit.System):
def __init__(self, config: FeldfreundConfiguration, secrets: Secrets) -> None:
super().__init__(config, secrets=secrets)
self.steerer = Steerer(self.feldfreund.wheels, speed_scaling=0.25)
self.driver = Driver(self.feldfreund.wheels, self.odometer, parameters=self.config.driver)
self.shape = rosys.geometry.Prism.default_robot_shape()
self.navigation = StraightLineNavigation(implement=ImplementDummy(),
driver=self.driver,
pose_provider=self.odometer)
self.automator = Automator(self.steerer, on_interrupt=self.feldfreund.stop, notify=False)
self.automator.default_automation = self.navigation.start
def startup() -> None:
secrets = Secrets()
config = config_from_id('example', secrets=secrets)
system = System(config, secrets).persistent()
@ui.page('/')
def ui_content() -> None:
keyboard_control(system.steerer)
with ui.scene():
robot_object(system.shape, system.odometer)
with ui.card():
ui.label('hold SHIFT to steer with the keyboard arrow keys or use the automation controls')
with ui.row():
system.navigation.settings_ui()
with ui.row():
automation_controls(system.automator)
app.on_startup(startup)
ui.run(title='Feldfreund_devkit')