Reordered PID

This commit is contained in:
Guillermo 2021-07-28 11:06:56 +02:00 committed by bernat
parent deda2c3e5e
commit 18494b799d
2 changed files with 10 additions and 11 deletions

View File

@ -106,8 +106,7 @@ class PIDLongitudinalController():
PIDLongitudinalController implements longitudinal control using a PID.
"""
def __init__(self, vehicle, K_P=1.0, K_D=0.0, K_I=0.0, dt=0.03):
def __init__(self, vehicle, K_P=1.0, K_I=0.0, K_D=0.0, dt=0.03):
"""
Constructor method.
@ -119,8 +118,8 @@ class PIDLongitudinalController():
"""
self._vehicle = vehicle
self._k_p = K_P
self._k_d = K_D
self._k_i = K_I
self._k_d = K_D
self._dt = dt
self._error_buffer = deque(maxlen=10)
@ -160,11 +159,11 @@ class PIDLongitudinalController():
return np.clip((self._k_p * error) + (self._k_d * _de) + (self._k_i * _ie), -1.0, 1.0)
def change_parameters(self, K_P, K_D, K_I, dt):
def change_parameters(self, K_P, K_I, K_D, dt):
"""Changes the PID parameters"""
self._k_p = K_P
self._k_d = K_D
self._k_i = K_I
self._k_d = K_D
self._dt = dt
@ -173,7 +172,7 @@ class PIDLateralController():
PIDLateralController implements lateral control using a PID.
"""
def __init__(self, vehicle, offset=0, K_P=1.0, K_D=0.0, K_I=0.0, dt=0.03):
def __init__(self, vehicle, offset=0, K_P=1.0, K_I=0.0, K_D=0.0, dt=0.03):
"""
Constructor method.
@ -187,8 +186,8 @@ class PIDLateralController():
"""
self._vehicle = vehicle
self._k_p = K_P
self._k_d = K_D
self._k_i = K_I
self._k_d = K_D
self._dt = dt
self._offset = offset
self._e_buffer = deque(maxlen=10)
@ -251,9 +250,9 @@ class PIDLateralController():
return np.clip((self._k_p * _dot) + (self._k_d * _de) + (self._k_i * _ie), -1.0, 1.0)
def change_parameters(self, K_P, K_D, K_I, dt):
def change_parameters(self, K_P, K_I, K_D, dt):
"""Changes the PID parameters"""
self._k_p = K_P
self._k_d = K_D
self._k_i = K_I
self._k_d = K_D
self._dt = dt

View File

@ -70,8 +70,8 @@ class LocalPlanner(object):
self._dt = 1.0 / 20.0
self._target_speed = 20.0 # Km/h
self._sampling_radius = 2.0
self._args_lateral_dict = {'K_P': 1.95, 'K_D': 0.2, 'K_I': 0.05, 'dt': self._dt}
self._args_longitudinal_dict = {'K_P': 1.0, 'K_D': 0, 'K_I': 0.05, 'dt': self._dt}
self._args_lateral_dict = {'K_P': 1.95, 'K_I': 0.05, 'K_D': 0.2, 'dt': self._dt}
self._args_longitudinal_dict = {'K_P': 1.0, 'K_I': 0.05, 'K_D': 0, 'dt': self._dt}
self._max_throt = 0.75
self._max_brake = 0.3
self._max_steer = 0.8