|
|
@ -5,9 +5,8 @@ from abc import abstractmethod, ABC |
|
|
|
class LatControl(ABC): |
|
|
|
class LatControl(ABC): |
|
|
|
def __init__(self, CP, CI, dt): |
|
|
|
def __init__(self, CP, CI, dt): |
|
|
|
self.dt = dt |
|
|
|
self.dt = dt |
|
|
|
self.sat_count_rate = 1.0 * self.dt |
|
|
|
|
|
|
|
self.sat_limit = CP.steerLimitTimer |
|
|
|
self.sat_limit = CP.steerLimitTimer |
|
|
|
self.sat_count = 0. |
|
|
|
self.sat_time = 0. |
|
|
|
self.sat_check_min_speed = 10. |
|
|
|
self.sat_check_min_speed = 10. |
|
|
|
|
|
|
|
|
|
|
|
# we define the steer torque scale as [-1.0...1.0] |
|
|
|
# we define the steer torque scale as [-1.0...1.0] |
|
|
@ -18,13 +17,13 @@ class LatControl(ABC): |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def reset(self): |
|
|
|
def reset(self): |
|
|
|
self.sat_count = 0. |
|
|
|
self.sat_time = 0. |
|
|
|
|
|
|
|
|
|
|
|
def _check_saturation(self, saturated, CS, steer_limited_by_safety, curvature_limited): |
|
|
|
def _check_saturation(self, saturated, CS, steer_limited_by_safety, curvature_limited): |
|
|
|
# Saturated only if control output is not being limited by car torque/angle rate limits |
|
|
|
# Saturated only if control output is not being limited by car torque/angle rate limits |
|
|
|
if (saturated or curvature_limited) and CS.vEgo > self.sat_check_min_speed and not steer_limited_by_safety and not CS.steeringPressed: |
|
|
|
if (saturated or curvature_limited) and CS.vEgo > self.sat_check_min_speed and not steer_limited_by_safety and not CS.steeringPressed: |
|
|
|
self.sat_count += self.sat_count_rate |
|
|
|
self.sat_time += self.dt |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.sat_count -= self.sat_count_rate |
|
|
|
self.sat_time -= self.dt |
|
|
|
self.sat_count = np.clip(self.sat_count, 0.0, self.sat_limit) |
|
|
|
self.sat_time = np.clip(self.sat_time, 0.0, self.sat_limit) |
|
|
|
return self.sat_count > (self.sat_limit - 1e-3) |
|
|
|
return self.sat_time > (self.sat_limit - 1e-3) |
|
|
|