File tree 1 file changed +8
-20
lines changed
1 file changed +8
-20
lines changed Original file line number Diff line number Diff line change 1
1
from XRPLib .defaults import *
2
2
from machine import Pin
3
3
import time
4
- from XRPLib .dryw_encoder import *
5
4
6
5
imu .reset_pitch ()
7
6
imu .reset_yaw ()
@@ -65,24 +64,13 @@ def test_button():
65
64
board .set_button_callback (trigger = Pin .IRQ_RISING , callback = lambda p : board .led .toggle ())
66
65
67
66
def 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 )
71
70
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 )
87
75
88
- encoder_benchmarking ()
76
+ test_rangefinder ()
You can’t perform that action at this time.
0 commit comments