mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 22:53:57 +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>
26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
import math
|
|
|
|
from cereal import log
|
|
from selfdrive.controls.lib.latcontrol import LatControl, MIN_STEER_SPEED
|
|
|
|
STEER_ANGLE_SATURATION_THRESHOLD = 2.5 # Degrees
|
|
|
|
|
|
class LatControlAngle(LatControl):
|
|
def update(self, active, CS, CP, VM, params, last_actuators, desired_curvature, desired_curvature_rate):
|
|
angle_log = log.ControlsState.LateralAngleState.new_message()
|
|
|
|
if CS.vEgo < MIN_STEER_SPEED or not active:
|
|
angle_log.active = False
|
|
angle_steers_des = float(CS.steeringAngleDeg)
|
|
else:
|
|
angle_log.active = True
|
|
angle_steers_des = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo, params.roll))
|
|
angle_steers_des += params.angleOffsetDeg
|
|
|
|
angle_control_saturated = abs(angle_steers_des - CS.steeringAngleDeg) > STEER_ANGLE_SATURATION_THRESHOLD
|
|
angle_log.saturated = self._check_saturation(angle_control_saturated, CS)
|
|
angle_log.steeringAngleDeg = float(CS.steeringAngleDeg)
|
|
angle_log.steeringAngleDesiredDeg = angle_steers_des
|
|
return 0, float(angle_steers_des), angle_log
|