Skip to content

Commit 65243c8

Browse files
committed
Test ordering of motor run_to_position commands
1 parent 74d7644 commit 65243c8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/motors.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@ def test_rotations(self):
1919
rotated = (pos2 - pos1) / 360
2020
self.assertLess(abs(rotated - 2), 0.5)
2121

22+
def test_nonblocking(self):
23+
"""Test motor nonblocking mode"""
24+
m = Motor('A')
25+
last = 0
26+
for delay in [1, 0]:
27+
for _ in range(3):
28+
m.run_to_position(90, blocking=False)
29+
time.sleep(delay)
30+
m.run_to_position(90, blocking=False)
31+
time.sleep(delay)
32+
m.run_to_position(90, blocking=False)
33+
time.sleep(delay)
34+
m.run_to_position(last, blocking=False)
35+
time.sleep(delay)
36+
# Wait for a bit, before reading last position
37+
time.sleep(7)
38+
pos1 = m.get_aposition()
39+
diff = abs((last - pos1 + 180) % 360 - 180)
40+
self.assertLess(diff, 10)
41+
2242
def test_position(self):
2343
"""Test motor goes to desired position"""
2444
m = Motor('A')

0 commit comments

Comments
 (0)