@@ -148,7 +148,7 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
148
148
# Secondary controller to keep encoder values in sync
149
149
if secondary_controller is None :
150
150
secondary_controller = PID (
151
- kp = 0.25 , kd = 0.0025 ,
151
+ kp = 0.025 , kd = 0.0025 ,
152
152
)
153
153
154
154
if self .imu is not None :
@@ -166,7 +166,7 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
166
166
167
167
# PID for distance
168
168
distanceError = distance - distTraveled
169
- effort = main_controller .tick (distanceError )
169
+ effort = main_controller .update (distanceError )
170
170
171
171
if main_controller .is_done () or time_out .is_done ():
172
172
break
@@ -178,8 +178,8 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
178
178
else :
179
179
current_heading = ((rightDelta - leftDelta )/ 2 )* 360 / (self .track_width * math .pi )
180
180
181
- headingCorrection = secondary_controller .tick (initial_heading - current_heading )
182
-
181
+ headingCorrection = secondary_controller .update (initial_heading - current_heading )
182
+
183
183
self .set_effort (effort - headingCorrection , effort + headingCorrection )
184
184
185
185
time .sleep (0.01 )
@@ -243,7 +243,7 @@ def turn(self, turn_degrees: float, max_effort: float = 0.5, timeout: float = No
243
243
# calculate encoder correction to minimize drift
244
244
leftDelta = self .get_left_encoder_position () - startingLeft
245
245
rightDelta = self .get_right_encoder_position () - startingRight
246
- encoderCorrection = secondary_controller .tick (leftDelta + rightDelta )
246
+ encoderCorrection = secondary_controller .update (leftDelta + rightDelta )
247
247
248
248
if use_imu and (self .imu is not None ):
249
249
# calculate turn error (in degrees) from the imu
@@ -253,7 +253,7 @@ def turn(self, turn_degrees: float, max_effort: float = 0.5, timeout: float = No
253
253
turnError = turn_degrees - ((rightDelta - leftDelta )/ 2 )* 360 / (self .track_width * math .pi )
254
254
255
255
# Pass the turn error to the main controller to get a turn speed
256
- turnSpeed = main_controller .tick (turnError )
256
+ turnSpeed = main_controller .update (turnError )
257
257
258
258
# exit if timeout or tolerance reached
259
259
if main_controller .is_done () or time_out .is_done ():
0 commit comments