mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 16:26:14 +08:00
fixes
This commit is contained in:
@@ -12,7 +12,7 @@ from openpilot.common.swaglog import cloudlog
|
||||
from opendbc.car.car_helpers import interfaces
|
||||
from opendbc.car.gm.values import CAR as GM_CAR
|
||||
from opendbc.car.vehicle_model import VehicleModel
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import clip_curvature
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import clip_curvature, get_lateral_active
|
||||
from openpilot.selfdrive.controls.lib.latcontrol import LatControl
|
||||
from openpilot.selfdrive.controls.lib.latcontrol_pid import LatControlPID
|
||||
from openpilot.selfdrive.controls.lib.latcontrol_angle import LatControlAngle, STEER_ANGLE_SATURATION_THRESHOLD
|
||||
@@ -35,23 +35,13 @@ LaneChangeDirection = log.LaneChangeDirection
|
||||
ACTUATOR_FIELDS = tuple(car.CarControl.Actuators.schema.fields.keys())
|
||||
|
||||
|
||||
def get_gm_hud_set_speed(set_speed_ms: float, controls_enabled: bool, starpilot_toggles, starpilot_plan) -> float:
|
||||
def get_gm_hud_set_speed(set_speed_ms: float, starpilot_toggles) -> float:
|
||||
spoofed_speed = set_speed_ms
|
||||
|
||||
set_speed_offset = float(getattr(starpilot_toggles, "set_speed_offset", 0.0) or 0.0)
|
||||
if spoofed_speed > 0 and set_speed_offset > 0:
|
||||
spoofed_speed += set_speed_offset * CV.KPH_TO_MS
|
||||
|
||||
if not controls_enabled or not getattr(starpilot_toggles, "speed_limit_controller", False):
|
||||
return spoofed_speed
|
||||
|
||||
slc_source = str(getattr(starpilot_plan, "slcSpeedLimitSource", "") or "")
|
||||
slc_speed_limit = float(getattr(starpilot_plan, "slcSpeedLimit", 0.0) or 0.0)
|
||||
slc_speed_limit_offset = float(getattr(starpilot_plan, "slcSpeedLimitOffset", 0.0) or 0.0)
|
||||
|
||||
if slc_source != "None" and slc_speed_limit > 0:
|
||||
return slc_speed_limit + slc_speed_limit_offset
|
||||
|
||||
return spoofed_speed
|
||||
|
||||
|
||||
@@ -141,8 +131,11 @@ class Controls:
|
||||
|
||||
# Check which actuators can be enabled
|
||||
standstill = abs(CS.vEgo) <= max(self.CP.minSteerSpeed, 0.3) or CS.standstill
|
||||
CC.latActive = (self.sm['selfdriveState'].active or self.sm['starpilotCarState'].alwaysOnLateralEnabled) and not CS.steerFaultTemporary and not CS.steerFaultPermanent and \
|
||||
(not standstill or self.CP.steerAtStandstill) and self.sm['starpilotPlan'].lateralCheck
|
||||
CC.latActive = get_lateral_active(CC.enabled, self.sm['selfdriveState'].active,
|
||||
self.sm['starpilotCarState'].alwaysOnLateralEnabled,
|
||||
CS.steerFaultTemporary, CS.steerFaultPermanent,
|
||||
standstill, self.CP.steerAtStandstill,
|
||||
self.sm['starpilotPlan'].lateralCheck)
|
||||
CC.longActive = CC.enabled and not any(e.overrideLongitudinal for e in self.sm['onroadEvents']) and not self.sm['starpilotCarState'].pauseLongitudinal and self.CP.openpilotLongitudinalControl
|
||||
|
||||
actuators = CC.actuators
|
||||
@@ -222,7 +215,7 @@ class Controls:
|
||||
getattr(self.starpilot_toggles, "gm_dash_spoof_offsets", False)
|
||||
)
|
||||
if gm_dash_spoof_offsets_enabled:
|
||||
hud_set_speed = get_gm_hud_set_speed(hud_set_speed, CC.enabled, self.starpilot_toggles, self.sm['starpilotPlan'])
|
||||
hud_set_speed = get_gm_hud_set_speed(hud_set_speed, self.starpilot_toggles)
|
||||
hudControl.setSpeed = hud_set_speed
|
||||
hudControl.speedVisible = CC.enabled
|
||||
hudControl.lanesVisible = CC.enabled
|
||||
|
||||
@@ -56,6 +56,14 @@ def get_accel_from_plan(speeds, accels, t_idxs, action_t=DT_MDL, vEgoStopping=0.
|
||||
# Backward-compatible alias used by tinygrad_modeld.
|
||||
get_accel_from_plan_tomb_raider = get_accel_from_plan
|
||||
|
||||
|
||||
def get_lateral_active(enabled: bool, active: bool, always_on_lateral_enabled: bool,
|
||||
steer_fault_temporary: bool, steer_fault_permanent: bool,
|
||||
standstill: bool, steer_at_standstill: bool, lateral_check: bool) -> bool:
|
||||
lateral_allowed = (enabled and active) or always_on_lateral_enabled
|
||||
return lateral_allowed and not steer_fault_temporary and not steer_fault_permanent and \
|
||||
(not standstill or steer_at_standstill) and lateral_check
|
||||
|
||||
def curv_from_psis(psi_target, psi_rate, vego, action_t):
|
||||
vego = np.clip(vego, MIN_SPEED, np.inf)
|
||||
curv_from_psi = psi_target / (vego * action_t)
|
||||
|
||||
@@ -152,21 +152,21 @@ VOLT_STANDARD_FF_CUTOFF = 1.30
|
||||
VOLT_STANDARD_FF_CUTOFF_WIDTH = 0.24
|
||||
VOLT_STANDARD_TRANSITION_SPEED = 10.0
|
||||
VOLT_STANDARD_PHASE_SCALE = 0.10
|
||||
VOLT_STANDARD_TURN_IN_BOOST_LEFT = -0.08
|
||||
VOLT_STANDARD_TURN_IN_BOOST_RIGHT = 0.20
|
||||
VOLT_STANDARD_TURN_IN_BOOST_LEFT = -0.04
|
||||
VOLT_STANDARD_TURN_IN_BOOST_RIGHT = 0.24
|
||||
VOLT_STANDARD_UNWIND_TAPER_LEFT = 0.03
|
||||
VOLT_STANDARD_UNWIND_TAPER_RIGHT = 0.02
|
||||
VOLT_STANDARD_UNWIND_TAPER_RIGHT = 0.08
|
||||
VOLT_STANDARD_FRICTION_MULT = 1.04
|
||||
VOLT_STANDARD_FRICTION_LAT_RISE = 0.20
|
||||
VOLT_STANDARD_FRICTION_JERK_RISE = 0.24
|
||||
VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_LEFT = -0.08
|
||||
VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_RIGHT = 0.12
|
||||
VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_LEFT = -0.04
|
||||
VOLT_STANDARD_TURN_IN_THRESHOLD_REDUCTION_RIGHT = 0.14
|
||||
VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_LEFT = -0.06
|
||||
VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_RIGHT = -0.08
|
||||
VOLT_STANDARD_TURN_IN_FRICTION_BOOST_LEFT = -0.03
|
||||
VOLT_STANDARD_TURN_IN_FRICTION_BOOST_RIGHT = 0.06
|
||||
VOLT_STANDARD_UNWIND_THRESHOLD_INCREASE_RIGHT = 0.04
|
||||
VOLT_STANDARD_TURN_IN_FRICTION_BOOST_LEFT = -0.02
|
||||
VOLT_STANDARD_TURN_IN_FRICTION_BOOST_RIGHT = 0.08
|
||||
VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_LEFT = -0.04
|
||||
VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_RIGHT = -0.06
|
||||
VOLT_STANDARD_UNWIND_FRICTION_REDUCTION_RIGHT = 0.04
|
||||
|
||||
GENESIS_G90_LATERAL_TESTING_GROUND_ID = testing_ground.id_4
|
||||
GENESIS_G90_FF_GAIN_LEFT = 0.09
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import get_lateral_active
|
||||
|
||||
|
||||
def test_get_lateral_active_requires_enabled_without_aol():
|
||||
assert not get_lateral_active(False, True, False, False, False, False, False, True)
|
||||
|
||||
|
||||
def test_get_lateral_active_allows_aol_while_disabled():
|
||||
assert get_lateral_active(False, False, True, False, False, False, False, True)
|
||||
@@ -158,7 +158,7 @@ class TestLatControl:
|
||||
left_unwind = get_volt_standard_friction_threshold(6.0, 0.7, -0.8)
|
||||
right_unwind = get_volt_standard_friction_threshold(6.0, -0.7, 0.8)
|
||||
assert left_turn_in > base > right_turn_in
|
||||
assert left_unwind < base and right_unwind < base
|
||||
assert left_unwind < base < right_unwind
|
||||
|
||||
def test_volt_standard_friction_scale_curve(self):
|
||||
base = get_volt_standard_friction_scale(25.0, 0.7, 0.8)
|
||||
@@ -167,7 +167,7 @@ class TestLatControl:
|
||||
left_unwind = get_volt_standard_friction_scale(6.0, 0.7, -0.8)
|
||||
right_unwind = get_volt_standard_friction_scale(6.0, -0.7, 0.8)
|
||||
assert left_turn_in < base < right_turn_in
|
||||
assert left_unwind > base and right_unwind > base
|
||||
assert left_unwind > base > right_unwind
|
||||
|
||||
def test_genesis_g90_ff_scale_curve(self):
|
||||
assert get_genesis_g90_ff_scale(0.0, 0.0, 20.0) == 1.0
|
||||
|
||||
@@ -2019,7 +2019,7 @@
|
||||
{
|
||||
"key": "GMDashSpoofOffsets",
|
||||
"label": "Apply Offsets To Dash Spoof",
|
||||
"description": "On GM pedal-long cars, add the active global set-speed offset or SLC offset to the spoofed dash set speed.",
|
||||
"description": "On GM pedal-long cars, add the configured set-speed offset to the spoofed dash set speed so it matches the on-screen set speed.",
|
||||
"data_type": "bool",
|
||||
"ui_type": "toggle"
|
||||
},
|
||||
|
||||
@@ -175,7 +175,7 @@ StarPilotVehiclesPanel::StarPilotVehiclesPanel(StarPilotSettingsWindow *parent,
|
||||
std::vector<std::tuple<QString, QString, QString, QString>> vehicleToggles {
|
||||
{"GMToggles", tr("General Motors Settings"), tr("<b>StarPilot features for General Motors vehicles.</b>"), ""},
|
||||
{"GMPedalLongitudinal", tr("Use Pedal For Longitudinal"), tr("<b>Use the pedal interceptor for full longitudinal control</b> on supported GM vehicles."), ""},
|
||||
{"GMDashSpoofOffsets", tr("Apply Offsets To Dash Spoof"), tr("<b>On GM pedal-long cars, add the active global set-speed offset or SLC offset</b> to the spoofed dash set speed."), ""},
|
||||
{"GMDashSpoofOffsets", tr("Apply Offsets To Dash Spoof"), tr("<b>On GM pedal-long cars, add the configured set-speed offset</b> to the spoofed dash set speed so it matches the on-screen set speed."), ""},
|
||||
{"LongPitch", tr("Smooth Pedal Response on Hills"), tr("<b>Smoothen acceleration and braking</b> when driving downhill/uphill."), ""},
|
||||
{"RemoteStartBootsComma", tr("Remote Start Boots comma"), tr("<b>Use the remote-start GM panda firmware at boot.</b><br><br>Required for GM remote-start startup signal behavior."), ""},
|
||||
{"RemapCancelToDistance", tr("Remap Cancel To Distance"), tr("<b>On pedal-interceptor Bolts, remap the steering-wheel CANCEL button to distance/personality input.</b>"), ""},
|
||||
|
||||
Reference in New Issue
Block a user