Skip to content

Commit 233dede

Browse files
committed
fix: basic_test
1 parent 41baa0c commit 233dede

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

tests/basic_test.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import time
2-
import random
32
import os
43
from pymycobot.mycobot import MyCobot
54
from pymycobot.genre import Angle, Coord
@@ -10,11 +9,8 @@
109
def test(mycobot):
1110
print("\nStart check basic options\n")
1211

13-
color_name = ["red", "green", "blue"]
14-
color_code = ["ff0000", "00ff00", "0000ff"]
15-
i = random.randint(0, len(color_code) - 1)
16-
mycobot.set_led_color(color_code[i])
17-
print("::set_led_color() ==> color {}\n".format(color_name[i]))
12+
mycobot.set_color(255, 255, 0)
13+
print("::set_color() ==> color {}\n".format("255 255 0"))
1814
time.sleep(3)
1915

2016
angles = [0, 0, 0, 0, 0, 0]
@@ -39,7 +35,8 @@ def test(mycobot):
3935

4036
coords = [160, 160, 160, 0, 0, 0]
4137
mycobot.send_coords(coords, 70, 0)
42-
print("::send_coords() ==> send coords {}, speed 70, mode 0\n".format(coords))
38+
print("::send_coords() ==> send coords {}, speed 70, mode 0\n".format(
39+
coords))
4340
time.sleep(3)
4441

4542
print("::get_coords() ==> coords {}\n".format(mycobot.get_coords()))
@@ -58,8 +55,7 @@ def test(mycobot):
5855

5956

6057
if __name__ == "__main__":
61-
print(
62-
"""
58+
print("""
6359
--------------------------------------------
6460
| This file will test basic option method: |
6561
| set_led_color() |
@@ -73,8 +69,7 @@ def test(mycobot):
7369
| send_coord() |
7470
| set_free_mode() |
7571
--------------------------------------------
76-
"""
77-
)
72+
""")
7873
time.sleep(3)
7974
# port = subprocess.check_output(['echo -n /dev/ttyUSB*'],
8075
# shell=True).decode()

tests/gripper_test.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import time, subprocess
1+
import os
2+
import time
23
from pymycobot.mycobot import MyCobot
34

45

@@ -10,9 +11,11 @@ def gripper_test(mc):
1011
print("Is gripper moving: {}".format(flag))
1112
time.sleep(1)
1213

13-
print("Set the current position to zero")
14-
mc.set_gripper_ini()
15-
time.sleep(2)
14+
# Set the current position to (2048).
15+
# Use it when you are sure you need it.
16+
# Gripper has been initialized for a long time. Generally, there
17+
# is no need to change the method.
18+
# mc.set_gripper_ini()
1619

1720
print("")
1821
mc.set_gripper_value(2048, 50)
@@ -35,6 +38,8 @@ def gripper_test(mc):
3538

3639

3740
if __name__ == "__main__":
38-
port = subprocess.check_output(["echo -n /dev/ttyUSB*"], shell=True).decode()
41+
with open(os.path.dirname(__file__) + "/port.txt") as f:
42+
port = f.read().strip().replace("\n", "")
43+
print(port)
3944
mycobot = MyCobot(port)
4045
gripper_test(mycobot)

tests/io_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import time, subprocess
1+
import os
2+
import time
23
from pymycobot.mycobot import MyCobot
34

45

@@ -14,6 +15,8 @@ def io_test(mc):
1415

1516

1617
if __name__ == "__main__":
17-
port = subprocess.check_output(["echo -n /dev/ttyUSB*"], shell=True).decode()
18+
with open(os.path.dirname(__file__) + "/port.txt") as f:
19+
port = f.read().strip().replace("\n", "")
20+
print(port)
1821
mycobot = MyCobot(port)
1922
io_test(mycobot)

tests/port.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
/dev/cu.usbserial-7152ADB1F6
1+
/dev/cu.usbserial-0213245D

0 commit comments

Comments
 (0)