Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nissan/carcontroller: add max steering angle safeguard for nissan #33020

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions selfdrive/car/nissan/carcontroller.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from cereal import car
from opendbc.can.packer import CANPacker
from openpilot.common.numpy_fast import clip
from openpilot.selfdrive.car import apply_std_steer_angle_limits
from openpilot.selfdrive.car.interfaces import CarControllerBase
from openpilot.selfdrive.car.nissan import nissancan
from openpilot.selfdrive.car.nissan.values import CAR, CarControllerParams

VisualAlert = car.CarControl.HUDControl.VisualAlert

# When output steering Angle not within range -1311 and 1310,
# CANPacker packs wrong angle output to be decoded by panda
MAX_STEER_ANGLE = 1310


class CarController(CarControllerBase):
def __init__(self, dbc_name, CP, VM):
Expand Down Expand Up @@ -49,6 +54,7 @@ def update(self, CC, CS, now_nanos):
apply_angle = CS.out.steeringAngleDeg
self.lkas_max_torque = 0

apply_angle = clip(apply_angle, -MAX_STEER_ANGLE, MAX_STEER_ANGLE)
self.apply_angle_last = apply_angle

if self.CP.carFingerprint in (CAR.NISSAN_ROGUE, CAR.NISSAN_XTRAIL, CAR.NISSAN_ALTIMA) and pcm_cancel_cmd:
Expand Down
Loading