mirror of
https://github.com/infiniteCable2/opendbc.git
synced 2026-06-08 10:54:51 +08:00
Nissan: filter angle to reduce jitter (#3415)
* try this * filter angle * filter angle * just filter angle * dt * huh
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import numpy as np
|
||||
from opendbc.can import CANPacker
|
||||
from opendbc.car import Bus, structs
|
||||
from opendbc.car import Bus, DT_CTRL, structs
|
||||
from opendbc.car.lateral import apply_std_steer_angle_limits
|
||||
from opendbc.car.interfaces import CarControllerBase
|
||||
from opendbc.car.nissan import nissancan
|
||||
from opendbc.car.nissan.values import CAR, CarControllerParams
|
||||
from opendbc.car.common.filter_simple import FirstOrderFilter
|
||||
|
||||
VisualAlert = structs.CarControl.HUDControl.VisualAlert
|
||||
|
||||
@@ -13,6 +15,8 @@ class CarController(CarControllerBase):
|
||||
super().__init__(dbc_names, CP)
|
||||
self.car_fingerprint = CP.carFingerprint
|
||||
|
||||
self.angle_filter = FirstOrderFilter(0.0, 0.1, DT_CTRL)
|
||||
|
||||
self.apply_angle_last = 0
|
||||
|
||||
self.packer = CANPacker(dbc_names[Bus.pt])
|
||||
@@ -27,8 +31,15 @@ class CarController(CarControllerBase):
|
||||
### STEER ###
|
||||
steer_hud_alert = 1 if hud_control.visualAlert in (VisualAlert.steerRequired, VisualAlert.ldw) else 0
|
||||
|
||||
# At low speeds and at high steering angles, EPS is sensitive to jitter in angle request. Smooth to fix uncomfortable response.
|
||||
if CC.latActive:
|
||||
self.angle_filter.update_alpha(float(np.interp(CS.out.vEgo, [5, 10, 20], [0.2, 0.1, 0.0])))
|
||||
self.angle_filter.update(actuators.steeringAngleDeg)
|
||||
else:
|
||||
self.angle_filter.x = actuators.steeringAngleDeg
|
||||
|
||||
# windup slower
|
||||
self.apply_angle_last = apply_std_steer_angle_limits(actuators.steeringAngleDeg, self.apply_angle_last, CS.out.vEgoRaw,
|
||||
self.apply_angle_last = apply_std_steer_angle_limits(self.angle_filter.x, self.apply_angle_last, CS.out.vEgoRaw,
|
||||
CS.out.steeringAngleDeg, CC.latActive, CarControllerParams.ANGLE_LIMITS)
|
||||
|
||||
lkas_max_torque = 0
|
||||
|
||||
Reference in New Issue
Block a user