mirror of https://github.com/1okko/openpilot.git
Merge branch 'upstream/openpilot/master' into sync-20240224
# Conflicts: # cereal # common/params.cc # selfdrive/car/chrysler/interface.py
This commit is contained in:
commit
4d8c13ba42
|
@ -96,8 +96,6 @@ lenv = {
|
|||
rpath = lenv["LD_LIBRARY_PATH"].copy()
|
||||
|
||||
if arch == "larch64":
|
||||
lenv["LD_LIBRARY_PATH"] += ['/data/data/com.termux/files/usr/lib']
|
||||
|
||||
cpppath = [
|
||||
"#third_party/opencl/include",
|
||||
]
|
||||
|
@ -360,13 +358,6 @@ Export('common', 'gpucommon')
|
|||
# Build cereal and messaging
|
||||
SConscript(['cereal/SConscript'])
|
||||
|
||||
cereal = [File('#cereal/libcereal.a')]
|
||||
messaging = [File('#cereal/libmessaging.a')]
|
||||
visionipc = [File('#cereal/libvisionipc.a')]
|
||||
messaging_python = [File('#cereal/messaging/messaging_pyx.so')]
|
||||
|
||||
Export('cereal', 'messaging', 'messaging_python', 'visionipc')
|
||||
|
||||
# Build other submodules
|
||||
SConscript([
|
||||
'body/board/SConscript',
|
||||
|
|
2
cereal
2
cereal
|
@ -1 +1 @@
|
|||
Subproject commit 6f8c147d22a8fce2d75a2b6fd3a49e6c1fe35553
|
||||
Subproject commit 6aff39be259914e1596cc6a582f434132ce0e810
|
|
@ -207,7 +207,6 @@ std::unordered_map<std::string, uint32_t> keys = {
|
|||
{"UpdaterLastFetchTime", PERSISTENT},
|
||||
{"Version", PERSISTENT},
|
||||
{"VisionRadarToggle", PERSISTENT},
|
||||
{"WheeledBody", PERSISTENT},
|
||||
|
||||
{"AccMadsCombo", PERSISTENT},
|
||||
{"AmapKey1", PERSISTENT},
|
||||
|
|
|
@ -62,4 +62,4 @@ A good pull request has all of the following:
|
|||
* Consider opting into driver camera uploads to improve the driver monitoring model.
|
||||
* Connect your device to Wi-Fi regularly, so that we can pull data for training better driving models.
|
||||
* Run the `nightly` branch and report issues. This branch is like `master` but it's built just like a release.
|
||||
* Annotate images in the [comma10k dateset](https://github.com/commaai/comma10k).
|
||||
* Annotate images in the [comma10k dataset](https://github.com/commaai/comma10k).
|
||||
|
|
|
@ -190,6 +190,7 @@ lint.flake8-implicit-str-concat.allow-multiline=false
|
|||
"system".msg = "Use openpilot.system"
|
||||
"third_party".msg = "Use openpilot.third_party"
|
||||
"tools".msg = "Use openpilot.tools"
|
||||
"pytest.main".msg = "pytest.main requires special handling that is easy to mess up!"
|
||||
|
||||
[tool.coverage.run]
|
||||
concurrency = ["multiprocessing", "thread"]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# functions common among cars
|
||||
from collections import namedtuple
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass, field, replace
|
||||
from enum import ReprEnum
|
||||
|
||||
import capnp
|
||||
|
@ -246,7 +246,7 @@ class CanSignalRateCalculator:
|
|||
CarInfos = CarInfo | list[CarInfo]
|
||||
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class CarSpecs:
|
||||
mass: float
|
||||
wheelbase: float
|
||||
|
@ -256,7 +256,7 @@ class CarSpecs:
|
|||
minEnableSpeed: float = field(default=-1.)
|
||||
|
||||
|
||||
@dataclass(order=True)
|
||||
@dataclass(frozen=True, order=True)
|
||||
class PlatformConfig:
|
||||
platform_str: str
|
||||
car_info: CarInfos
|
||||
|
@ -267,6 +267,9 @@ class PlatformConfig:
|
|||
def __hash__(self) -> int:
|
||||
return hash(self.platform_str)
|
||||
|
||||
def override(self, **kwargs):
|
||||
return replace(self, **kwargs)
|
||||
|
||||
|
||||
class Platforms(str, ReprEnum):
|
||||
config: PlatformConfig
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import numpy as np
|
||||
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.realtime import DT_CTRL
|
||||
from opendbc.can.packer import CANPacker
|
||||
from openpilot.selfdrive.car.body import bodycan
|
||||
|
@ -20,18 +19,13 @@ class CarController:
|
|||
self.frame = 0
|
||||
self.packer = CANPacker(dbc_name)
|
||||
|
||||
# Speed, balance and turn PIDs
|
||||
self.speed_pid = PIDController(0.115, k_i=0.23, rate=1/DT_CTRL)
|
||||
self.balance_pid = PIDController(1300, k_i=0, k_d=280, rate=1/DT_CTRL)
|
||||
# PIDs
|
||||
self.turn_pid = PIDController(110, k_i=11.5, rate=1/DT_CTRL)
|
||||
self.wheeled_speed_pid = PIDController(110, k_i=11.5, rate=1/DT_CTRL)
|
||||
|
||||
self.torque_r_filtered = 0.
|
||||
self.torque_l_filtered = 0.
|
||||
|
||||
params = Params()
|
||||
self.wheeled_body = params.get("WheeledBody")
|
||||
|
||||
@staticmethod
|
||||
def deadband_filter(torque, deadband):
|
||||
if torque > 0:
|
||||
|
@ -55,17 +49,7 @@ class CarController:
|
|||
speed_measured = SPEED_FROM_RPM * (CS.out.wheelSpeeds.fl + CS.out.wheelSpeeds.fr) / 2.
|
||||
speed_error = speed_desired - speed_measured
|
||||
|
||||
if self.wheeled_body is None:
|
||||
freeze_integrator = ((speed_error < 0 and self.speed_pid.error_integral <= -MAX_POS_INTEGRATOR) or
|
||||
(speed_error > 0 and self.speed_pid.error_integral >= MAX_POS_INTEGRATOR))
|
||||
angle_setpoint = self.speed_pid.update(speed_error, freeze_integrator=freeze_integrator)
|
||||
|
||||
# Clip angle error, this is enough to get up from stands
|
||||
angle_error = np.clip((-CC.orientationNED[1]) - angle_setpoint, -MAX_ANGLE_ERROR, MAX_ANGLE_ERROR)
|
||||
angle_error_rate = np.clip(-CC.angularVelocity[1], -1., 1.)
|
||||
torque = self.balance_pid.update(angle_error, error_rate=angle_error_rate)
|
||||
else:
|
||||
torque = self.wheeled_speed_pid.update(speed_error, freeze_integrator=False)
|
||||
torque = self.wheeled_speed_pid.update(speed_error, freeze_integrator=False)
|
||||
|
||||
speed_diff_measured = SPEED_FROM_RPM * (CS.out.wheelSpeeds.fl - CS.out.wheelSpeeds.fr)
|
||||
turn_error = speed_diff_measured - speed_diff_desired
|
||||
|
|
|
@ -24,7 +24,6 @@ class CarInterface(CarInterfaceBase):
|
|||
elif candidate in RAM_DT:
|
||||
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_CHRYSLER_RAM_DT
|
||||
|
||||
ret.minSteerSpeed = 3.8 # m/s
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning)
|
||||
if candidate not in RAM_CARS:
|
||||
# Newer FW versions standard on the following platforms, or flashed by a dealer onto older platforms have a higher minimum steering speed.
|
||||
|
@ -35,10 +34,6 @@ class CarInterface(CarInterfaceBase):
|
|||
|
||||
# Chrysler
|
||||
if candidate in (CAR.PACIFICA_2017_HYBRID, CAR.PACIFICA_2018, CAR.PACIFICA_2018_HYBRID, CAR.PACIFICA_2019_HYBRID, CAR.PACIFICA_2020, CAR.DODGE_DURANGO):
|
||||
ret.mass = 2242.
|
||||
ret.wheelbase = 3.089
|
||||
ret.steerRatio = 16.2 # Pacifica Hybrid 2017
|
||||
|
||||
ret.lateralTuning.init('pid')
|
||||
ret.lateralTuning.pid.kpBP, ret.lateralTuning.pid.kiBP = [[9., 20.], [9., 20.]]
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.15, 0.30], [0.03, 0.05]]
|
||||
|
@ -46,9 +41,6 @@ class CarInterface(CarInterfaceBase):
|
|||
|
||||
# Jeep
|
||||
elif candidate in (CAR.JEEP_GRAND_CHEROKEE, CAR.JEEP_GRAND_CHEROKEE_2019):
|
||||
ret.mass = 1778
|
||||
ret.wheelbase = 2.71
|
||||
ret.steerRatio = 16.7
|
||||
ret.steerActuatorDelay = 0.2
|
||||
|
||||
ret.lateralTuning.init('pid')
|
||||
|
@ -60,19 +52,12 @@ class CarInterface(CarInterfaceBase):
|
|||
elif candidate == CAR.RAM_1500:
|
||||
ret.steerActuatorDelay = 0.2
|
||||
ret.wheelbase = 3.88
|
||||
ret.steerRatio = 16.3
|
||||
ret.mass = 2493.
|
||||
ret.minSteerSpeed = 0.5
|
||||
ret.minEnableSpeed = 14.5
|
||||
if any(fw.ecu == 'eps' and fw.fwVersion in (b"68273275AF", b"68273275AG", b"68312176AE", b"68312176AG",) for fw in car_fw):
|
||||
ret.minEnableSpeed = 0.
|
||||
# Older EPS FW allow steer to zero
|
||||
if any(fw.ecu == 'eps' and b"68" < fw.fwVersion[:4] <= b"6831" for fw in car_fw):
|
||||
ret.minSteerSpeed = 0.
|
||||
|
||||
elif candidate == CAR.RAM_HD:
|
||||
ret.steerActuatorDelay = 0.2
|
||||
ret.wheelbase = 3.785
|
||||
ret.steerRatio = 15.61
|
||||
ret.mass = 3405.
|
||||
ret.minSteerSpeed = 16
|
||||
CarInterfaceBase.configure_torque_tune(candidate, ret.lateralTuning, 1.0, False)
|
||||
|
||||
else:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from enum import IntFlag, StrEnum
|
||||
from enum import IntFlag
|
||||
from dataclasses import dataclass, field
|
||||
|
||||
from cereal import car
|
||||
from panda.python import uds
|
||||
from openpilot.selfdrive.car import dbc_dict
|
||||
from openpilot.selfdrive.car import CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict
|
||||
from openpilot.selfdrive.car.docs_definitions import CarHarness, CarInfo, CarParts
|
||||
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, p16
|
||||
|
||||
|
@ -13,25 +13,89 @@ Ecu = car.CarParams.Ecu
|
|||
class ChryslerFlags(IntFlag):
|
||||
HIGHER_MIN_STEERING_SPEED = 1
|
||||
|
||||
@dataclass
|
||||
class ChryslerCarInfo(CarInfo):
|
||||
package: str = "Adaptive Cruise Control (ACC)"
|
||||
car_parts: CarParts = field(default_factory=CarParts.common([CarHarness.fca]))
|
||||
|
||||
class CAR(StrEnum):
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ChryslerPlatformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('chrysler_pacifica_2017_hybrid_generated', None))
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ChryslerCarSpecs(CarSpecs):
|
||||
minSteerSpeed: float = 3.8 # m/s
|
||||
|
||||
|
||||
class CAR(Platforms):
|
||||
# Chrysler
|
||||
PACIFICA_2017_HYBRID = "CHRYSLER PACIFICA HYBRID 2017"
|
||||
PACIFICA_2018_HYBRID = "CHRYSLER PACIFICA HYBRID 2018"
|
||||
PACIFICA_2019_HYBRID = "CHRYSLER PACIFICA HYBRID 2019"
|
||||
PACIFICA_2018 = "CHRYSLER PACIFICA 2018"
|
||||
PACIFICA_2020 = "CHRYSLER PACIFICA 2020"
|
||||
PACIFICA_2017_HYBRID = ChryslerPlatformConfig(
|
||||
"CHRYSLER PACIFICA HYBRID 2017",
|
||||
ChryslerCarInfo("Chrysler Pacifica Hybrid 2017"),
|
||||
specs=ChryslerCarSpecs(mass=2242., wheelbase=3.089, steerRatio=16.2),
|
||||
)
|
||||
PACIFICA_2018_HYBRID = ChryslerPlatformConfig(
|
||||
"CHRYSLER PACIFICA HYBRID 2018",
|
||||
ChryslerCarInfo("Chrysler Pacifica Hybrid 2018"),
|
||||
specs=PACIFICA_2017_HYBRID.specs,
|
||||
)
|
||||
PACIFICA_2019_HYBRID = ChryslerPlatformConfig(
|
||||
"CHRYSLER PACIFICA HYBRID 2019",
|
||||
ChryslerCarInfo("Chrysler Pacifica Hybrid 2019-23"),
|
||||
specs=PACIFICA_2017_HYBRID.specs,
|
||||
)
|
||||
PACIFICA_2018 = ChryslerPlatformConfig(
|
||||
"CHRYSLER PACIFICA 2018",
|
||||
ChryslerCarInfo("Chrysler Pacifica 2017-18"),
|
||||
specs=PACIFICA_2017_HYBRID.specs,
|
||||
)
|
||||
PACIFICA_2020 = ChryslerPlatformConfig(
|
||||
"CHRYSLER PACIFICA 2020",
|
||||
[
|
||||
ChryslerCarInfo("Chrysler Pacifica 2019-20"),
|
||||
ChryslerCarInfo("Chrysler Pacifica 2021-23", package="All"),
|
||||
],
|
||||
specs=PACIFICA_2017_HYBRID.specs,
|
||||
)
|
||||
|
||||
# Dodge
|
||||
DODGE_DURANGO = "DODGE DURANGO 2021"
|
||||
DODGE_DURANGO = ChryslerPlatformConfig(
|
||||
"DODGE DURANGO 2021",
|
||||
ChryslerCarInfo("Dodge Durango 2020-21"),
|
||||
specs=PACIFICA_2017_HYBRID.specs,
|
||||
)
|
||||
|
||||
# Jeep
|
||||
JEEP_GRAND_CHEROKEE = "JEEP GRAND CHEROKEE V6 2018" # includes 2017 Trailhawk
|
||||
JEEP_GRAND_CHEROKEE_2019 = "JEEP GRAND CHEROKEE 2019" # includes 2020 Trailhawk
|
||||
JEEP_GRAND_CHEROKEE = ChryslerPlatformConfig( # includes 2017 Trailhawk
|
||||
"JEEP GRAND CHEROKEE V6 2018",
|
||||
ChryslerCarInfo("Jeep Grand Cherokee 2016-18", video_link="https://www.youtube.com/watch?v=eLR9o2JkuRk"),
|
||||
specs=ChryslerCarSpecs(mass=1778., wheelbase=2.71, steerRatio=16.7),
|
||||
)
|
||||
|
||||
JEEP_GRAND_CHEROKEE_2019 = ChryslerPlatformConfig( # includes 2020 Trailhawk
|
||||
"JEEP GRAND CHEROKEE 2019",
|
||||
ChryslerCarInfo("Jeep Grand Cherokee 2019-21", video_link="https://www.youtube.com/watch?v=jBe4lWnRSu4"),
|
||||
specs=JEEP_GRAND_CHEROKEE.specs,
|
||||
)
|
||||
|
||||
# Ram
|
||||
RAM_1500 = "RAM 1500 5TH GEN"
|
||||
RAM_HD = "RAM HD 5TH GEN"
|
||||
RAM_1500 = ChryslerPlatformConfig(
|
||||
"RAM 1500 5TH GEN",
|
||||
ChryslerCarInfo("Ram 1500 2019-24", car_parts=CarParts.common([CarHarness.ram])),
|
||||
dbc_dict('chrysler_ram_dt_generated', None),
|
||||
specs=ChryslerCarSpecs(mass=2493., wheelbase=3.88, steerRatio=16.3, minSteerSpeed=14.5),
|
||||
)
|
||||
RAM_HD = ChryslerPlatformConfig(
|
||||
"RAM HD 5TH GEN",
|
||||
[
|
||||
ChryslerCarInfo("Ram 2500 2020-24", car_parts=CarParts.common([CarHarness.ram])),
|
||||
ChryslerCarInfo("Ram 3500 2019-22", car_parts=CarParts.common([CarHarness.ram])),
|
||||
],
|
||||
dbc_dict('chrysler_ram_hd_generated', None),
|
||||
specs=ChryslerCarSpecs(mass=3405., wheelbase=3.785, steerRatio=15.61, minSteerSpeed=16.),
|
||||
)
|
||||
|
||||
|
||||
class CarControllerParams:
|
||||
|
@ -59,32 +123,6 @@ RAM_HD = {CAR.RAM_HD, }
|
|||
RAM_CARS = RAM_DT | RAM_HD
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChryslerCarInfo(CarInfo):
|
||||
package: str = "Adaptive Cruise Control (ACC)"
|
||||
car_parts: CarParts = field(default_factory=CarParts.common([CarHarness.fca]))
|
||||
|
||||
|
||||
CAR_INFO: dict[str, ChryslerCarInfo | list[ChryslerCarInfo] | None] = {
|
||||
CAR.PACIFICA_2017_HYBRID: ChryslerCarInfo("Chrysler Pacifica Hybrid 2017"),
|
||||
CAR.PACIFICA_2018_HYBRID: ChryslerCarInfo("Chrysler Pacifica Hybrid 2018"),
|
||||
CAR.PACIFICA_2019_HYBRID: ChryslerCarInfo("Chrysler Pacifica Hybrid 2019-23"),
|
||||
CAR.PACIFICA_2018: ChryslerCarInfo("Chrysler Pacifica 2017-18"),
|
||||
CAR.PACIFICA_2020: [
|
||||
ChryslerCarInfo("Chrysler Pacifica 2019-20"),
|
||||
ChryslerCarInfo("Chrysler Pacifica 2021-23", package="All"),
|
||||
],
|
||||
CAR.JEEP_GRAND_CHEROKEE: ChryslerCarInfo("Jeep Grand Cherokee 2016-18", video_link="https://www.youtube.com/watch?v=eLR9o2JkuRk"),
|
||||
CAR.JEEP_GRAND_CHEROKEE_2019: ChryslerCarInfo("Jeep Grand Cherokee 2019-21", video_link="https://www.youtube.com/watch?v=jBe4lWnRSu4"),
|
||||
CAR.DODGE_DURANGO: ChryslerCarInfo("Dodge Durango 2020-21"),
|
||||
CAR.RAM_1500: ChryslerCarInfo("Ram 1500 2019-24", car_parts=CarParts.common([CarHarness.ram])),
|
||||
CAR.RAM_HD: [
|
||||
ChryslerCarInfo("Ram 2500 2020-24", car_parts=CarParts.common([CarHarness.ram])),
|
||||
ChryslerCarInfo("Ram 3500 2019-22", car_parts=CarParts.common([CarHarness.ram])),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
CHRYSLER_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
|
||||
p16(0xf132)
|
||||
CHRYSLER_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
|
||||
|
@ -124,16 +162,5 @@ FW_QUERY_CONFIG = FwQueryConfig(
|
|||
],
|
||||
)
|
||||
|
||||
|
||||
DBC = {
|
||||
CAR.PACIFICA_2017_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.PACIFICA_2018: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.PACIFICA_2020: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.PACIFICA_2018_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.PACIFICA_2019_HYBRID: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.DODGE_DURANGO: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.JEEP_GRAND_CHEROKEE: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.JEEP_GRAND_CHEROKEE_2019: dbc_dict('chrysler_pacifica_2017_hybrid_generated', 'chrysler_pacifica_2017_hybrid_private_fusion'),
|
||||
CAR.RAM_1500: dbc_dict('chrysler_ram_dt_generated', None),
|
||||
CAR.RAM_HD: dbc_dict('chrysler_ram_hd_generated', None),
|
||||
}
|
||||
CAR_INFO = CAR.create_carinfo_map()
|
||||
DBC = CAR.create_dbc_map()
|
||||
|
|
|
@ -19,6 +19,7 @@ ECU_ADDRESSES = {
|
|||
Ecu.fwdCamera: 0x706, # Image Processing Module A (IPMA)
|
||||
Ecu.engine: 0x7E0, # Powertrain Control Module (PCM)
|
||||
Ecu.shiftByWire: 0x732, # Gear Shift Module (GSM)
|
||||
Ecu.debug: 0x7D0, # Accessory Protocol Interface Module (APIM)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from dataclasses import dataclass, field
|
||||
from enum import Enum
|
||||
|
||||
import panda.python.uds as uds
|
||||
from cereal import car
|
||||
from openpilot.selfdrive.car import AngleRateLimit, CarSpecs, dbc_dict, DbcDict, PlatformConfig, Platforms
|
||||
from openpilot.selfdrive.car.docs_definitions import CarFootnote, CarHarness, CarInfo, CarParts, Column, \
|
||||
Device
|
||||
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries
|
||||
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries, p16
|
||||
|
||||
Ecu = car.CarParams.Ecu
|
||||
|
||||
|
@ -63,7 +64,7 @@ class FordCarInfo(CarInfo):
|
|||
self.car_parts = CarParts([Device.threex, harness])
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(frozen=True)
|
||||
class FordPlatformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('ford_lincoln_base_pt', RADAR.DELPHI_MRR))
|
||||
|
||||
|
@ -140,6 +141,33 @@ class CAR(Platforms):
|
|||
CANFD_CAR = {CAR.F_150_MK14, CAR.F_150_LIGHTNING_MK1, CAR.MUSTANG_MACH_E_MK1}
|
||||
|
||||
|
||||
DATA_IDENTIFIER_FORD_ASBUILT = 0xDE00
|
||||
|
||||
ASBUILT_BLOCKS: list[tuple[int, list]] = [
|
||||
(1, [Ecu.debug, Ecu.fwdCamera, Ecu.eps]),
|
||||
(2, [Ecu.abs, Ecu.debug, Ecu.eps]),
|
||||
(3, [Ecu.abs, Ecu.debug, Ecu.eps]),
|
||||
(4, [Ecu.debug, Ecu.fwdCamera]),
|
||||
(5, [Ecu.debug]),
|
||||
(6, [Ecu.debug]),
|
||||
(7, [Ecu.debug]),
|
||||
(8, [Ecu.debug]),
|
||||
(9, [Ecu.debug]),
|
||||
(16, [Ecu.debug, Ecu.fwdCamera]),
|
||||
(18, [Ecu.fwdCamera]),
|
||||
(20, [Ecu.fwdCamera]),
|
||||
(21, [Ecu.fwdCamera]),
|
||||
]
|
||||
|
||||
|
||||
def ford_asbuilt_block_request(block_id: int):
|
||||
return bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + p16(DATA_IDENTIFIER_FORD_ASBUILT + block_id - 1)
|
||||
|
||||
|
||||
def ford_asbuilt_block_response(block_id: int):
|
||||
return bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + p16(DATA_IDENTIFIER_FORD_ASBUILT + block_id - 1)
|
||||
|
||||
|
||||
FW_QUERY_CONFIG = FwQueryConfig(
|
||||
requests=[
|
||||
# CAN and CAN FD queries are combined.
|
||||
|
@ -147,19 +175,29 @@ FW_QUERY_CONFIG = FwQueryConfig(
|
|||
Request(
|
||||
[StdQueries.TESTER_PRESENT_REQUEST, StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST],
|
||||
[StdQueries.TESTER_PRESENT_RESPONSE, StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE],
|
||||
whitelist_ecus=[Ecu.abs, Ecu.debug, Ecu.engine, Ecu.eps, Ecu.fwdCamera, Ecu.fwdRadar, Ecu.shiftByWire],
|
||||
logging=True,
|
||||
),
|
||||
Request(
|
||||
[StdQueries.TESTER_PRESENT_REQUEST, StdQueries.MANUFACTURER_SOFTWARE_VERSION_REQUEST],
|
||||
[StdQueries.TESTER_PRESENT_RESPONSE, StdQueries.MANUFACTURER_SOFTWARE_VERSION_RESPONSE],
|
||||
whitelist_ecus=[Ecu.abs, Ecu.debug, Ecu.engine, Ecu.eps, Ecu.fwdCamera, Ecu.fwdRadar, Ecu.shiftByWire],
|
||||
bus=0,
|
||||
auxiliary=True,
|
||||
),
|
||||
*[Request(
|
||||
[StdQueries.TESTER_PRESENT_REQUEST, ford_asbuilt_block_request(block_id)],
|
||||
[StdQueries.TESTER_PRESENT_RESPONSE, ford_asbuilt_block_response(block_id)],
|
||||
whitelist_ecus=ecus,
|
||||
bus=0,
|
||||
logging=True,
|
||||
) for block_id, ecus in ASBUILT_BLOCKS],
|
||||
],
|
||||
extra_ecus=[
|
||||
# We are unlikely to get a response from the PCM from behind the gateway
|
||||
(Ecu.engine, 0x7e0, None),
|
||||
(Ecu.shiftByWire, 0x732, None),
|
||||
(Ecu.engine, 0x7e0, None), # Powertrain Control Module
|
||||
# Note: We are unlikely to get a response from behind the gateway
|
||||
(Ecu.shiftByWire, 0x732, None), # Gear Shift Module
|
||||
(Ecu.debug, 0x7d0, None), # Accessory Protocol Interface Module
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class GMCarInfo(CarInfo):
|
|||
self.footnotes.append(Footnote.OBD_II)
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(frozen=True)
|
||||
class GMPlatformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('gm_global_a_powertrain_generated', 'gm_global_a_object', chassis_dbc='gm_global_a_chassis'))
|
||||
|
||||
|
|
|
@ -219,6 +219,8 @@ FW_QUERY_CONFIG = FwQueryConfig(
|
|||
Ecu.combinationMeter: [CAR.CIVIC_BOSCH, CAR.CRV_5G],
|
||||
Ecu.gateway: [CAR.CIVIC_BOSCH, CAR.CRV_5G],
|
||||
Ecu.electricBrakeBooster: [CAR.CIVIC_BOSCH, CAR.CRV_5G],
|
||||
Ecu.shiftByWire: [CAR.ACCORD], # existence correlates with transmission type for ICE
|
||||
Ecu.hud: [CAR.ACCORD, CAR.ACCORDH], # existence correlates with trim level
|
||||
},
|
||||
extra_ecus=[
|
||||
# The only other ECU on PT bus accessible by camera on radarless Civic
|
||||
|
|
|
@ -4,7 +4,7 @@ import numpy as np
|
|||
import tomllib
|
||||
from abc import abstractmethod, ABC
|
||||
from enum import StrEnum
|
||||
from typing import Any, NamedTuple, cast
|
||||
from typing import Any, NamedTuple
|
||||
from collections.abc import Callable
|
||||
|
||||
from cereal import car
|
||||
|
@ -13,7 +13,7 @@ from openpilot.common.conversions import Conversions as CV
|
|||
from openpilot.common.simple_kalman import KF1D, get_kalman_gain
|
||||
from openpilot.common.numpy_fast import clip
|
||||
from openpilot.common.realtime import DT_CTRL
|
||||
from openpilot.selfdrive.car import PlatformConfig, apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG
|
||||
from openpilot.selfdrive.car import apply_hysteresis, gen_empty_fingerprint, scale_rot_inertia, scale_tire_stiffness, STD_CARGO_KG
|
||||
from openpilot.selfdrive.car.values import Platform
|
||||
from openpilot.selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX, get_friction
|
||||
from openpilot.selfdrive.controls.lib.events import Events
|
||||
|
@ -113,14 +113,13 @@ class CarInterfaceBase(ABC):
|
|||
ret = CarInterfaceBase.get_std_params(candidate)
|
||||
|
||||
if hasattr(candidate, "config"):
|
||||
platform_config = cast(PlatformConfig, candidate.config)
|
||||
if platform_config.specs is not None:
|
||||
ret.mass = platform_config.specs.mass
|
||||
ret.wheelbase = platform_config.specs.wheelbase
|
||||
ret.steerRatio = platform_config.specs.steerRatio
|
||||
ret.centerToFront = ret.wheelbase * platform_config.specs.centerToFrontRatio
|
||||
ret.minEnableSpeed = platform_config.specs.minEnableSpeed
|
||||
ret.minSteerSpeed = platform_config.specs.minSteerSpeed
|
||||
if candidate.config.specs is not None:
|
||||
ret.mass = candidate.config.specs.mass
|
||||
ret.wheelbase = candidate.config.specs.wheelbase
|
||||
ret.steerRatio = candidate.config.specs.steerRatio
|
||||
ret.centerToFront = ret.wheelbase * candidate.config.specs.centerToFrontRatio
|
||||
ret.minEnableSpeed = candidate.config.specs.minEnableSpeed
|
||||
ret.minSteerSpeed = candidate.config.specs.minSteerSpeed
|
||||
|
||||
ret = cls._get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs)
|
||||
|
||||
|
|
|
@ -16,25 +16,13 @@ class CarInterface(CarInterfaceBase):
|
|||
ret.steerLimitTimer = 1.0
|
||||
|
||||
ret.steerActuatorDelay = 0.1
|
||||
ret.steerRatio = 17
|
||||
|
||||
ret.steerControlType = car.CarParams.SteerControlType.angle
|
||||
ret.radarUnavailable = True
|
||||
|
||||
if candidate in (CAR.ROGUE, CAR.XTRAIL):
|
||||
ret.mass = 1610
|
||||
ret.wheelbase = 2.705
|
||||
ret.centerToFront = ret.wheelbase * 0.44
|
||||
elif candidate in (CAR.LEAF, CAR.LEAF_IC):
|
||||
ret.mass = 1610
|
||||
ret.wheelbase = 2.705
|
||||
ret.centerToFront = ret.wheelbase * 0.44
|
||||
elif candidate == CAR.ALTIMA:
|
||||
if candidate == CAR.ALTIMA:
|
||||
# Altima has EPS on C-CAN unlike the others that have it on V-CAN
|
||||
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_NISSAN_ALT_EPS_BUS
|
||||
ret.mass = 1492
|
||||
ret.wheelbase = 2.824
|
||||
ret.centerToFront = ret.wheelbase * 0.44
|
||||
|
||||
return ret
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from dataclasses import dataclass, field
|
||||
from enum import StrEnum
|
||||
|
||||
from cereal import car
|
||||
from panda.python import uds
|
||||
from openpilot.selfdrive.car import AngleRateLimit, dbc_dict
|
||||
from openpilot.selfdrive.car import AngleRateLimit, CarSpecs, DbcDict, PlatformConfig, Platforms, dbc_dict
|
||||
from openpilot.selfdrive.car.docs_definitions import CarInfo, CarHarness, CarParts
|
||||
from openpilot.selfdrive.car.fw_query_definitions import FwQueryConfig, Request, StdQueries
|
||||
|
||||
|
@ -20,29 +19,52 @@ class CarControllerParams:
|
|||
pass
|
||||
|
||||
|
||||
class CAR(StrEnum):
|
||||
XTRAIL = "NISSAN X-TRAIL 2017"
|
||||
LEAF = "NISSAN LEAF 2018"
|
||||
# Leaf with ADAS ECU found behind instrument cluster instead of glovebox
|
||||
# Currently the only known difference between them is the inverted seatbelt signal.
|
||||
LEAF_IC = "NISSAN LEAF 2018 Instrument Cluster"
|
||||
ROGUE = "NISSAN ROGUE 2019"
|
||||
ALTIMA = "NISSAN ALTIMA 2020"
|
||||
|
||||
|
||||
@dataclass
|
||||
class NissanCarInfo(CarInfo):
|
||||
package: str = "ProPILOT Assist"
|
||||
car_parts: CarParts = field(default_factory=CarParts.common([CarHarness.nissan_a]))
|
||||
|
||||
|
||||
CAR_INFO: dict[str, NissanCarInfo | list[NissanCarInfo] | None] = {
|
||||
CAR.XTRAIL: NissanCarInfo("Nissan X-Trail 2017"),
|
||||
CAR.LEAF: NissanCarInfo("Nissan Leaf 2018-23", video_link="https://youtu.be/vaMbtAh_0cY"),
|
||||
CAR.LEAF_IC: None, # same platforms
|
||||
CAR.ROGUE: NissanCarInfo("Nissan Rogue 2018-20"),
|
||||
CAR.ALTIMA: NissanCarInfo("Nissan Altima 2019-20", car_parts=CarParts.common([CarHarness.nissan_b])),
|
||||
}
|
||||
@dataclass(frozen=True)
|
||||
class NissanCarSpecs(CarSpecs):
|
||||
centerToFrontRatio: float = 0.44
|
||||
steerRatio: float = 17.
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class NissanPlaformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('nissan_x_trail_2017_generated', None))
|
||||
|
||||
|
||||
class CAR(Platforms):
|
||||
XTRAIL = NissanPlaformConfig(
|
||||
"NISSAN X-TRAIL 2017",
|
||||
NissanCarInfo("Nissan X-Trail 2017"),
|
||||
specs=NissanCarSpecs(mass=1610, wheelbase=2.705)
|
||||
)
|
||||
LEAF = NissanPlaformConfig(
|
||||
"NISSAN LEAF 2018",
|
||||
NissanCarInfo("Nissan Leaf 2018-23", video_link="https://youtu.be/vaMbtAh_0cY"),
|
||||
dbc_dict=dbc_dict('nissan_leaf_2018_generated', None),
|
||||
specs=NissanCarSpecs(mass=1610, wheelbase=2.705)
|
||||
)
|
||||
# Leaf with ADAS ECU found behind instrument cluster instead of glovebox
|
||||
# Currently the only known difference between them is the inverted seatbelt signal.
|
||||
LEAF_IC = LEAF.override(platform_str="NISSAN LEAF 2018 Instrument Cluster", car_info=None)
|
||||
ROGUE = NissanPlaformConfig(
|
||||
"NISSAN ROGUE 2019",
|
||||
NissanCarInfo("Nissan Rogue 2018-20"),
|
||||
specs=NissanCarSpecs(mass=1610, wheelbase=2.705)
|
||||
)
|
||||
ALTIMA = NissanPlaformConfig(
|
||||
"NISSAN ALTIMA 2020",
|
||||
NissanCarInfo("Nissan Altima 2019-20", car_parts=CarParts.common([CarHarness.nissan_b])),
|
||||
specs=NissanCarSpecs(mass=1492, wheelbase=2.824)
|
||||
)
|
||||
|
||||
|
||||
CAR_INFO = CAR.create_carinfo_map()
|
||||
DBC = CAR.create_dbc_map()
|
||||
|
||||
# Default diagnostic session
|
||||
NISSAN_DIAGNOSTIC_REQUEST_KWP = bytes([uds.SERVICE_TYPE.DIAGNOSTIC_SESSION_CONTROL, 0x81])
|
||||
|
@ -88,11 +110,3 @@ FW_QUERY_CONFIG = FwQueryConfig(
|
|||
),
|
||||
]],
|
||||
)
|
||||
|
||||
DBC = {
|
||||
CAR.XTRAIL: dbc_dict('nissan_x_trail_2017_generated', None),
|
||||
CAR.LEAF: dbc_dict('nissan_leaf_2018_generated', None),
|
||||
CAR.LEAF_IC: dbc_dict('nissan_leaf_2018_generated', None),
|
||||
CAR.ROGUE: dbc_dict('nissan_x_trail_2017_generated', None),
|
||||
CAR.ALTIMA: dbc_dict('nissan_x_trail_2017_generated', None),
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class SubaruCarInfo(CarInfo):
|
|||
self.footnotes.append(Footnote.EXP_LONG)
|
||||
|
||||
|
||||
@dataclass
|
||||
@dataclass(frozen=True)
|
||||
class SubaruPlatformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('subaru_global_2017_generated', None))
|
||||
|
||||
|
|
|
@ -263,13 +263,13 @@ class TestFwFingerprintTiming(unittest.TestCase):
|
|||
print(f'get_vin {name} case, query time={self.total_time / self.N} seconds')
|
||||
|
||||
def test_fw_query_timing(self):
|
||||
total_ref_time = {1: 6.5, 2: 7.4}
|
||||
total_ref_time = {1: 7.8, 2: 8.7}
|
||||
brand_ref_times = {
|
||||
1: {
|
||||
'gm': 0.5,
|
||||
'body': 0.1,
|
||||
'chrysler': 0.3,
|
||||
'ford': 0.2,
|
||||
'ford': 1.5,
|
||||
'honda': 0.55,
|
||||
'hyundai': 1.05,
|
||||
'mazda': 0.1,
|
||||
|
@ -280,7 +280,7 @@ class TestFwFingerprintTiming(unittest.TestCase):
|
|||
'volkswagen': 0.65,
|
||||
},
|
||||
2: {
|
||||
'ford': 0.3,
|
||||
'ford': 1.6,
|
||||
'hyundai': 1.85,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -573,6 +573,7 @@ FW_VERSIONS = {
|
|||
b'\x018821F6201400\x00\x00\x00\x00',
|
||||
],
|
||||
(Ecu.fwdCamera, 0x750, 0x6d): [
|
||||
b'\x028646F12010C0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00',
|
||||
b'\x028646F12010D0\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00',
|
||||
b'\x028646F1201100\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00',
|
||||
b'\x028646F1201200\x00\x00\x00\x008646G26011A0\x00\x00\x00\x00',
|
||||
|
@ -843,6 +844,7 @@ FW_VERSIONS = {
|
|||
b'8965B47023\x00\x00\x00\x00\x00\x00',
|
||||
b'8965B47050\x00\x00\x00\x00\x00\x00',
|
||||
b'8965B47060\x00\x00\x00\x00\x00\x00',
|
||||
b'8965B47070\x00\x00\x00\x00\x00\x00',
|
||||
],
|
||||
(Ecu.abs, 0x7b0, None): [
|
||||
b'F152647290\x00\x00\x00\x00\x00\x00',
|
||||
|
@ -1024,6 +1026,7 @@ FW_VERSIONS = {
|
|||
b'\x02896634A13000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00',
|
||||
b'\x02896634A13001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00',
|
||||
b'\x02896634A13101\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00',
|
||||
b'\x02896634A13201\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00',
|
||||
b'\x02896634A14001\x00\x00\x00\x00897CF1203001\x00\x00\x00\x00',
|
||||
b'\x02896634A14001\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00',
|
||||
b'\x02896634A14101\x00\x00\x00\x00897CF4801001\x00\x00\x00\x00',
|
||||
|
|
|
@ -112,15 +112,15 @@ class CANBUS:
|
|||
class VolkswagenFlags(IntFlag):
|
||||
STOCK_HCA_PRESENT = 1
|
||||
|
||||
@dataclass
|
||||
@dataclass(frozen=True)
|
||||
class VolkswagenMQBPlatformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('vw_mqb_2010', None))
|
||||
|
||||
@dataclass
|
||||
@dataclass(frozen=True)
|
||||
class VolkswagenPQPlatformConfig(PlatformConfig):
|
||||
dbc_dict: DbcDict = field(default_factory=lambda: dbc_dict('vw_golf_mk4', None))
|
||||
|
||||
@dataclass(kw_only=True)
|
||||
@dataclass(frozen=True, kw_only=True)
|
||||
class VolkswagenCarSpecs(CarSpecs):
|
||||
steerRatio: float = field(default=15.6)
|
||||
|
||||
|
|
|
@ -691,10 +691,9 @@ int Localizer::locationd_thread() {
|
|||
|
||||
this->configure_gnss_source(source);
|
||||
const std::initializer_list<const char *> service_list = {gps_location_socket, "cameraOdometry", "liveCalibration",
|
||||
"carState", "carParams", "accelerometer", "gyroscope"};
|
||||
"carState", "accelerometer", "gyroscope"};
|
||||
|
||||
// TODO: remove carParams once we're always sending at 100Hz
|
||||
SubMaster sm(service_list, {}, nullptr, {gps_location_socket, "carParams"});
|
||||
SubMaster sm(service_list, {}, nullptr, {gps_location_socket});
|
||||
PubMaster pm({"liveLocationKalman"});
|
||||
|
||||
uint64_t cnt = 0;
|
||||
|
@ -718,8 +717,7 @@ int Localizer::locationd_thread() {
|
|||
filterInitialized = sm.allAliveAndValid();
|
||||
}
|
||||
|
||||
// 100Hz publish for notcars, 20Hz for cars
|
||||
const char* trigger_msg = sm["carParams"].getCarParams().getNotCar() ? "accelerometer" : "cameraOdometry";
|
||||
const char* trigger_msg = "cameraOdometry";
|
||||
if (sm.updated(trigger_msg)) {
|
||||
bool inputsOK = sm.allValid() && this->are_inputs_ok();
|
||||
bool gpsOK = this->is_gps_ok();
|
||||
|
|
|
@ -512,7 +512,7 @@ CONFIGS = [
|
|||
proc_name="locationd",
|
||||
pubs=[
|
||||
"cameraOdometry", "accelerometer", "gyroscope", "gpsLocationExternal",
|
||||
"liveCalibration", "carState", "carParams", "gpsLocation"
|
||||
"liveCalibration", "carState", "gpsLocation"
|
||||
],
|
||||
subs=["liveLocationKalman"],
|
||||
ignore=["logMonoTime"],
|
||||
|
|
|
@ -1 +1 @@
|
|||
d0cdea7eb15f3cac8a921f7ace3eaa6baebb4fd5
|
||||
47609e372bf616932c4dca74d2616c3d97fa2443
|
||||
|
|
|
@ -424,4 +424,4 @@ class TestOnroad(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main()
|
||||
unittest.main()
|
||||
|
|
|
@ -97,6 +97,7 @@ CONFIGS = {
|
|||
AmpConfig("Right DAC input mixer: DAI2 right", 0b1, 0x22, 0, 0b00000001),
|
||||
AmpConfig("Volume adjustment smoothing disabled", 0b1, 0x49, 6, 0b01000000),
|
||||
],
|
||||
"mici": [],
|
||||
}
|
||||
|
||||
class Amplifier:
|
||||
|
|
|
@ -20,12 +20,12 @@ public:
|
|||
}
|
||||
|
||||
static std::string get_name() {
|
||||
std::string devicetree_model = util::read_file("/sys/firmware/devicetree/base/model");
|
||||
return (devicetree_model.find("tizi") != std::string::npos) ? "tizi" : "tici";
|
||||
std::string model = util::read_file("/sys/firmware/devicetree/base/model");
|
||||
return model.substr(std::string("comma ").size());
|
||||
}
|
||||
|
||||
static cereal::InitData::DeviceType get_device_type() {
|
||||
return (get_name() == "tizi") ? cereal::InitData::DeviceType::TIZI : cereal::InitData::DeviceType::TICI;
|
||||
return (get_name() == "tizi") ? cereal::InitData::DeviceType::TIZI : (get_name() == "mici" ? cereal::InitData::DeviceType::MICI : cereal::InitData::DeviceType::TICI);
|
||||
}
|
||||
|
||||
static int get_voltage() { return std::atoi(util::read_file("/sys/class/hwmon/hwmon1/in1_input").c_str()); }
|
||||
|
|
|
@ -25,4 +25,4 @@ class TestHardware(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main()
|
||||
unittest.main()
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
from collections import defaultdict, deque
|
||||
import sys
|
||||
import pytest
|
||||
import unittest
|
||||
import time
|
||||
|
@ -132,4 +131,4 @@ class TestPowerDraw(unittest.TestCase):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main(sys.argv)
|
||||
unittest.main()
|
||||
|
|
|
@ -21,41 +21,41 @@ ENABLE_IGN = IGN_ON > 0 and IGN_OFF > 0
|
|||
ENABLE_PWR = PWR_ON > 0 and PWR_OFF > 0
|
||||
|
||||
|
||||
def send_thread(s, flock):
|
||||
def send_thread(j: PandaJungle, flock):
|
||||
if "FLASH" in os.environ:
|
||||
with flock:
|
||||
s.flash()
|
||||
j.flash()
|
||||
|
||||
for i in [0, 1, 2, 3, 0xFFFF]:
|
||||
s.can_clear(i)
|
||||
s.set_can_speed_kbps(i, 500)
|
||||
s.set_can_data_speed_kbps(i, 500)
|
||||
s.set_ignition(False)
|
||||
j.can_clear(i)
|
||||
j.set_can_speed_kbps(i, 500)
|
||||
j.set_can_data_speed_kbps(i, 500)
|
||||
j.set_ignition(False)
|
||||
time.sleep(5)
|
||||
s.set_ignition(True)
|
||||
s.set_panda_power(True)
|
||||
s.set_can_loopback(False)
|
||||
j.set_ignition(True)
|
||||
j.set_panda_power(True)
|
||||
j.set_can_loopback(False)
|
||||
|
||||
rk = Ratekeeper(1 / DT_CTRL, print_delay_threshold=None)
|
||||
while True:
|
||||
# handle cycling
|
||||
if ENABLE_PWR:
|
||||
i = (rk.frame*DT_CTRL) % (PWR_ON + PWR_OFF) < PWR_ON
|
||||
s.set_panda_power(i)
|
||||
j.set_panda_power(i)
|
||||
if ENABLE_IGN:
|
||||
i = (rk.frame*DT_CTRL) % (IGN_ON + IGN_OFF) < IGN_ON
|
||||
s.set_ignition(i)
|
||||
j.set_ignition(i)
|
||||
|
||||
snd = CAN_MSGS[rk.frame % len(CAN_MSGS)]
|
||||
snd = list(filter(lambda x: x[-1] <= 2, snd))
|
||||
try:
|
||||
s.can_send_many(snd)
|
||||
j.can_send_many(snd)
|
||||
except usb1.USBErrorTimeout:
|
||||
# timeout is fine, just means the CAN TX buffer is full
|
||||
pass
|
||||
|
||||
# Drain panda message buffer
|
||||
s.can_recv()
|
||||
j.can_recv()
|
||||
rk.keep_time()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue