-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdoctest.txt
73 lines (58 loc) · 1.95 KB
/
doctest.txt
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
This is a doctest for various functionality of the usb2ax module
>>> import usb2ax
>>> dxl = usb2ax.Controller(100)
Traceback (most recent call last):
InitError: There was a problem connecting to the USB2AX at /dev/ttyACM100
>>> dxl = usb2ax.Controller(fix_sync_read_delay=True)
>>> 1 in dxl.servo_list
True
>>> 100 not in dxl.servo_list
True
>>> 1 in dxl.servo_map.keys()
True
>>> dxl.servo_models[1]
'AX-12 '
>>> dxl.servo_map[1] is usb2ax.MMAP_AX
True
>>> dxl.sync_write( dxl.servo_list, "goal_position", [512]*len(dxl.servo_list) )
>>> real_positions = dxl.sync_read( dxl.servo_list, "present_position" )
>>> len(real_positions) == len(dxl.servo_list)
True
>>> dxl.write(1,"goal_position",512)
>>> dxl.write(1,"blah",5000)
Traceback (most recent call last):
UnknownParameterError: Servo 1 is a AX-12 which does not support the blah parameter
You shouldn't be able to write to the model_no parameter:
>>> dxl.write(1,"model_no",12)
Traceback (most recent call last):
InvalidWriteParameterError
Move the servo, it should update its position in response
>>> from time import sleep
>>> dxl.write(1,"goal_position",450)
>>> sleep(0.5)
>>> dxl.read(1,"present_position") < 500
True
>>> dxl.write(1,"goal_position",550)
>>> sleep(0.5)
>>> dxl.read(1,"present_position") > 500
True
Reset the servo, this should cause it to get a bad return delay time
>>> dxl.reset(1)
>>> sleep(1.0)
>>> dxl.read(1,"return_delay_time")
250
>>> dxl.terminate()
>>> dxl = usb2ax.Controller(fix_sync_read_delay=False)
Now sync_read should fail
>>> dxl.sync_read([1],"present_position")
Traceback (most recent call last):
SyncReadError: You tried to sync read but some of your devices
are set to return too slowly. To fix this call initialize with
fix_sync_read_delay = True.
<BLANKLINE>
>>> dxl.terminate()
Calling with fix_sync_read_delay should fix it
>>> dxl = usb2ax.Controller(fix_sync_read_delay=True)
>>> dxl.sync_read([1],"present_position")[0] in range(540,560)
True
>>> dxl.terminate()