Toyota: use a filter for PCM compensation (#1477)

* use a filter

* clean up

* use pitch filter

* use standstill, permit braking uses un rate limited request

* stash

* Revert "stash"

This reverts commit 8bbd7ffd4c.

* Revert "use standstill, permit braking uses un rate limited request"

This reverts commit 78b78eb257.

* Revert "use pitch filter"

This reverts commit f5aa4c6d04.
This commit is contained in:
Shane Smiskol 2024-11-13 17:24:49 -06:00 committed by GitHub
parent f9abb9e473
commit af2333f7c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -2,6 +2,7 @@ import math
from opendbc.car import carlog, apply_meas_steer_torque_limits, apply_std_steer_angle_limits, common_fault_avoidance, \
make_tester_present_msg, rate_limit, structs, ACCELERATION_DUE_TO_GRAVITY, DT_CTRL
from opendbc.car.can_definitions import CanData
from opendbc.car.common.filter_simple import FirstOrderFilter
from opendbc.car.common.numpy_fast import clip
from opendbc.car.secoc import add_mac, build_sync_mac
from opendbc.car.interfaces import CarControllerBase
@ -46,7 +47,7 @@ class CarController(CarControllerBase):
self.steer_rate_counter = 0
self.distance_button = 0
self.pcm_accel_compensation = 0.0
self.pcm_accel_compensation = FirstOrderFilter(0, 0.5, DT_CTRL * 3)
self.permit_braking = True
self.packer = CANPacker(dbc_name)
@ -193,11 +194,10 @@ class CarController(CarControllerBase):
pcm_accel_compensation = clip(pcm_accel_compensation, pcm_accel_cmd - self.params.ACCEL_MAX,
pcm_accel_cmd - self.params.ACCEL_MIN)
self.pcm_accel_compensation = rate_limit(pcm_accel_compensation, self.pcm_accel_compensation, -0.03, 0.03)
pcm_accel_cmd = pcm_accel_cmd - self.pcm_accel_compensation
pcm_accel_cmd = pcm_accel_cmd - self.pcm_accel_compensation.update(pcm_accel_compensation)
else:
self.pcm_accel_compensation = 0.0
self.pcm_accel_compensation.x = 0.0
self.permit_braking = True
# Along with rate limiting positive jerk above, this greatly improves gas response time