@@ -151,18 +151,20 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
151
151
152
152
if main_controller is None :
153
153
main_controller = PID (
154
- kp = 0.075 ,
155
- kd = 0.005 ,
156
- minOutput = 0.25 ,
157
- maxOutput = max_effort ,
154
+ kp = 0.04 ,
155
+ ki = 0.0125 ,
156
+ kd = 0.025 ,
157
+ minOutput = 0.225 ,
158
+ maxOutput = 0.5 ,
159
+ maxIntegral = 35 ,
158
160
tolerance = 0.1 ,
159
161
toleranceCount = 3 ,
160
162
)
161
163
162
164
# Secondary controller to keep encoder values in sync
163
165
if secondary_controller is None :
164
166
secondary_controller = PID (
165
- kp = 0.025 , kd = 0.0025 ,
167
+ kp = 0.03 , kd = 0.003 ,
166
168
)
167
169
168
170
if self .imu is not None :
@@ -203,16 +205,16 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
203
205
return not time_out .is_done ()
204
206
205
207
206
- def turn (self , turn_degrees : float , max_speed : float = 40 , timeout : float = None , main_controller : Controller = None , secondary_controller : Controller = None , use_imu :bool = True ) -> bool :
208
+ def turn (self , turn_degrees : float , max_effort : float = 40 , timeout : float = None , main_controller : Controller = None , secondary_controller : Controller = None , use_imu :bool = True ) -> bool :
207
209
"""
208
210
Turn the robot some relative heading given in turnDegrees, and exit function when the robot has reached that heading.
209
- Speed is bounded from -1 (turn counterclockwise the relative heading at full speed) to 1 (turn clockwise the relative heading at full speed)
211
+ effort is bounded from -1 (turn counterclockwise the relative heading at full speed) to 1 (turn clockwise the relative heading at full speed)
210
212
Uses the IMU to determine the heading of the robot and P control for the motor controller.
211
213
212
214
:param turnDegrees: The number of angle for the robot to turn (In Degrees)
213
215
:type turnDegrees: float
214
- :param max_speed : The max speed for each wheel of the robot to spin, in cm/s. Default is 40 cm/s.
215
- :type max_speed : float
216
+ :param max_effort : The max speed for which the robot to travel (Bounded from -1 to 1)
217
+ :type max_effort : float
216
218
:param timeout: The amount of time before the robot stops trying to turn and continues to the next step (In Seconds)
217
219
:type timeout: float
218
220
:param main_controller: The main controller, for handling the angle turned
@@ -225,8 +227,8 @@ def turn(self, turn_degrees: float, max_speed: float = 40, timeout: float = None
225
227
:rtype: bool
226
228
"""
227
229
228
- if max_speed < 0 :
229
- max_speed *= - 1
230
+ if max_effort < 0 :
231
+ max_effort *= - 1
230
232
turn_degrees *= - 1
231
233
232
234
time_out = Timeout (timeout )
@@ -239,7 +241,7 @@ def turn(self, turn_degrees: float, max_speed: float = 40, timeout: float = None
239
241
ki = 0.005 ,
240
242
kd = 0.012 ,
241
243
minOutput = 0.35 ,
242
- maxOutput = 0.5 ,
244
+ maxOutput = max_effort ,
243
245
maxDerivative = 0.5 ,
244
246
maxIntegral = 50 ,
245
247
tolerance = 0.5 ,
0 commit comments