Skip to content

Commit b593e73

Browse files
committed
tests/pup/motors: Add logging test.
1 parent 6398ebe commit b593e73

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/pup/motors/log_servo.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-License-Identifier: MIT
2+
# Copyright (c) 2020 The Pybricks Authors
3+
4+
"""
5+
Hardware Module: 1
6+
7+
Description: Verifies data logging capability.
8+
"""
9+
10+
from pybricks.pupdevices import Motor
11+
from pybricks.tools import wait
12+
from pybricks.parameters import Port
13+
14+
# Initialize the motor.
15+
motor = Motor(Port.A)
16+
17+
# Rotate the motor to base position.
18+
motor.run_target(500, 0)
19+
wait(500)
20+
21+
# Allocate logs for motor and controller signals.
22+
DURATION = 2000
23+
motor.log.start(DURATION)
24+
motor.control.log.start(DURATION)
25+
26+
# Rotate the motor.
27+
motor.run_target(500, 360)
28+
29+
# Wait so we can also log hold capability, then turn off the motor completely.
30+
wait(1000)
31+
motor.stop()
32+
33+
# Save the data by printing it. Pybricksdev will capture the printed
34+
# data and save it to the given path relative to this script.
35+
motor.log.save('build/servo_data.txt')
36+
motor.control.log.save('build/control_data.txt')

0 commit comments

Comments
 (0)