diff --git a/opendbc_repo/opendbc/car/interfaces.py b/opendbc_repo/opendbc/car/interfaces.py index 5728fff..eeddbd0 100644 --- a/opendbc_repo/opendbc/car/interfaces.py +++ b/opendbc_repo/opendbc/car/interfaces.py @@ -213,7 +213,7 @@ class CarInterfaceBase(ABC): dbc_names = {bus: cp.dbc_name for bus, cp in self.can_parsers.items()} self.CC: CarControllerBase = CarController(dbc_names, CP) - Params().put('LongitudinalPersonalityMax', "3") + Params().put('LongitudinalPersonalityMax', "4") # 强制调整4 eps_firmware = str(next((fw.fwVersion for fw in CP.carFw if fw.ecu == "eps"), "")) comma_nnff_supported = self.check_comma_nn_ff_support(CP.carFingerprint) @@ -221,7 +221,7 @@ class CarInterfaceBase(ABC): self.use_nnff = not comma_nnff_supported and nnff_supported and Params().get_bool("NNFF") self.use_nnff_lite = not self.use_nnff and Params().get_bool("NNFFLite") - + def get_ff_nn(self, x): return self.lat_torque_nn_model.evaluate(x) @@ -233,7 +233,7 @@ class CarInterfaceBase(ABC): def initialize_lat_torque_nn(self, car, eps_firmware) -> bool: self.lat_torque_nn_model = get_nn_model(car, eps_firmware) return self.lat_torque_nn_model is not None - + def apply(self, c: structs.CarControl, now_nanos: int | None = None) -> tuple[structs.CarControl.Actuators, list[CanData]]: if now_nanos is None: @@ -267,7 +267,7 @@ class CarInterfaceBase(ABC): ret.flags |= int(platform.config.flags) ret = cls._get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs) - + # Enable torque controller for all cars that do not use angle based steering if ret.steerControlType != structs.CarParams.SteerControlType.angle and Params().get_bool("NNFF"): CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning) @@ -276,7 +276,7 @@ class CarInterfaceBase(ABC): if model is not None: Params().put_nonblocking("NNFFModelName", candidate.replace("_", " ")) print(f"NNFF loaded... {model}") - + if Params().get_bool("DisableMinSteerSpeed"): ret.minSteerSpeed = 0. @@ -453,7 +453,7 @@ class CarStateBase(ABC): v_ego_x = self.v_ego_kf.update(v_ego_raw) return float(v_ego_x[0]), float(v_ego_x[1]) - + def update_clu_speed_kf(self, v_ego_raw): if abs(v_ego_raw - self.v_ego_clu_kf.x[0][0]) > 2.0: # Prevent large accelerations when car starts at non zero speed self.v_ego_clu_kf.set_x([[v_ego_raw], [0.0]]) diff --git a/selfdrive/car/cruise.py b/selfdrive/car/cruise.py index 98a9b2f..fc7631e 100644 --- a/selfdrive/car/cruise.py +++ b/selfdrive/car/cruise.py @@ -438,8 +438,8 @@ class VCruiseCarrot: speed_kph = int(self.carrot_arg) if 0 < speed_kph < 200: v_cruise_kph = speed_kph - self._add_log(f"Cruise speed set to {v_cruise_kph} (carrot command)") - + self._add_log(f"Cruise speed set to {v_cruise_kph} (carrot command)") + return v_cruise_kph, button_type, long_pressed def _update_cruise_buttons(self, CS, CC, v_cruise_kph): @@ -512,7 +512,11 @@ class VCruiseCarrot: v_cruise_kph = button_kph self._v_cruise_kph_at_brake = 0 elif button_type == ButtonType.gapAdjustCruise: - self.params.put_int_nonblocking("MyDrivingMode", self.params.get_int("MyDrivingMode") % 4 + 1) # 1,2,3,4 (1:eco, 2:safe, 3:normal, 4:high speed) + current_speed_mode = self.params.get_int("SpeedFromPCM") + new_speed_mode = (current_speed_mode + 1) % 3 + self.params.put_int_nonblocking("SpeedFromPCM", new_speed_mode) + self._add_log(f"SpeedFromPCM changed to {new_speed_mode}") + #self.params.put_int_nonblocking("MyDrivingMode", self.params.get_int("MyDrivingMode") % 4 + 1) # 1,2,3,4 (1:eco, 2:safe, 3:normal, 4:high speed) elif button_type == ButtonType.lfaButton: useLaneLineSpeed = max(1, self.useLaneLineSpeed) self.params.put_int_nonblocking("UseLaneLineSpeedApply", useLaneLineSpeed if self.params.get_int("UseLaneLineSpeedApply") == 0 else 0)