File tree Expand file tree Collapse file tree 1 file changed +8
-20
lines changed
Expand file tree Collapse file tree 1 file changed +8
-20
lines changed Original file line number Diff line number Diff line change 11from XRPLib .defaults import *
22from machine import Pin
33import time
4- from XRPLib .dryw_encoder import *
54
65imu .reset_pitch ()
76imu .reset_yaw ()
@@ -65,24 +64,13 @@ def test_button():
6564 board .set_button_callback (trigger = Pin .IRQ_RISING , callback = lambda p : board .led .toggle ())
6665
6766def test_rangefinder ():
68- while True :
69- print (f"{ rangefinder .distance ()} " )
70- time .sleep (0.25 )
67+ while not board . is_button_pressed () :
68+ print (f"{ rangefinder .distance ()} , { rangefinder . distance () } " )
69+ time .sleep (0.5 )
7170
72- def encoder_benchmarking ():
73- print ("start benchmark" )
74- N = 100000
75- a = time .time ()
76- for i in range (N ):
77- drivetrain .left_motor ._encoder ._isr ()
78- b = time .time ()
79- for i in range (N ):
80- mot1 .encInt (4 )
81- c = time .time ()
82- # Print benchmark
83- print (f"Time for { N } Old Encoder calls: { b - a } s" )
84- print (f"Time per Old Encoder call: { (b - a )/ N } s" ) # ~0.06 ms per call
85- print (f"Time for { N } New Encoder calls: { c - b } s" )
86- print (f"Time per New Encoder call: { (c - b )/ N } s" )
71+ def encoder_test ():
72+ while not board .is_button_pressed ():
73+ print (f"Left: { left_motor .get_position ()} \t Right:{ right_motor .get_position ()} " )
74+ time .sleep (0.1 )
8775
88- encoder_benchmarking ()
76+ test_rangefinder ()
You can’t perform that action at this time.
0 commit comments