sunnypilot v2026.002.000
version: sunnypilot v2026.002.000 (staging) date: 2026-07-21T07:44:02 master commit: 2c334ede443d7391d27575af8c854a095ba702a8
This commit is contained in:
commit
de77c89cf6
3995 files changed
+1260688
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
|
||||
from enum import StrEnum
|
||||
|
||||
from opendbc.car import Bus, structs
|
||||
from opendbc.can.parser import CANParser
|
||||
from opendbc.sunnypilot.car.nissan.values import BUTTONS
|
||||
|
||||
|
||||
class CarStateExt:
|
||||
def __init__(self, CP, CP_SP):
|
||||
self.CP = CP
|
||||
self.CP_SP = CP_SP
|
||||
|
||||
self.button_events = []
|
||||
self.button_states = {button.event_type: False for button in BUTTONS}
|
||||
|
||||
def update(self, ret: structs.CarState, ret_sp: structs.CarStateSP, can_parsers: dict[StrEnum, CANParser]):
|
||||
cp = can_parsers[Bus.pt]
|
||||
|
||||
button_events = []
|
||||
for button in BUTTONS:
|
||||
state = (cp.vl[button.can_addr][button.can_msg] in button.values)
|
||||
if self.button_states[button.event_type] != state:
|
||||
event = structs.CarState.ButtonEvent.new_message()
|
||||
event.type = button.event_type
|
||||
event.pressed = state
|
||||
button_events.append(event)
|
||||
self.button_states[button.event_type] = state
|
||||
self.button_events = button_events
|
||||
@@ -0,0 +1,67 @@
|
||||
"""
|
||||
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
|
||||
from opendbc.car.nissan.values import CAR
|
||||
|
||||
LEAF_CRUISE_THROTTLE_SIGNALS = [
|
||||
"GAS_PEDAL",
|
||||
"GAS_PEDAL_INVERTED",
|
||||
"unsure2",
|
||||
"CRUISE_AVAILABLE",
|
||||
"unsure1",
|
||||
"PROPILOT_BUTTON",
|
||||
"CANCEL_BUTTON",
|
||||
"FOLLOW_DISTANCE_BUTTON",
|
||||
"SET_BUTTON",
|
||||
"RES_BUTTON",
|
||||
"NO_BUTTON_PRESSED",
|
||||
"unsure3",
|
||||
"COUNTER",
|
||||
"USER_BRAKE_PRESSED",
|
||||
"unsure5",
|
||||
"unsure6",
|
||||
"unsure7",
|
||||
]
|
||||
|
||||
XTRAIL_CRUISE_THROTTLE_SIGNALS = [
|
||||
"COUNTER",
|
||||
"PROPILOT_BUTTON",
|
||||
"CANCEL_BUTTON",
|
||||
"GAS_PEDAL_INVERTED",
|
||||
"SET_BUTTON",
|
||||
"RES_BUTTON",
|
||||
"FOLLOW_DISTANCE_BUTTON",
|
||||
"NO_BUTTON_PRESSED",
|
||||
"GAS_PEDAL",
|
||||
"USER_BRAKE_PRESSED",
|
||||
"USER_BRAKE_PRESSED_INVERTED",
|
||||
"NEW_SIGNAL_2",
|
||||
"GAS_PRESSED_INVERTED",
|
||||
"unsure1",
|
||||
"unsure2",
|
||||
"unsure3",
|
||||
]
|
||||
|
||||
|
||||
def create_cruise_throttle_msg(packer, car_fingerprint, cruise_throttle_msg, frame, button_name=None):
|
||||
signals = LEAF_CRUISE_THROTTLE_SIGNALS if car_fingerprint in (CAR.NISSAN_LEAF, CAR.NISSAN_LEAF_IC) else XTRAIL_CRUISE_THROTTLE_SIGNALS
|
||||
values = {s: cruise_throttle_msg[s] for s in signals}
|
||||
|
||||
can_bus = 1 if car_fingerprint == CAR.NISSAN_ALTIMA else 2
|
||||
|
||||
values["COUNTER"] = (frame // 2) % 4
|
||||
|
||||
if (button_name is not None) and (not values["CANCEL_BUTTON"]):
|
||||
values["NO_BUTTON_PRESSED"] = 0
|
||||
values["PROPILOT_BUTTON"] = 0
|
||||
values["SET_BUTTON"] = 0
|
||||
values["RES_BUTTON"] = 0
|
||||
values["FOLLOW_DISTANCE_BUTTON"] = 0
|
||||
values["CANCEL_BUTTON"] = 0
|
||||
values[button_name] = 1
|
||||
|
||||
return packer.make_can_msg("CRUISE_THROTTLE", can_bus, values)
|
||||
@@ -0,0 +1,24 @@
|
||||
"""
|
||||
Copyright (c) 2021-, Haibin Wen, sunnypilot, and a number of other contributors.
|
||||
|
||||
This file is part of sunnypilot and is licensed under the MIT License.
|
||||
See the LICENSE.md file in the root directory for more details.
|
||||
"""
|
||||
|
||||
from collections import namedtuple
|
||||
from opendbc.car import structs
|
||||
|
||||
|
||||
class NissanSafetyFlagsSP:
|
||||
DEFAULT = 0
|
||||
LEAF = 1
|
||||
|
||||
|
||||
ButtonType = structs.CarState.ButtonEvent.Type
|
||||
Button = namedtuple('Button', ['event_type', 'can_addr', 'can_msg', 'values'])
|
||||
|
||||
|
||||
BUTTONS = [
|
||||
Button(ButtonType.accelCruise, "CRUISE_THROTTLE", "RES_BUTTON", [1]),
|
||||
Button(ButtonType.decelCruise, "CRUISE_THROTTLE", "SET_BUTTON", [1]),
|
||||
]
|
||||
Reference in new issue
Block a user