Skip to content

Commit 7832109

Browse files
committed
chro: update test file. make alone CHANGELOG
1 parent ad5c4d9 commit 7832109

File tree

10 files changed

+253
-64
lines changed

10 files changed

+253
-64
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,7 @@ log
66
.vscode/
77
pymycobot/__pycache__/
88

9-
test.py
9+
test.py
10+
port.txt
11+
record.txt
12+
test_test.py

CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# 2021.3.12
2+
3+
added more test file.
4+
5+
# 2021.2.5
6+
7+
relase v2.2.0
8+
9+
- add new method for girpper and IO.
10+
11+
# 2021.1.25
12+
13+
release v2.1.2
14+
15+
- refactor pymycobot
16+
- add Error class
17+
18+
# 2021.1.20
19+
20+
`v1.0.6` fix get_coords() error.
21+
22+
relase v2.0.0
23+
24+
# 2021.1.16
25+
26+
Upload to server, can use `pip` to installation now.
27+
28+
# 2021.1.9
29+
30+
Fix the API problem that `is_moving()` and other methods of mycobot cannot be used.
31+
32+
# 2021.1.8
33+
34+
Python API add new methods:
35+
36+
- `jog_angle()`
37+
- `jog_coord()`
38+
- `jog_stop()`
39+
40+
# 2020.12.30
41+
42+
Adding usage documents to Python API.
43+
44+
# 2020.12.29
45+
46+
Python API supports python2.7
47+
48+
Modify the serial port to manual setting, support the use of window.

setup.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -40,49 +40,3 @@
4040
python_requires= '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, != 3.4.*',
4141
)
4242

43-
change_log = '''
44-
# 2021.2.5
45-
46-
relase v2.2.0
47-
- add new method for girpper and IO.
48-
49-
# 2021.1.25
50-
51-
release v2.1.2
52-
- refactor pymycobot
53-
- add Error class
54-
55-
# 2021.1.20
56-
57-
`v1.0.6` fix get_coords() error.
58-
59-
relase v2.0.0
60-
61-
# 2021.1.16
62-
63-
Upload to server, can use `pip` to installation now.
64-
65-
# 2021.1.9
66-
67-
Fix the API problem that `is_moving()` and other methods of mycobot cannot be used.
68-
69-
# 2021.1.8
70-
71-
Python API add new methods:
72-
73-
- `jog_angle()`
74-
- `jog_coord()`
75-
- `jog_stop()`
76-
77-
# 2020.12.30
78-
79-
Adding usage documents to Python API.
80-
81-
# 2020.12.29
82-
83-
Python API supports python2.7
84-
85-
Modify the serial port to manual setting, support the use of window.
86-
87-
'''
88-

tests/basic_test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test(mycobot):
5656

5757
if __name__ == '__main__':
5858
print('''
59-
————————————————————————————————————————————
59+
--------------------------------------------
6060
| This file will test basic option method: |
6161
| set_led_color() |
6262
| send_angles() |
@@ -68,12 +68,14 @@ def test(mycobot):
6868
| get_coords() |
6969
| send_coord() |
7070
| set_free_mode() |
71-
————————————————————————————————————————————
71+
--------------------------------------------
7272
''')
7373
time.sleep(3)
7474
# port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
7575
# shell=True).decode()
76-
port = "/dev/cu.usbserial-0203B030"
76+
with open('./port.txt') as f:
77+
port = f.read().strip().replace('\n', '')
78+
print(port)
7779
# mycobot = MyCobot(port, debug=True)
7880
mycobot = MyCobot(port)
7981
test(mycobot)

