mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-23 23:03:53 +08:00
* base LatControl class, move sat check out of pid.py clean up clean up * fix * global variable for min control speed * nicer name * unify latcontrol class init arguments * add to release files * saturated if close to limit * move angle mode saturation checks into class * check_saturation function takes in current saturated status undo * apply latcontrol_angle's active checking to all controllers * clean up * move those back * make abstract baseclass * add test for saturation * keep clip * update ref * fix static analysis Co-authored-by: Willem Melching <willem.melching@gmail.com>
29 lines
803 B
Python
29 lines
803 B
Python
from abc import abstractmethod, ABC
|
|
|
|
from common.realtime import DT_CTRL
|
|
from common.numpy_fast import clip
|
|
|
|
MIN_STEER_SPEED = 0.3
|
|
|
|
|
|
class LatControl(ABC):
|
|
def __init__(self, CP, CI):
|
|
self.sat_count_rate = 1.0 * DT_CTRL
|
|
self.sat_limit = CP.steerLimitTimer
|
|
self.sat_count = 0.
|
|
|
|
@abstractmethod
|
|
def update(self, active, CS, CP, VM, params, last_actuators, desired_curvature, desired_curvature_rate):
|
|
pass
|
|
|
|
def reset(self):
|
|
self.sat_count = 0.
|
|
|
|
def _check_saturation(self, saturated, CS):
|
|
if saturated and CS.vEgo > 10. and not CS.steeringRateLimited and not CS.steeringPressed:
|
|
self.sat_count += self.sat_count_rate
|
|
else:
|
|
self.sat_count -= self.sat_count_rate
|
|
self.sat_count = clip(self.sat_count, 0.0, 1.0)
|
|
return self.sat_count > self.sat_limit
|