You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
118 lines
3.7 KiB
118 lines
3.7 KiB
2 years ago
|
from dataclasses import dataclass, field
|
||
2 months ago
|
from enum import IntFlag
|
||
2 years ago
|
|
||
2 months ago
|
from opendbc.car import AngleSteeringLimits, Bus, CarSpecs, DbcDict, PlatformConfig, Platforms, uds
|
||
|
from opendbc.car.structs import CarParams
|
||
|
from opendbc.car.docs_definitions import CarDocs, CarHarness, CarParts
|
||
|
from opendbc.car.fw_query_definitions import FwQueryConfig, Request, StdQueries
|
||
2 years ago
|
|
||
2 months ago
|
Ecu = CarParams.Ecu
|
||
2 years ago
|
|
||
|
|
||
|
class CarControllerParams:
|
||
2 months ago
|
ANGLE_LIMITS: AngleSteeringLimits = AngleSteeringLimits(
|
||
|
# When output steering Angle not within range -1311 and 1310,
|
||
|
# CANPacker packs wrong angle output to be decoded by panda
|
||
|
600, # deg, reasonable limit
|
||
|
([0., 5., 15.], [5., .8, .15]),
|
||
|
([0., 5., 15.], [5., 3.5, 0.4]),
|
||
|
)
|
||
|
|
||
2 years ago
|
LKAS_MAX_TORQUE = 1 # A value of 1 is easy to overpower
|
||
|
STEER_THRESHOLD = 1.0
|
||
|
|
||
|
def __init__(self, CP):
|
||
|
pass
|
||
|
|
||
|
|
||
2 months ago
|
class NissanSafetyFlags(IntFlag):
|
||
|
ALT_EPS_BUS = 1
|
||
|
|
||
|
|
||
2 years ago
|
@dataclass
|
||
11 months ago
|
class NissanCarDocs(CarDocs):
|
||
2 years ago
|
package: str = "ProPILOT Assist"
|
||
|
car_parts: CarParts = field(default_factory=CarParts.common([CarHarness.nissan_a]))
|
||
|
|
||
|
|
||
11 months ago
|
@dataclass(frozen=True)
|
||
|
class NissanCarSpecs(CarSpecs):
|
||
|
centerToFrontRatio: float = 0.44
|
||
|
steerRatio: float = 17.
|
||
|
|
||
|
|
||
|
@dataclass
|
||
|
class NissanPlatformConfig(PlatformConfig):
|
||
2 months ago
|
dbc_dict: DbcDict = field(default_factory=lambda: {Bus.pt: 'nissan_x_trail_2017_generated'})
|
||
11 months ago
|
|
||
|
|
||
|
class CAR(Platforms):
|
||
|
NISSAN_XTRAIL = NissanPlatformConfig(
|
||
|
[NissanCarDocs("Nissan X-Trail 2017")],
|
||
|
NissanCarSpecs(mass=1610, wheelbase=2.705)
|
||
|
)
|
||
|
NISSAN_LEAF = NissanPlatformConfig(
|
||
|
[NissanCarDocs("Nissan Leaf 2018-23", video_link="https://youtu.be/vaMbtAh_0cY")],
|
||
|
NissanCarSpecs(mass=1610, wheelbase=2.705),
|
||
2 months ago
|
{Bus.pt: 'nissan_leaf_2018_generated'},
|
||
11 months ago
|
)
|
||
|
# Leaf with ADAS ECU found behind instrument cluster instead of glovebox
|
||
|
# Currently the only known difference between them is the inverted seatbelt signal.
|
||
|
NISSAN_LEAF_IC = NISSAN_LEAF.override(car_docs=[])
|
||
|
NISSAN_ROGUE = NissanPlatformConfig(
|
||
|
[NissanCarDocs("Nissan Rogue 2018-20")],
|
||
|
NissanCarSpecs(mass=1610, wheelbase=2.705)
|
||
|
)
|
||
|
NISSAN_ALTIMA = NissanPlatformConfig(
|
||
|
[NissanCarDocs("Nissan Altima 2019-20", car_parts=CarParts.common([CarHarness.nissan_b]))],
|
||
|
NissanCarSpecs(mass=1492, wheelbase=2.824)
|
||
|
)
|
||
|
|
||
|
|
||
|
DBC = CAR.create_dbc_map()
|
||
2 years ago
|
|
||
2 years ago
|
# Default diagnostic session
|
||
2 years ago
|
NISSAN_DIAGNOSTIC_REQUEST_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0x81])
|
||
|
NISSAN_DIAGNOSTIC_RESPONSE_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0x81])
|
||
|
|
||
2 years ago
|
# Manufacturer specific
|
||
|
NISSAN_DIAGNOSTIC_REQUEST_KWP_2 = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0xda])
|
||
|
NISSAN_DIAGNOSTIC_RESPONSE_KWP_2 = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL + 0x40, 0xda])
|
||
|
|
||
2 years ago
|
NISSAN_VERSION_REQUEST_KWP = b'\x21\x83'
|
||
|
NISSAN_VERSION_RESPONSE_KWP = b'\x61\x83'
|
||
|
|
||
|
NISSAN_RX_OFFSET = 0x20
|
||
|
|
||
|
FW_QUERY_CONFIG = FwQueryConfig(
|
||
1 year ago
|
requests=[request for bus, logging in ((0, False), (1, True)) for request in [
|
||
2 years ago
|
Request(
|
||
|
[NISSAN_DIAGNOSTIC_REQUEST_KWP, NISSAN_VERSION_REQUEST_KWP],
|
||
|
[NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP],
|
||
1 year ago
|
bus=bus,
|
||
|
logging=logging,
|
||
2 years ago
|
),
|
||
|
Request(
|
||
|
[NISSAN_DIAGNOSTIC_REQUEST_KWP, NISSAN_VERSION_REQUEST_KWP],
|
||
|
[NISSAN_DIAGNOSTIC_RESPONSE_KWP, NISSAN_VERSION_RESPONSE_KWP],
|
||
|
rx_offset=NISSAN_RX_OFFSET,
|
||
1 year ago
|
bus=bus,
|
||
|
logging=logging,
|
||
2 years ago
|
),
|
||
2 years ago
|
# Rogue's engine solely responds to this
|
||
|
Request(
|
||
|
[NISSAN_DIAGNOSTIC_REQUEST_KWP_2, NISSAN_VERSION_REQUEST_KWP],
|
||
|
[NISSAN_DIAGNOSTIC_RESPONSE_KWP_2, NISSAN_VERSION_RESPONSE_KWP],
|
||
1 year ago
|
bus=bus,
|
||
|
logging=logging,
|
||
2 years ago
|
),
|
||
2 years ago
|
Request(
|
||
|
[StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST],
|
||
|
[StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE],
|
||
|
rx_offset=NISSAN_RX_OFFSET,
|
||
1 year ago
|
bus=bus,
|
||
|
logging=logging,
|
||
2 years ago
|
),
|
||
1 year ago
|
]],
|
||
2 years ago
|
)
|