mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-20 17:13:53 +08:00
* Initial commit
* Fix bugs
* Need more torque rate
* Cleanup cray cray control
* Write nicely
* Chiiil
* Not relevant for cray cray control
* Do some logging
* Seems like it has more torque than I thought
* Bit more feedforward
* Tune change
* Retune
* Retune
* Little more chill
* Add coroll
* Add corolla
* Give craycray a good name
* Update to proper logging
* D to the PI
* Should be in radians
* Add d
* Start oscillations
* Add D term
* Only change torque rate limits for new tune
* Add d logging
* Should be enough
* Wrong sign in D
* Downtune a little
* Needed to prevent faults
* Add lqr rav4 to tune
* Try derivative again
* Data based retune
* Data based retune
* add friction compensation
* Doesnt need too much P with friction comp
* remove lqr
* Remove kd
* Fix tests
* fix tests
* Too much error
* Get roll induced error under 1cm/deg
* Too much jitter
* Do roll comp
* Add ki
* Final update
* Update refs
* Cleanup latcontrol_torque a little more
old-commit-hash: fe0bcdaef6
32 lines
909 B
Python
32 lines
909 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.
|
|
|
|
# we define the steer torque scale as [-1.0...1.0]
|
|
self.steer_max = 1.0
|
|
|
|
@abstractmethod
|
|
def update(self, active, CS, CP, VM, params, last_actuators, desired_curvature, desired_curvature_rate, llk):
|
|
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, self.sat_limit)
|
|
return self.sat_count > (self.sat_limit - 1e-3)
|