mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-11-06 20:43:46 +08:00
79c8945a41
Integrate torque feedback, lane-change smoothing and low-speed Turn Assist through dedicated lateral owners. Co-authored-by: Dom <168790843+firestar5683@users.noreply.github.com> Co-authored-by: pharmacomaniac <blittle65@gmail.com>
25 lines
968 B
Python
25 lines
968 B
Python
"""Ordinary ASCM torque selection; factory PID identity stays on PID."""
|
|
|
|
import math
|
|
|
|
from opendbc.car.structs import CarParams
|
|
from opendbc.car.gm.values import is_ordinary_ascm_profile
|
|
from openpilot.starpilot.lateral.gm_ordinary_policy import GMOrdinaryTorquePolicy
|
|
|
|
|
|
def supported_cp(cp):
|
|
if not (is_ordinary_ascm_profile(cp, longitudinal=False) or is_ordinary_ascm_profile(cp, longitudinal=True)):
|
|
return False
|
|
if cp.steerControlType != CarParams.SteerControlType.torque or cp.lateralTuning.which() != "torque":
|
|
return False
|
|
tune = cp.lateralTuning.torque
|
|
return (math.isfinite(tune.latAccelFactor) and tune.latAccelFactor > 0 and
|
|
math.isfinite(tune.latAccelOffset) and math.isfinite(tune.friction) and tune.friction >= 0)
|
|
|
|
|
|
class AscmTorquePolicy(GMOrdinaryTorquePolicy):
|
|
def __init__(self, parent, cp):
|
|
if not supported_cp(cp):
|
|
raise ValueError("Unsupported ordinary ASCM torque profile")
|
|
super().__init__(parent, cp)
|