Skip to content

Commit 3a0d5e3

Browse files
committed
tests/motors: Add coast and hold tests.
1 parent d7b04e7 commit 3a0d5e3

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

tests/motors/single_motor_coast.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from pybricks.pupdevices import Motor
2+
from pybricks.tools import wait
3+
from pybricks.parameters import Port
4+
from pybricks import version
5+
6+
print(version)
7+
8+
# Initialize the motor.
9+
motor = Motor(Port.A)
10+
11+
# Allocate the data logs.
12+
DURATION = 16000
13+
motor.log.start(DURATION, 2)
14+
15+
wait(5000)
16+
17+
# Transfer data logs.
18+
print("Transferring data...")
19+
motor.log.save("servo.txt")
20+
print("Done")

tests/motors/single_motor_hold.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pybricks.pupdevices import Motor
2+
from pybricks.tools import wait
3+
from pybricks.parameters import Port
4+
from pybricks import version
5+
6+
print(version)
7+
8+
# Initialize the motor.
9+
motor = Motor(Port.A)
10+
11+
# Allocate the data logs.
12+
DURATION = 16000
13+
motor.log.start(DURATION, 2)
14+
motor.control.log.start(DURATION, 2)
15+
16+
# Hold the motor.
17+
motor.hold()
18+
wait(DURATION)
19+
motor.stop()
20+
21+
# Transfer data logs.
22+
print("Transferring data...")
23+
motor.log.save("servo.txt")
24+
motor.control.log.save("control.txt")
25+
print("Done")

0 commit comments

Comments
 (0)