Skip to content

Commit

Permalink
global variable for min control speed
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Aug 19, 2021
1 parent 3d04b21 commit 3d50211
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions selfdrive/controls/lib/latcontrol.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from common.numpy_fast import clip
from common.realtime import DT_CTRL

MIN_CTRL_SPEED = 0.3


class LatControl:
def __init__(self, CP):
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/latcontrol_angle.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import math
from cereal import log
from selfdrive.controls.lib.latcontrol import LatControl
from selfdrive.controls.lib.latcontrol import LatControl, MIN_CTRL_SPEED


class LatControlAngle(LatControl):
def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvature_rate):
angle_log = log.ControlsState.LateralAngleState.new_message()

if CS.vEgo < 0.3 or not active:
if CS.vEgo < MIN_CTRL_SPEED or not active:
angle_log.active = False
angle_steers_des = float(CS.steeringAngleDeg)
else:
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/latcontrol_indi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from selfdrive.car import apply_toyota_steer_torque_limits
from selfdrive.car.toyota.values import CarControllerParams
from selfdrive.controls.lib.drive_helpers import get_steer_max
from selfdrive.controls.lib.latcontrol import LatControl
from selfdrive.controls.lib.latcontrol import LatControl, MIN_CTRL_SPEED


class LatControlINDI(LatControl):
Expand Down Expand Up @@ -83,7 +83,7 @@ def update(self, active, CS, CP, VM, params, curvature, curvature_rate):

steers_des = VM.get_steer_from_curvature(-curvature, CS.vEgo)
steers_des += math.radians(params.angleOffsetDeg)
if CS.vEgo < 0.3 or not active:
if CS.vEgo < MIN_CTRL_SPEED or not active:
indi_log.active = False
self.output_steer = 0.0
self.steer_filter.x = 0.0
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/latcontrol_lqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from common.realtime import DT_CTRL
from cereal import log
from selfdrive.controls.lib.drive_helpers import get_steer_max
from selfdrive.controls.lib.latcontrol import LatControl
from selfdrive.controls.lib.latcontrol import LatControl, MIN_CTRL_SPEED


class LatControlLQR(LatControl):
Expand Down Expand Up @@ -50,7 +50,7 @@ def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvatur
e = steering_angle_no_offset - angle_steers_k
self.x_hat = self.A.dot(self.x_hat) + self.B.dot(CS.steeringTorqueEps / torque_scale) + self.L.dot(e)

if CS.vEgo < 0.3 or not active:
if CS.vEgo < MIN_CTRL_SPEED or not active:
lqr_log.active = False
lqr_output = 0.
output_steer = 0.
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/latcontrol_pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from selfdrive.controls.lib.pid import PIController
from selfdrive.controls.lib.drive_helpers import get_steer_max
from selfdrive.controls.lib.latcontrol import LatControl
from selfdrive.controls.lib.latcontrol import LatControl, MIN_CTRL_SPEED
from cereal import log


Expand All @@ -25,7 +25,7 @@ def update(self, active, CS, CP, VM, params, desired_curvature, desired_curvatur
angle_steers_des_no_offset = math.degrees(VM.get_steer_from_curvature(-desired_curvature, CS.vEgo))
angle_steers_des = angle_steers_des_no_offset + params.angleOffsetDeg

if CS.vEgo < 0.3 or not active:
if CS.vEgo < MIN_CTRL_SPEED or not active:
output_steer = 0.0
pid_log.active = False
self.pid.reset()
Expand Down

0 comments on commit 3d50211

Please sign in to comment.