1
|
|
|
from itertools import cycle |
2
|
|
|
from curio import sleep |
3
|
|
|
from bricknil import attach, start |
4
|
|
|
from bricknil.hub import PoweredUpHub |
5
|
|
|
from bricknil.sensor import TrainMotor, VisionSensor, Button, LED, InternalTiltSensor, InternalMotor |
6
|
|
|
from bricknil.process import Process |
7
|
|
|
from bricknil.const import Color |
8
|
|
|
import logging |
9
|
|
|
|
10
|
|
|
@attach(Button, name='hub_btn', capabilities=['sense_press']) |
11
|
|
|
@attach(LED, name='hub_led') |
12
|
|
|
#@attach(VisionSensor, name='vision_sensor', capabilities=['sense_count', 'sense_distance']) |
13
|
|
|
@attach(TrainMotor, name='motor_l') |
14
|
|
|
class Robot(PoweredUpHub): |
15
|
|
|
|
16
|
|
|
async def hub_btn_change(self): |
17
|
|
|
pass |
18
|
|
|
async def vision_sensor_change(self): |
19
|
|
|
pass |
20
|
|
|
async def motor_l_change(self): |
21
|
|
|
pass |
22
|
|
|
async def motor_r_change(self): |
23
|
|
|
pass |
24
|
|
|
async def tilt_sensor_change(self): |
25
|
|
|
pass |
26
|
|
|
|
27
|
|
|
async def run(self): |
28
|
|
|
self.message_info("Running") |
29
|
|
|
await sleep(20) # Give it enough time to gather data |
30
|
|
|
self.message_info("Done") |
31
|
|
|
|
32
|
|
|
self.message_info(self.port_info) |
33
|
|
|
|
34
|
|
|
async def system(): |
35
|
|
|
hub = Robot('robot', query_port_info=True, ble_id='05c5e50e-71e9-4dcf-871a-7e5b93b36d6a') |
36
|
|
|
|
37
|
|
|
if __name__ == '__main__': |
38
|
|
|
logging.basicConfig(level=logging.INFO) |
39
|
|
|
start(system) |
40
|
|
|
|