File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 2727motor .run_target (500 , 360 )
2828
2929# Wait so we can also log hold capability, then turn off the motor completely.
30- wait (1000 )
30+ wait (100 )
3131motor .stop ()
3232
3333# Save the data by printing it. Pybricksdev will capture the printed
3434# 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' )
35+ motor .log .save ("build/servo_data.txt" )
36+ motor .control .log .save ("build/control_data.txt" )
37+
38+ # The log can also be read from the user script. For fun, let's print the
39+ # position and the estimated speed in a rotated plot. We show only 1 in 3
40+ # samples here and scale the speed and angle values for better visibility.
41+ for i in range (len (motor .log ) / 3 ):
42+
43+ # Read the (i * 3)th row in the data log.
44+ values = motor .log .get (i * 3 )
45+ speed = values [7 ]
46+ angle = values [2 ]
47+
48+ # Turn it into a line of spaces with * for speed and + for angle.
49+ line = [ord (" " )] * 100
50+ line [speed // 6 ] = ord ("*" )
51+ line [angle // 5 ] = ord ("+" )
52+
53+ # Print it. Looked at it sideways, you should see a trapezoidal graph
54+ # for speed and a gradual ramp for the angle.
55+ print (bytes (line ))
You can’t perform that action at this time.
0 commit comments