-
Notifications
You must be signed in to change notification settings - Fork 9
/
vector_keep_still.py
22 lines (20 loc) · 954 Bytes
/
vector_keep_still.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import time
from multiprocessing.dummy import Pool
import anki_vector
import vector_utils as utils
def reserve_control(args):
robot_index, (robot_name, robot_serial) = args
try:
anki_vector.behavior.ReserveBehaviorControl(serial=robot_serial)._conn.connect()
with anki_vector.Robot(serial=robot_serial, default_logging=False) as robot:
robot.behavior.set_head_angle(anki_vector.util.degrees(0))
print('Connected to {} ({})'.format(robot_name, robot_index))
except anki_vector.exceptions.VectorNotFoundException:
print('Could not find {} ({})'.format(robot_name, robot_index))
except anki_vector.exceptions.VectorControlTimeoutException:
print('Could not connect to {} ({})'.format(robot_name, robot_index))
robot_serials = utils.get_robot_serials()
with Pool(len(robot_serials)) as p:
p.map(reserve_control, enumerate(sorted(robot_serials.items())))
while True:
time.sleep(1)