-
Notifications
You must be signed in to change notification settings - Fork 4
/
ecal_being.py
46 lines (34 loc) · 1.16 KB
/
ecal_being.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
40
41
42
43
44
45
46
#!/usr/local/python3
"""Being for ECAL workshop May 2021."""
from being.behavior import Behavior
from being.awakening import awake
from being.logging import setup_logging, suppress_other_loggers
from being.motion_player import MotionPlayer
from being.motors import LinearMotor
from being.resources import manage_resources
from being.sensors import SensorGpio
NODE_IDS = [1, 2]
"""Motor ids to use."""
def look_for_motors():
"""Look which motors for NODE_IDS are available."""
for nodeId in NODE_IDS:
try:
yield LinearMotor(nodeId, length=0.100)
except RuntimeError:
pass
#setup_logging()
#suppress_other_loggers()
#logging.basicConfig(level=0)
with manage_resources():
# Initialize being blocks
motors = list(look_for_motors())
if not motors:
raise RuntimeError('Found no motors!')
sensor = SensorGpio(channel=6)
behavior = Behavior.from_config('behavior.json')
motionPlayer = MotionPlayer(ndim=len(motors))
# Make block connections
sensor | behavior | motionPlayer
for output, motor in zip(motionPlayer.positionOutputs, motors):
output.connect(motor.input)
awake(behavior)