-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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>
- Loading branch information
Showing
14 changed files
with
115 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
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(): | ||
def __init__(self, CP): | ||
pass | ||
|
||
def reset(self): | ||
pass | ||
|
||
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 < 0.3 or not active: | ||
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_log.saturated = False | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.