Skip to content

Commit 9ca4743

Browse files
committed
feat: add new test files for gripper and IO.
1 parent bddda49 commit 9ca4743

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

setup.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
PYTHON_VERSION = sys.version_info[:2]
5-
VERSION = "2.1.2"
5+
VERSION = "2.2.0"
66

77
if (2, 7) != PYTHON_VERSION < (3, 5):
88
print("This mycobot version requires Python2.7, 3.5 or later.")
@@ -41,6 +41,11 @@
4141
)
4242

4343
change_log = '''
44+
# 2021.2.5
45+
46+
relase v2.2.0
47+
- add new method for girpper and IO.
48+
4449
# 2021.1.25
4550
4651
release v2.1.2

tests/gripper_test.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import time, random, subprocess
2+
from pymycobot.mycobot import MyCobot
3+
from pymycobot.genre import Angle, Coord
4+
5+
def gripper_test(mc):
6+
print('Start check IO part of api\n')
7+
# print()
8+
9+
flag = mc.is_gripper_moving()
10+
print('Is gripper moving: {}'.format(flag))
11+
time.sleep(1)
12+
13+
print('Set the current position to zero')
14+
mc.set_gripper_ini()
15+
time.sleep(2)
16+
17+
print('')
18+
mc.set_gripper_value(248 - 15, 50)
19+
time.sleep(2)
20+
21+
print('')
22+
mc.set_gripper_value(248 + 15, 50)
23+
time.sleep(2)
24+
25+
print('')
26+
mc.set_gripper_state(0, 70)
27+
time.sleep(2)
28+
29+
print('')
30+
mc.set_gripper_state(1, 70)
31+
time.sleep(2)
32+
33+
print('')
34+
print(mc.get_gripper_value())
35+
36+
37+
if __name__ == '__main__':
38+
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
39+
shell=True).decode()
40+
mycobot = MyCobot(port)
41+
gripper_test(mycobot)

tests/io_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import time, random, subprocess
2+
from pymycobot.mycobot import MyCobot
3+
from pymycobot.genre import Angle, Coord
4+
5+
def io_test(mc):
6+
print('Start check IO part of api\n')
7+
# print()
8+
9+
mc.set_pin_mode(19, 1)
10+
time.sleep(1)
11+
mc.set_digital_output(19, 1)
12+
time.sleep(5)
13+
mc.set_digital_output(19, 0)
14+
15+
16+
if __name__ == '__main__':
17+
port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
18+
shell=True).decode()
19+
mycobot = MyCobot(port)
20+
io_test(mycobot)

tests/test.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ def test(mycobot):
77
# print()
88

99
print('all servo status: {}'.format(mycobot.is_all_servo_enable()))
10-
time.sleep(1)
10+
time.sleep(2)
1111
servo = 2
1212
print('servo {} status: {}'.format(servo, mycobot.is_servo_enable(servo)))
13-
time.sleep(1)
13+
time.sleep(2)
1414
print('power status: {}'.format(mycobot.is_power_on()))
15-
time.sleep(1)
15+
time.sleep(2)
1616

1717
color_name = ['red', 'green', 'blue']
1818
color_code = ['ff0000', '00ff00', '0000ff']
@@ -105,6 +105,7 @@ def test(mycobot):
105105
print('=== check end <==\n')
106106

107107
print(mycobot.get_joint_min_angle(1))
108+
time.sleep(2)
108109
print(mycobot.get_joint_max_angle(1))
109110

110111

0 commit comments

Comments
 (0)