Compare commits

...

25 Commits

Author SHA1 Message Date
firestar5683 3a5b3411bc Update opendbc_repo 2025-08-11 21:22:30 -05:00
firestar5683 0724c290f2 Reapply "Update cruise.py"
This reverts commit 6753b8f490.
2025-08-11 18:45:24 -05:00
firestar5683 076fbbe102 Reapply "Merge remote-tracking branch 'origin/master' into SunnyPilot"
This reverts commit 42b6ecb535.
2025-08-11 18:44:44 -05:00
firestar5683 f56b049010 Update opendbc_repo 2025-08-11 16:53:35 -05:00
firestar5683 eb1e70d9c7 Revert "undo"
This reverts commit 039e89d92a.
2025-08-11 16:53:06 -05:00
firestar5683 039e89d92a undo 2025-08-11 16:51:33 -05:00
firestar5683 42b6ecb535 Revert "Merge remote-tracking branch 'origin/master' into SunnyPilot"
This reverts commit bd4ed9d316, reversing
changes made to f047a7d008.
2025-08-11 16:51:13 -05:00
firestar5683 827c9cede9 Revert "update submodules"
This reverts commit b5cf8a520d.
2025-08-11 16:51:10 -05:00
firestar5683 6753b8f490 Revert "Update cruise.py"
This reverts commit fef711a206.
2025-08-11 16:51:08 -05:00
firestar5683 34894ffeab Revert "Update panda"
This reverts commit 09ef4b64ff.
2025-08-11 16:51:04 -05:00
firestar5683 0a9046c594 Revert "Update tinygrad_repo"
This reverts commit edf384d37e.
2025-08-11 16:51:02 -05:00
firestar5683 8b47b3c1f8 Revert "Update opendbc_repo"
This reverts commit f13335fe67.
2025-08-11 16:51:00 -05:00
firestar5683 f13335fe67 Update opendbc_repo 2025-08-11 16:42:40 -05:00
firestar5683 edf384d37e Update tinygrad_repo 2025-08-11 16:33:31 -05:00
firestar5683 09ef4b64ff Update panda 2025-08-11 16:32:53 -05:00
firestar5683 fef711a206 Update cruise.py 2025-08-11 16:00:22 -05:00
firestar5683 b5cf8a520d update submodules 2025-08-11 15:55:41 -05:00
firestar5683 bd4ed9d316 Merge remote-tracking branch 'origin/master' into SunnyPilot 2025-08-11 15:53:36 -05:00
firestar5683 f047a7d008 Updates 2025-08-11 15:04:31 -05:00
firestar5683 2e884610c1 Merge branch 'SunnyPilot' of https://github.com/firestar5683/StarPilot into SunnyPilot 2025-07-29 01:33:41 -05:00
firestar5683 87c29b0ee1 OPGM 2025-07-29 01:33:36 -05:00
firestar5683 c5113e8ea6 Update car_specific.py 2025-07-29 01:33:01 -05:00
firestar5683 88f7cb5f05 Update opendbc_repo 2025-07-29 01:27:38 -05:00
firestar5683 14b3d0ca38 OPGM 2025-07-29 01:27:35 -05:00
firestar5683 d52a823fa3 OPGM 2025-07-29 01:27:21 -05:00
7 changed files with 59 additions and 10 deletions
+15 -1
View File
@@ -1,6 +1,7 @@
from cereal import car, log, custom
import cereal.messaging as messaging
from opendbc.car import DT_CTRL, structs
from opendbc.car.gm.values import GMFlags
from opendbc.car.interfaces import MAX_CTRL_SPEED
from openpilot.selfdrive.selfdrived.events import Events
@@ -103,13 +104,26 @@ class CarSpecificEvents:
if CS.vEgo < self.CP.minEnableSpeed and not (CS.standstill and CS.brake >= 20 and
self.CP.networkLocation == NetworkLocation.fwdCamera):
events.add(EventName.belowEngageSpeed)
if CS.cruiseState.standstill:
if CS.cruiseState.standstill and not self.CP.autoResumeSng:
events.add(EventName.resumeRequired)
if CS.vEgo < self.CP.minSteerSpeed:
events.add(EventName.belowSteerSpeed)
if (self.CP.flags & GMFlags.CC_LONG) and CS.vEgo < self.CP.minEnableSpeed and CS.cruiseState.enabled:
events.add(EventName.speedTooLow)
elif self.CP.brand == 'volkswagen':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic],
pcm_enable=self.CP.pcmCruise)
# Low speed steer alert hysteresis logic
if (self.CP.minSteerSpeed - 1e-3) > VWCarControllerParams.DEFAULT_MIN_STEER_SPEED and CS.vEgo < (self.CP.minSteerSpeed + 1.):
self.low_speed_alert = True
elif CS.vEgo > (self.CP.minSteerSpeed + 2.):
self.low_speed_alert = False
if self.low_speed_alert:
events.add(EventName.belowSteerSpeed)
if self.CP.openpilotLongitudinalControl:
if CS.vEgo < self.CP.minEnableSpeed + 0.5:
events.add(EventName.belowEngageSpeed)
+8 -2
View File
@@ -11,7 +11,7 @@ from openpilot.common.params import Params
from openpilot.common.realtime import config_realtime_process, Priority, Ratekeeper
from openpilot.common.swaglog import cloudlog, ForwardingHandler
from opendbc.car import DT_CTRL, structs
from opendbc.car import DT_CTRL, structs, ButtonType
from opendbc.car.can_definitions import CanData, CanRecvCallable, CanSendCallable
from opendbc.car.carlog import carlog
from opendbc.car.fw_versions import ObdCallback
@@ -80,6 +80,7 @@ class Car:
self.CS_prev = car.CarState.new_message()
self.CS_SP_prev = custom.CarStateSP.new_message()
self.initialized_prev = False
self.resume_prev_button = False
self.last_actuators_output = structs.CarControl.Actuators()
@@ -217,12 +218,17 @@ class Car:
self.v_cruise_helper.update_v_cruise(CS, self.sm['carControl'].enabled, self.is_metric)
if self.sm['carControl'].enabled and not self.CC_prev.enabled:
# Use CarState w/ buttons from the step selfdrived enables on
self.v_cruise_helper.initialize_v_cruise(self.CS_prev, self.experimental_mode, self.dynamic_experimental_control)
self.v_cruise_helper.initialize_v_cruise(self.CS_prev, self.experimental_mode, self.dynamic_experimental_control, self.resume_prev_button)
# TODO: mirror the carState.cruiseState struct?
CS.vCruise = float(self.v_cruise_helper.v_cruise_kph)
CS.vCruiseCluster = float(self.v_cruise_helper.v_cruise_cluster_kph)
if any(be.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for be in CS.buttonEvents):
self.resume_prev_button = True
elif any(be.type in (ButtonType.decelCruise, ButtonType.setCruise) for be in CS.buttonEvents):
self.resume_prev_button = False
return CS, CS_SP, RD
def state_publish(self, CS: car.CarState, CS_SP: custom.CarStateSP, RD: structs.RadarDataT | None):
+7 -4
View File
@@ -2,6 +2,7 @@ import math
import numpy as np
from cereal import car
from opendbc.car.gm.values import CC_ONLY_CAR, GMFlags
from openpilot.common.constants import CV
from openpilot.sunnypilot.selfdrive.car.cruise_ext import VCruiseHelperSP
@@ -33,6 +34,7 @@ class VCruiseHelper(VCruiseHelperSP):
def __init__(self, CP):
VCruiseHelperSP.__init__(self)
self.CP = CP
self.gm_cc_only = self.CP.carFingerprint in CC_ONLY_CAR and self.CP.flags & GMFlags.CC_LONG.value
self.v_cruise_kph = V_CRUISE_UNSET
self.v_cruise_cluster_kph = V_CRUISE_UNSET
self.v_cruise_kph_last = 0
@@ -47,7 +49,7 @@ class VCruiseHelper(VCruiseHelperSP):
self.v_cruise_kph_last = self.v_cruise_kph
if CS.cruiseState.available:
if not self.CP.pcmCruise:
if self.gm_cc_only or not self.CP.pcmCruise:
# if stock cruise is completely disabled, then we can use our own set speed logic
self._update_v_cruise_non_pcm(CS, enabled, is_metric)
self.v_cruise_cluster_kph = self.v_cruise_kph
@@ -125,15 +127,16 @@ class VCruiseHelper(VCruiseHelperSP):
self.button_timers[b.type.raw] = 1 if b.pressed else 0
self.button_change_states[b.type.raw] = {"standstill": CS.cruiseState.standstill, "enabled": enabled}
def initialize_v_cruise(self, CS, experimental_mode: bool, dynamic_experimental_control: bool) -> None:
def initialize_v_cruise(self, CS, experimental_mode: bool, dynamic_experimental_control, resume_prev_button: bool) -> None:
# initializing is handled by the PCM
if self.CP.pcmCruise:
if self.CP.pcmCruise and not self.gm_cc_only:
return
initial_experimental_mode = experimental_mode and not dynamic_experimental_control
initial = V_CRUISE_INITIAL_EXPERIMENTAL_MODE if initial_experimental_mode else V_CRUISE_INITIAL
if any(b.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for b in CS.buttonEvents) and self.v_cruise_initialized:
if (any(b.type in (ButtonType.accelCruise, ButtonType.resumeCruise) for b in CS.buttonEvents)
and self.v_cruise_initialized or (self.gm_cc_only and resume_prev_button)):
self.v_cruise_kph = self.v_cruise_kph_last
else:
self.v_cruise_kph = int(round(np.clip(CS.vEgo * CV.MS_TO_KPH, initial, V_CRUISE_MAX)))
+3
View File
@@ -133,6 +133,9 @@ class Controls(ControlsExt, ModelStateBase):
pid_accel_limits = self.CI.get_pid_accel_limits(self.CP, CS.vEgo, CS.vCruise * CV.KPH_TO_MS)
actuators.accel = float(self.LoC.update(CC.longActive, CS, long_plan.aTarget, long_plan.shouldStop, pid_accel_limits))
if len(long_plan.speeds):
actuators.speed = long_plan.speeds[-1]
# Steering PID loop and lateral MPC
# Reset desired curvature to current to avoid violating the limits on engage
new_desired_curvature = model_v2.action.desiredCurvature if CC.latActive else self.curvature
+21
View File
@@ -63,3 +63,24 @@ def get_curvature_from_plan(yaws, yaw_rates, t_idxs, vego, action_t):
psi_target = np.interp(action_t, t_idxs, yaws)
psi_rate = yaw_rates[0]
return curv_from_psis(psi_target, psi_rate, vego, action_t)
def interp(x, xp, fp):
N = len(xp)
def get_interp(xv):
hi = 0
while hi < N and xv > xp[hi]:
hi += 1
low = hi - 1
return fp[-1] if hi == N and xv > xp[low] else (
fp[0] if hi == 0 else
(xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low])
return [get_interp(v) for v in x] if hasattr(x, '__iter__') else get_interp(x)
def apply_deadzone(error, deadzone):
if error > deadzone:
error -= deadzone
elif error < -deadzone:
error += deadzone
else:
error = 0.
return error
+4 -2
View File
@@ -1,7 +1,7 @@
import numpy as np
from cereal import car
from openpilot.common.realtime import DT_CTRL
from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N
from openpilot.selfdrive.controls.lib.drive_helpers import CONTROL_N, apply_deadzone, interp
from openpilot.common.pid import PIDController
from openpilot.selfdrive.modeld.constants import ModelConstants
@@ -80,8 +80,10 @@ class LongControl:
self.reset()
else: # LongCtrlState.pid
deadzone = interp(CS.vEgo, self.CP.longitudinalTuning.deadzoneBPDEPRECATED, self.CP.longitudinalTuning.deadzoneVDEPRECATED)
error = a_target - CS.aEgo
output_accel = self.pid.update(error, speed=CS.vEgo,
error_deadzone = apply_deadzone(error, deadzone)
output_accel = self.pid.update(error_deadzone, speed=CS.vEgo,
feedforward=a_target)
self.last_output_accel = np.clip(output_accel, accel_limits[0], accel_limits[1])