@@ -151,18 +151,20 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
151151
152152 if main_controller is None :
153153 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 ,
158160 tolerance = 0.1 ,
159161 toleranceCount = 3 ,
160162 )
161163
162164 # Secondary controller to keep encoder values in sync
163165 if secondary_controller is None :
164166 secondary_controller = PID (
165- kp = 0.025 , kd = 0.0025 ,
167+ kp = 0.03 , kd = 0.003 ,
166168 )
167169
168170 if self .imu is not None :
@@ -203,16 +205,16 @@ def straight(self, distance: float, max_effort: float = 0.5, timeout: float = No
203205 return not time_out .is_done ()
204206
205207
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 :
207209 """
208210 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)
210212 Uses the IMU to determine the heading of the robot and P control for the motor controller.
211213
212214 :param turnDegrees: The number of angle for the robot to turn (In Degrees)
213215 :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
216218 :param timeout: The amount of time before the robot stops trying to turn and continues to the next step (In Seconds)
217219 :type timeout: float
218220 :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
225227 :rtype: bool
226228 """
227229
228- if max_speed < 0 :
229- max_speed *= - 1
230+ if max_effort < 0 :
231+ max_effort *= - 1
230232 turn_degrees *= - 1
231233
232234 time_out = Timeout (timeout )
@@ -239,7 +241,7 @@ def turn(self, turn_degrees: float, max_speed: float = 40, timeout: float = None
239241 ki = 0.005 ,
240242 kd = 0.012 ,
241243 minOutput = 0.35 ,
242- maxOutput = 0.5 ,
244+ maxOutput = max_effort ,
243245 maxDerivative = 0.5 ,
244246 maxIntegral = 50 ,
245247 tolerance = 0.5 ,
0 commit comments