-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.py
executable file
·39 lines (35 loc) · 1.44 KB
/
main.py
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
#!/usr/bin/env python3
from nicegui import ui
import rosys
# setup
shape = rosys.geometry.Prism.default_robot_shape()
rosys.hardware.SerialCommunication.search_paths = ['/dev/ttyUSB0']
is_real = rosys.hardware.SerialCommunication.is_possible()
wheels: rosys.hardware.Wheels
robot: rosys.hardware.Robot
if is_real:
communication = rosys.hardware.SerialCommunication()
robot_brain = rosys.hardware.RobotBrain(communication)
can = rosys.hardware.CanHardware(robot_brain)
wheels = rosys.hardware.WheelsHardware(robot_brain,
can=can,
left_can_address=0x100,
right_can_address=0x000,
m_per_tick=0.01571,
width=0.207,
is_right_reversed=True)
robot = rosys.hardware.RobotHardware([can, wheels], robot_brain)
else:
wheels = rosys.hardware.WheelsSimulation()
robot = rosys.hardware.RobotSimulation([wheels])
odometer = rosys.driving.Odometer(wheels)
steerer = rosys.driving.Steerer(wheels)
# ui
rosys.driving.keyboard_control(steerer)
with ui.scene():
rosys.driving.robot_object(shape, odometer)
ui.label('hold SHIFT to steer with the keyboard arrow keys')
if is_real:
ui.button('configure microcontroller', on_click=robot_brain.configure).props('outline')
# start
ui.run(title='RoSys')