tests/get_port.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@
1212
port='/dev/cu.usbserial-0213245D'
1313
'''
1414
plist = list(serial.tools.list_ports.comports())
15+
idx = 1
1516
for port in plist:
16-
print(port)
17+
print('{} : {}'.format(idx, port))
18+
idx += 1
19+
20+
_in = input('\nPlease input 1 - {} to choice:'.format(idx - 1))
21+
port = str(plist[int(_in) - 1]).split('-')[0].strip()
22+
print(port)
23+
with open('./port.txt', 'w') as f:
24+
f.write(port + '\n')

tests/jog_test.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import time
2+
from pymycobot.mycobot import MyCobot
3+
from pymycobot.genre import Angle, Coord
4+
5+
reset = [153.19, 137.81, -153.54, 156.79, 87.27, 13.62]
6+
zero = [0, 0, 0, 0, 0, 0]
7+
sp = 100
8+
9+
10+
def test(mc):
11+
print('Start check jog api\n')
12+
13+
mc.send_angles(zero, sp)
14+
time.sleep(5)
15+
16+
print('jog_angle() -> control joint1')
17+
mc.jog_angle(Angle.J1.value, 1, 10)
18+
time.sleep(3)
19+
print('pause 10 s')
20+
mc.pause()
21+
time.sleep(3)
22+
print('speed get', mc.get_speed())
23+
mc.set_speed(20)
24+
print('speed set', mc.get_speed())
25+
time.sleep(7)
26+
print('resume')
27+
mc.resume()
28+
time.sleep(10)
29+
30+
coords = [160, 140, 160, 0, 0, 0]
31+
mc.send_coords(coords, 100, 0)
32+
time.sleep(4)
33+
34+
mc.jog_coord(Coord.Z.value, 1, 10)
35+
time.sleep(3)
36+
print('stop')
37+
38+
print('=== check end ===\n')
39+
40+
41+
if __name__ == '__main__':
42+
print('''
43+
--------------------------------------------
44+
| This file will test jog method: |
45+
| jog_angle() |
46+
| jog_coord() |
47+
| pause() |
48+
| resume() |
49+
| stop() |
50+
| get_speed() |
51+
| set_speed() |
52+
--------------------------------------------
53+
''')
54+
time.sleep(3)
55+
with open('./port.txt') as f:
56+
port = f.read().strip().replace('\n', '')
57+
print(port)
58+
mc = MyCobot(port)
59+
60+
test(mc)

tests/limit_test.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import time
2+
from pymycobot.mycobot import MyCobot
3+
4+
5+
reset = [153.19, 137.81, -153.54, 156.79, 87.27, 13.62]
6+
zero = [0,0,0,0,0,0]
7+
sp = 100
8+
9+
def test(mc):
10+
print('Start check limit api\n')
11+
12+
print('get joint min angle value:')
13+
print(mc.get_joint_min_angle(1))
14+
print(mc.get_joint_min_angle(2))
15+
print(mc.get_joint_min_angle(3))
16+
print(mc.get_joint_min_angle(4))
17+
print(mc.get_joint_min_angle(5))
18+
print(mc.get_joint_min_angle(6))
19+
20+
21+
print('get joint max angle value:')
22+
print(mc.get_joint_max_angle(1))
23+
print(mc.get_joint_max_angle(2))
24+
print(mc.get_joint_max_angle(3))
25+
print(mc.get_joint_max_angle(4))
26+
print(mc.get_joint_max_angle(5))
27+
print(mc.get_joint_max_angle(6))
28+
29+
30+
mc.send_angles(reset, 100)
31+
time.sleep(5)
32+
mc.set_free_mode()
33+
34+
print('=== check end ===\n')
35+
36+
37+
if __name__ == '__main__':
38+
print('''
39+
--------------------------------------------
40+
| This file will test limit method: |
41+
| get_joint_min_angle() |
42+
| get_joint_max_angle() |
43+
--------------------------------------------
44+
''')
45+
time.sleep(3)
46+
with open('./port.txt') as f:
47+
port = f.read().strip().replace('\n', '')
48+
print(port)
49+
mc = MyCobot(port)
50+
51+
test(mc)

tests/loop_test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import time, subprocess
1+
import time
22
from pymycobot.mycobot import MyCobot
33

44

55
if __name__ == '__main__':
6-
# port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
7-
# shell=True).decode()
8-
# port = "/dev/cu.usbserial-0203B030"
9-
port = "/dev/cu.usbserial-0213245D"
6+
with open('./port.txt') as f:
7+
port = f.read().strip().replace('\n', '')
8+
print(port)
109
cobot = MyCobot(port)
1110
cobot.send_angles([0,0,0,0,0,0],100)
1211
time.sleep(10)

tests/power_state_test.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import time, random, subprocess
1+
import time
22
from pymycobot.mycobot import MyCobot
3-
from pymycobot.genre import Angle, Coord
43

54

65
reset = [153.19, 137.81, -153.54, 156.79, 87.27, 13.62]
@@ -41,20 +40,19 @@ def test(mc):
4140
print('=== check end ===\n')
4241

4342

44-
45-
46-
4743
if __name__ == '__main__':
4844
print('''
49-
————————————————————————————————————————————
45+
--------------------------------------------
5046
| This file will test power state method: |
5147
| power_off() |
5248
| power_on() |
5349
| is_power_on() |
54-
————————————————————————————————————————————
50+
--------------------------------------------
5551
''')
5652
time.sleep(3)
57-
port = "/dev/cu.usbserial-0203B030"
53+
with open('./port.txt') as f:
54+
port = f.read().strip().replace('\n', '')
55+
print(port)
5856
mc = MyCobot(port)
5957
test(mc)
6058

tests/state_test.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import time
2+
from pymycobot.mycobot import MyCobot
3+
4+
5+
reset = [153.19, 137.81, -153.54, 156.79, 87.27, 13.62]
6+
zero = [0,0,0,0,0,0]
7+
coords = [160, 160, 160, 0, 0, 0]
8+
sp = 100
9+
10+
def test(mc):
11+
print('Start check state api\n')
12+
13+
print('goto zero position')
14+
mc.send_angles(zero, sp)
15+
time.sleep(4)
16+
print('is in position(angle): 1 - true, 0 - false, -1 - error data')
17+
for _ in range(10):
18+
print(mc.is_in_position(zero, 0), ' ', end='')
19+
time.sleep(.5)
20+
21+
print('\nis in position(coords): 1 - true, 0 - false, -1 - error data')
22+
for _ in range(10):
23+
print(mc.is_in_position(coords, 1), ' ', end='')
24+
time.sleep(.5)
25+
26+
mc.send_coords(coords, 100, 0)
27+
time.sleep(4)
28+
print('\nis in position(coords): 1 - true, 0 - false, -1 - error data')
29+
for _ in range(10):
30+
print(mc.is_in_position(coords, 1), ' ', end='')
31+
time.sleep(.5)
32+
33+
34+
mc.send_angles(zero, 100)
35+
time.sleep(4)
36+
print('is moving: 1 - true, 0 - false')
37+
print(mc.is_moving())
38+
time.sleep(3)
39+
print('is moving: 1 - true, 0 - false')
40+
print(mc.is_moving())
41+
time.sleep(1)
42+
mc.jog_angle(1, 1, 35)
43+
44+
t = time.time()
45+
print('is moving: 1 - true, 0 - false')
46+
while time.time() - t < 20:
47+
print(mc.is_moving())
48+
time.sleep(.5)
49+
50+
51+
52+
if __name__ == '__main__':
53+
print('''
54+
--------------------------------------------
55+
| This file will test state method: |
56+
| is_in_position() |
57+
| is_moving() |
58+
--------------------------------------------
59+
''')
60+
time.sleep(3)
61+
with open('./port.txt') as f:
62+
port = f.read().strip().replace('\n', '')
63+
print(port)
64+
mc = MyCobot(port)
65+
test(mc)
66+

0 commit comments

Comments
 (0)