mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-04-08 14:03:54 +08:00
@@ -106,6 +106,7 @@ keys = {
|
||||
#dragonpilot config
|
||||
"DragonEnableDashcam": [TxType.PERSISTENT],
|
||||
"DragonEnableDriverSafetyCheck": [TxType.PERSISTENT],
|
||||
"DragonEnableAutoShutdown": [TxType.PERSISTENT],
|
||||
"DragonAutoShutdownAt": [TxType.PERSISTENT],
|
||||
"DragonEnableSteeringOnSignal": [TxType.PERSISTENT],
|
||||
"DragonEnableLogger": [TxType.PERSISTENT],
|
||||
@@ -167,6 +168,7 @@ keys = {
|
||||
"DragonBTG": [TxType.PERSISTENT],
|
||||
"DragonBootHotspot": [TxType.PERSISTENT],
|
||||
"DragonAccelProfile": [TxType.PERSISTENT],
|
||||
"DragonLastModified": [TxType.PERSISTENT],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ const int TOYOTA_MAX_TORQUE = 1500; // max torque cmd allowed ever
|
||||
// rate based torque limit + stay within actually applied
|
||||
// packet is sent at 100hz, so this limit is 1000/sec
|
||||
const int TOYOTA_MAX_RATE_UP = 10; // ramp up slow
|
||||
const int TOYOTA_MAX_RATE_DOWN = 25; // ramp down fast
|
||||
const int TOYOTA_MAX_TORQUE_ERROR = 350; // max torque cmd in excess of torque motor
|
||||
const int TOYOTA_MAX_RATE_DOWN = 44; // ramp down fast
|
||||
const int TOYOTA_MAX_TORQUE_ERROR = 500; // max torque cmd in excess of torque motor
|
||||
|
||||
// real time torque limit to prevent controls spamming
|
||||
// the real time limit is 1500/sec
|
||||
|
||||
@@ -237,6 +237,7 @@ def get_car(logcan, sendcan, has_relay=False):
|
||||
y.start()
|
||||
|
||||
cloudlog.warning("car doesn't match any fingerprints: %r", fingerprints)
|
||||
cloudlog.warning("car doesn't match any fw: %s" % car_fw)
|
||||
candidate = "mock"
|
||||
|
||||
if is_online():
|
||||
|
||||
@@ -9,6 +9,7 @@ from selfdrive.car.honda.values import CruiseButtons, CAR, VISUAL_HUD
|
||||
from opendbc.can.packer import CANPacker
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
||||
|
||||
@@ -96,14 +97,18 @@ class CarController():
|
||||
self.turning_signal_timer = 0
|
||||
self.dragon_enable_steering_on_signal = False
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
def update(self, enabled, CS, frame, actuators, \
|
||||
pcm_speed, pcm_override, pcm_cancel_cmd, pcm_accel, \
|
||||
hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert):
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
if frame % 500 == 0:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
|
||||
# *** apply brake hysteresis ***
|
||||
brake, self.braking, self.brake_steady = actuator_hystereses(actuators.brake, self.braking, self.brake_steady, CS.v_ego, CS.CP.carFingerprint)
|
||||
|
||||
@@ -14,6 +14,7 @@ from selfdrive.controls.lib.planner import _A_CRUISE_MAX_V_FOLLOWING
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
A_ACC_MAX = max(_A_CRUISE_MAX_V_FOLLOWING)
|
||||
|
||||
@@ -105,6 +106,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.dragon_allow_gas = False
|
||||
self.ts_last_check = 0.
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
@staticmethod
|
||||
def calc_accel_override(a_ego, a_target, v_ego, v_target):
|
||||
@@ -386,10 +388,13 @@ class CarInterface(CarInterfaceBase):
|
||||
def update(self, c, can_strings):
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
ts = sec_since_boot()
|
||||
if ts - self.ts_last_check > 5.:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else True
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
if ts - self.ts_last_check >= 5.:
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else True
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
self.ts_last_check = ts
|
||||
|
||||
# ******************* do can recv *******************
|
||||
|
||||
@@ -73,6 +73,10 @@ FINGERPRINTS = {
|
||||
# 2017 Civic Hatchback EX, 2019 Civic Sedan Touring Canadian, and 2018 Civic Hatchback Executive Premium 1.0L CVT European
|
||||
57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 460: 3, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1625: 5, 1629: 5, 1633: 8,
|
||||
},
|
||||
# Manual CIVIC from AlexNoop
|
||||
{
|
||||
57: 3, 148: 8, 228: 5, 274: 3, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 420: 8, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 460: 3, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 829: 5, 862: 8, 884: 8, 891: 8, 892: 8, 927: 8, 929: 8, 985: 3, 1024: 5, 1029: 8, 1036: 8, 1108: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1625: 5, 1633: 8,
|
||||
},
|
||||
# 2017 Civic Hatchback LX
|
||||
{
|
||||
57: 3, 148: 8, 228: 5, 304: 8, 330: 8, 344: 8, 380: 8, 399: 7, 401: 8, 420: 8, 423: 2, 427: 3, 428: 8, 432: 7, 441: 5, 450: 8, 464: 8, 470: 2, 476: 7, 477: 8, 479: 8, 490: 8, 493: 5, 495: 8, 506: 8, 545: 6, 597: 8, 662: 4, 773: 7, 777: 8, 780: 8, 795: 8, 800: 8, 804: 8, 806: 8, 808: 8, 815: 8, 825: 4, 829: 5, 846: 8, 862: 8, 881: 8, 882: 4, 884: 8, 888: 8, 891: 8, 892: 8, 918: 7, 927: 8, 929: 8, 983: 8, 985: 3, 1024: 5, 1027: 5, 1029: 8, 1036: 8, 1039: 8, 1064: 7, 1092: 1, 1108: 8, 1125: 8, 1127: 2, 1296: 8, 1302: 8, 1322: 5, 1361: 5, 1365: 5, 1424: 5, 1600: 5, 1601: 8, 1633: 8
|
||||
@@ -307,6 +311,7 @@ FW_VERSIONS = {
|
||||
b'37805-5AN-LJ20\x00\x00',
|
||||
b'37805-5AZ-E850\x00\x00',
|
||||
b'37805-5BB-L640\x00\x00',
|
||||
b'37805-5AN-E410\x00\x00', # AlexNoop's Manual CIVIC_BOSCH
|
||||
],
|
||||
(Ecu.unknown, 0x18da1ef1, None): [
|
||||
b'28101-5CG-A920\x00\x00',
|
||||
|
||||
@@ -4,7 +4,7 @@ from selfdrive.car.hyundai.values import Buttons, SteerLimitParams
|
||||
from opendbc.can.packer import CANPacker
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
class CarController():
|
||||
def __init__(self, dbc_name, car_fingerprint):
|
||||
@@ -20,13 +20,17 @@ class CarController():
|
||||
self.turning_signal_timer = 0
|
||||
self.dragon_enable_steering_on_signal = False
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert):
|
||||
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
if frame % 500 == 0:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
|
||||
### Steering Torque
|
||||
new_steer = actuators.steer * SteerLimitParams.STEER_MAX
|
||||
|
||||
@@ -10,6 +10,7 @@ from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness,
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
GearShifter = car.CarState.GearShifter
|
||||
ButtonType = car.CarState.ButtonEvent.Type
|
||||
@@ -42,6 +43,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.dragon_allow_gas = False
|
||||
self.ts_last_check = 0.
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
@staticmethod
|
||||
def compute_gb(accel, speed):
|
||||
@@ -162,10 +164,13 @@ class CarInterface(CarInterfaceBase):
|
||||
def update(self, c, can_strings):
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
ts = sec_since_boot()
|
||||
if ts - self.ts_last_check > 5.:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else True
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
if ts - self.ts_last_check >= 5.:
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else True
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
self.ts_last_check = ts
|
||||
|
||||
# ******************* do can recv *******************
|
||||
|
||||
@@ -3,7 +3,9 @@ from selfdrive.car import apply_std_steer_torque_limits
|
||||
from selfdrive.car.subaru import subarucan
|
||||
from selfdrive.car.subaru.values import DBC
|
||||
from opendbc.can.packer import CANPacker
|
||||
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
class CarControllerParams():
|
||||
def __init__(self, car_fingerprint):
|
||||
@@ -32,9 +34,23 @@ class CarController():
|
||||
self.params = CarControllerParams(car_fingerprint)
|
||||
self.packer = CANPacker(DBC[car_fingerprint]['pt'])
|
||||
|
||||
# dragonpilot
|
||||
self.turning_signal_timer = 0
|
||||
self.dragon_enable_steering_on_signal = False
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, visual_alert, left_line, right_line):
|
||||
""" Controls thread """
|
||||
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
if frame % 500 == 0:
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
|
||||
P = self.params
|
||||
|
||||
# Send CAN commands.
|
||||
@@ -58,6 +74,23 @@ class CarController():
|
||||
if not lkas_enabled:
|
||||
apply_steer = 0
|
||||
|
||||
# dragonpilot
|
||||
if enabled:
|
||||
if self.dragon_enable_steering_on_signal:
|
||||
if CS.left_blinker_on == 0 and CS.right_blinker_on == 0:
|
||||
self.turning_signal_timer = 0
|
||||
else:
|
||||
self.turning_signal_timer = 100
|
||||
|
||||
if self.turning_signal_timer > 0:
|
||||
self.turning_signal_timer -= 1
|
||||
apply_steer = 0
|
||||
else:
|
||||
self.turning_signal_timer = 0
|
||||
|
||||
if not self.dragon_lat_ctrl:
|
||||
apply_steer = 0
|
||||
|
||||
can_sends.append(subarucan.create_steering_control(self.packer, CS.CP.carFingerprint, apply_steer, frame, P.STEER_STEP))
|
||||
|
||||
self.apply_steer_last = apply_steer
|
||||
|
||||
@@ -7,6 +7,10 @@ from selfdrive.car.subaru.values import CAR
|
||||
from selfdrive.car.subaru.carstate import CarState, get_powertrain_can_parser, get_camera_can_parser
|
||||
from selfdrive.car import STD_CARGO_KG, scale_rot_inertia, scale_tire_stiffness, gen_empty_fingerprint
|
||||
from selfdrive.car.interfaces import CarInterfaceBase
|
||||
from common.realtime import sec_since_boot
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
ButtonType = car.CarState.ButtonEvent.Type
|
||||
|
||||
@@ -30,6 +34,14 @@ class CarInterface(CarInterfaceBase):
|
||||
if CarController is not None:
|
||||
self.CC = CarController(CP.carFingerprint)
|
||||
|
||||
# dragonpilot
|
||||
self.frame = 0
|
||||
self.dragon_enable_steering_on_signal = False
|
||||
self.dragon_allow_gas = False
|
||||
self.ts_last_check = 0.
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
@staticmethod
|
||||
def compute_gb(accel, speed):
|
||||
return float(accel) / 4.0
|
||||
@@ -95,6 +107,17 @@ class CarInterface(CarInterfaceBase):
|
||||
|
||||
# returns a car.CarState
|
||||
def update(self, c, can_strings):
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
ts = sec_since_boot()
|
||||
if ts - self.ts_last_check >= 5.:
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else True
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
self.ts_last_check = ts
|
||||
|
||||
self.pt_cp.update_strings(can_strings)
|
||||
self.cam_cp.update_strings(can_strings)
|
||||
|
||||
@@ -166,17 +189,24 @@ class CarInterface(CarInterfaceBase):
|
||||
if ret.doorOpen:
|
||||
events.append(create_event('doorOpen', [ET.NO_ENTRY, ET.SOFT_DISABLE]))
|
||||
|
||||
if not self.dragon_lat_ctrl:
|
||||
events.append(create_event('manualSteeringRequired', [ET.WARNING]))
|
||||
elif (self.CS.left_blinker_on or self.CS.right_blinker_on) and self.dragon_enable_steering_on_signal:
|
||||
events.append(create_event('manualSteeringRequiredBlinkersOn', [ET.WARNING]))
|
||||
|
||||
if self.CS.acc_active and not self.acc_active_prev:
|
||||
events.append(create_event('pcmEnable', [ET.ENABLE]))
|
||||
if not self.CS.acc_active:
|
||||
events.append(create_event('pcmDisable', [ET.USER_DISABLE]))
|
||||
|
||||
# disable on gas pedal rising edge
|
||||
if (ret.gasPressed and not self.gas_pressed_prev):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
# DragonAllowGas
|
||||
if not self.dragon_allow_gas:
|
||||
# disable on gas pedal rising edge
|
||||
if (ret.gasPressed and not self.gas_pressed_prev):
|
||||
events.append(create_event('pedalPressed', [ET.NO_ENTRY, ET.USER_DISABLE]))
|
||||
|
||||
if ret.gasPressed:
|
||||
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
|
||||
if ret.gasPressed:
|
||||
events.append(create_event('pedalPressed', [ET.PRE_ENABLE]))
|
||||
|
||||
ret.events = events
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from selfdrive.car.toyota.values import Ecu, CAR, STATIC_MSGS, SteerLimitParams
|
||||
from opendbc.can.packer import CANPacker
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
||||
|
||||
@@ -109,16 +110,20 @@ class CarController():
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dragon_lane_departure_warning = True
|
||||
self.dragon_toyota_sng_mod = False
|
||||
self.dp_last_modified = None
|
||||
|
||||
def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, hud_alert,
|
||||
left_line, right_line, lead, left_lane_depart, right_lane_depart):
|
||||
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
if frame % 500 == 0:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dragon_lane_departure_warning = False if params.get("DragonToyotaLaneDepartureWarning", encoding='utf8') == "0" else True
|
||||
self.dragon_toyota_sng_mod = True if params.get("DragonToyotaSnGMod", encoding='utf8') == "1" else False
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dragon_lane_departure_warning = False if params.get("DragonToyotaLaneDepartureWarning", encoding='utf8') == "0" else True
|
||||
self.dragon_toyota_sng_mod = True if params.get("DragonToyotaSnGMod", encoding='utf8') == "1" else False
|
||||
self.dp_last_modified = modified
|
||||
|
||||
# *** compute control surfaces ***
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ from selfdrive.car.interfaces import CarInterfaceBase
|
||||
from common.realtime import sec_since_boot
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
ButtonType = car.CarState.ButtonEvent.Type
|
||||
GearShifter = car.CarState.GearShifter
|
||||
@@ -41,6 +42,7 @@ class CarInterface(CarInterfaceBase):
|
||||
self.dragon_allow_gas = False
|
||||
self.ts_last_check = 0.
|
||||
self.dragon_lat_ctrl = True
|
||||
self.dp_last_modified = None
|
||||
|
||||
@staticmethod
|
||||
def compute_gb(accel, speed):
|
||||
@@ -72,7 +74,7 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.wheelbase = 2.70
|
||||
ret.steerRatio = 15.74 # unknown end-to-end spec
|
||||
tire_stiffness_factor = 0.6371 # hand-tune
|
||||
ret.mass = 3045. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
ret.mass = 3370. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
|
||||
ret.lateralTuning.init('indi')
|
||||
ret.lateralTuning.indi.innerLoopGain = 4.0
|
||||
@@ -223,16 +225,6 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.mass = 3800. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
ret.lateralTuning.pid.kf = 0.00007818594
|
||||
|
||||
elif candidate == CAR.RAV4H_TSS2:
|
||||
stop_and_go = True
|
||||
ret.safetyParam = 73
|
||||
ret.wheelbase = 2.68986
|
||||
ret.steerRatio = 14.3
|
||||
tire_stiffness_factor = 0.7933
|
||||
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.6], [0.1]]
|
||||
ret.mass = 3800. * CV.LB_TO_KG + STD_CARGO_KG
|
||||
ret.lateralTuning.pid.kf = 0.00007818594
|
||||
|
||||
elif candidate in [CAR.COROLLA_TSS2, CAR.COROLLAH_TSS2]:
|
||||
stop_and_go = True
|
||||
ret.safetyParam = 73
|
||||
@@ -382,10 +374,13 @@ class CarInterface(CarInterfaceBase):
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
ts = sec_since_boot()
|
||||
if ts - self.ts_last_check >= 5.:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_toyota_stock_dsu = True if params.get("DragonToyotaStockDSU", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_enable_steering_on_signal = True if params.get("DragonEnableSteeringOnSignal", encoding='utf8') == "1" else False
|
||||
self.dragon_allow_gas = True if params.get("DragonAllowGas", encoding='utf8') == "1" else False
|
||||
self.dragon_toyota_stock_dsu = True if params.get("DragonToyotaStockDSU", encoding='utf8') == "1" else False
|
||||
self.dragon_lat_ctrl = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
self.dp_last_modified = modified
|
||||
self.ts_last_check = ts
|
||||
|
||||
# ******************* do can recv *******************
|
||||
|
||||
@@ -25,6 +25,7 @@ from selfdrive.controls.lib.alertmanager import AlertManager
|
||||
from selfdrive.controls.lib.vehicle_model import VehicleModel
|
||||
from selfdrive.controls.lib.planner import LON_MPC_STEP
|
||||
from selfdrive.locationd.calibration_helpers import Calibration, Filter
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
LANE_DEPARTURE_THRESHOLD = 0.1
|
||||
|
||||
@@ -546,15 +547,19 @@ def controlsd_thread(sm=None, pm=None, can_sock=None):
|
||||
dragon_display_steering_limit_alert = True
|
||||
dragon_stopped_has_lead_count = 0
|
||||
dragon_lead_car_moving_alert = False
|
||||
dp_last_modified = None
|
||||
|
||||
while True:
|
||||
# dragonpilot, don't check for param too often as it's a kernel call
|
||||
ts = sec_since_boot()
|
||||
if ts - ts_last_check > 5.:
|
||||
dragon_toyota_stock_dsu = True if params.get("DragonToyotaStockDSU", encoding='utf8') == "1" else False
|
||||
dragon_lat_control = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
dragon_display_steering_limit_alert = False if params.get("DragonDisplaySteeringLimitAlert", encoding='utf8') == "0" else True
|
||||
dragon_lead_car_moving_alert = True if params.get("DragonEnableLeadCarMovingAlert", encoding='utf8') == "1" else False
|
||||
if ts - ts_last_check >= 5.:
|
||||
modified = dp_get_last_modified()
|
||||
if dp_last_modified != modified:
|
||||
dragon_toyota_stock_dsu = True if params.get("DragonToyotaStockDSU", encoding='utf8') == "1" else False
|
||||
dragon_lat_control = False if params.get("DragonLatCtrl", encoding='utf8') == "0" else True
|
||||
dragon_display_steering_limit_alert = False if params.get("DragonDisplaySteeringLimitAlert", encoding='utf8') == "0" else True
|
||||
dragon_lead_car_moving_alert = True if params.get("DragonEnableLeadCarMovingAlert", encoding='utf8') == "1" else False
|
||||
dp_last_modified = modified
|
||||
ts_last_check = ts
|
||||
|
||||
start_time = sec_since_boot()
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
#!/usr/bin/env python3
|
||||
import gc
|
||||
from common.realtime import set_realtime_priority
|
||||
from common.realtime import set_realtime_priority, sec_since_boot
|
||||
from common.params import Params, put_nonblocking
|
||||
import cereal.messaging as messaging
|
||||
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
|
||||
from selfdrive.controls.lib.driver_monitor import DriverStatus, MAX_TERMINAL_ALERTS, MAX_TERMINAL_DURATION
|
||||
from selfdrive.locationd.calibration_helpers import Calibration
|
||||
from selfdrive.controls.lib.gps_helpers import is_rhd_region
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
def dmonitoringd_thread(sm=None, pm=None):
|
||||
gc.disable()
|
||||
@@ -40,8 +43,46 @@ def dmonitoringd_thread(sm=None, pm=None):
|
||||
v_cruise_last = 0
|
||||
driver_engaged = False
|
||||
|
||||
# dragonpilot
|
||||
last_ts = 0
|
||||
dp_last_modified = None
|
||||
dp_enable_driver_safety_check = True
|
||||
dp_enable_driver_monitoring = True
|
||||
|
||||
# 10Hz <- dmonitoringmodeld
|
||||
while True:
|
||||
cur_time = sec_since_boot()
|
||||
if cur_time - last_ts >= 5.:
|
||||
modified = dp_get_last_modified()
|
||||
if dp_last_modified != modified:
|
||||
dp_enable_driver_safety_check = False if params.get("DragonEnableDriverSafetyCheck", encoding='utf8') == "0" else True
|
||||
# load driver monitor val only when safety is on
|
||||
if dp_enable_driver_safety_check:
|
||||
dp_enable_driver_monitoring = False if params.get("DragonEnableDriverMonitoring", encoding='utf8') == "0" else True
|
||||
# load steering monitor timer val only when driver monitor is on
|
||||
if dp_enable_driver_safety_check:
|
||||
try:
|
||||
dp_awareness_time = int(params.get("DragonSteeringMonitorTimer", encoding='utf8'))
|
||||
except TypeError:
|
||||
dp_awareness_time = 0.
|
||||
driver_status.awareness_time = 86400 if dp_awareness_time <= 0. else dp_awareness_time * 60.
|
||||
dp_last_modified = modified
|
||||
last_ts = cur_time
|
||||
|
||||
if not dp_enable_driver_safety_check:
|
||||
dp_enable_driver_monitoring = False
|
||||
driver_status.awareness_time = 86400
|
||||
|
||||
# reset all awareness val and set to rhd region, this will enforce steering monitor.
|
||||
if not dp_enable_driver_monitoring:
|
||||
driver_status.is_rhd_region = True
|
||||
driver_status.is_rhd_region_checked = True
|
||||
driver_status.awareness = 1.
|
||||
driver_status.awareness_active = 1.
|
||||
driver_status.awareness_passive = 1.
|
||||
driver_status.terminal_alert_cnt = 0
|
||||
driver_status.terminal_time = 0
|
||||
|
||||
sm.update()
|
||||
|
||||
# GPS coords RHD parsing, once every restart
|
||||
|
||||
@@ -4,8 +4,6 @@ from common.realtime import DT_DMON
|
||||
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
|
||||
from common.filter_simple import FirstOrderFilter
|
||||
from common.stat_live import RunningStatFilter
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
|
||||
_AWARENESS_TIME = 70. # one minute limit without user touching steering wheels make the car enter a terminal status
|
||||
_AWARENESS_PRE_TIME_TILL_TERMINAL = 15. # a first alert is issued 25s before expiration
|
||||
@@ -114,10 +112,7 @@ class DriverStatus():
|
||||
self.is_rhd_region_checked = False
|
||||
|
||||
# dragonpilot
|
||||
self.awareness_time = float(params.get("DragonSteeringMonitorTimer", encoding='utf8'))
|
||||
self.awareness_time = 86400 if self.awareness_time <= 0. else self.awareness_time * 60.
|
||||
self.dragon_enable_driver_safety_check = False if params.get("DragonEnableDriverSafetyCheck", encoding='utf8') == "0" else True
|
||||
self.dragon_enable_driver_monitoring = False if params.get("DragonEnableDriverMonitoring", encoding='utf8') == "0" else True
|
||||
self.awareness_time = 70.
|
||||
|
||||
self._set_timers(active_monitoring=True)
|
||||
|
||||
@@ -182,9 +177,6 @@ class DriverStatus():
|
||||
if len(driver_state.faceOrientation) == 0 or len(driver_state.facePosition) == 0 or len(driver_state.faceOrientationStd) == 0 or len(driver_state.facePositionStd) == 0:
|
||||
return
|
||||
|
||||
if not self.dragon_enable_driver_monitoring:
|
||||
self.is_rhd_region = True
|
||||
|
||||
self.pose.roll, self.pose.pitch, self.pose.yaw = face_orientation_from_net(driver_state.faceOrientation, driver_state.facePosition, cal_rpy)
|
||||
self.pose.pitch_std = driver_state.faceOrientationStd[0]
|
||||
self.pose.yaw_std = driver_state.faceOrientationStd[1]
|
||||
@@ -220,7 +212,7 @@ class DriverStatus():
|
||||
self.hi_stds = 0
|
||||
|
||||
def update(self, events, driver_engaged, ctrl_active, standstill):
|
||||
if (driver_engaged and self.awareness > 0) or not ctrl_active or not self.dragon_enable_driver_safety_check:
|
||||
if (driver_engaged and self.awareness > 0) or not ctrl_active:
|
||||
# reset only when on disengagement if red reached
|
||||
self.awareness = 1.
|
||||
self.awareness_active = 1.
|
||||
|
||||
@@ -77,7 +77,7 @@ class LanePlanner():
|
||||
|
||||
def update_d_poly(self, v_ego):
|
||||
ts = sec_since_boot()
|
||||
if ts - self.ts_last_check > 5.:
|
||||
if ts - self.ts_last_check >= 5.:
|
||||
self.camera_offset = int(params.get("DragonCameraOffset", encoding='utf8')) * 0.01
|
||||
self.ts_last_check = ts
|
||||
# only offset left and right lane lines; offsetting p_poly does not make sense
|
||||
|
||||
@@ -11,6 +11,7 @@ import cereal.messaging as messaging
|
||||
from cereal import log
|
||||
# dragonpilot
|
||||
from common.params import Params
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
LaneChangeState = log.PathPlan.LaneChangeState
|
||||
LaneChangeDirection = log.PathPlan.LaneChangeDirection
|
||||
@@ -72,6 +73,7 @@ class PathPlanner():
|
||||
self.dragon_auto_lc_min_mph = 60 * CV.MPH_TO_MS
|
||||
self.dragon_auto_lc_delay = 2.
|
||||
self.last_ts = 0.
|
||||
self.dp_last_modified = None
|
||||
|
||||
def setup_mpc(self):
|
||||
self.libmpc = libmpc_py.libmpc
|
||||
@@ -92,26 +94,29 @@ class PathPlanner():
|
||||
def update(self, sm, pm, CP, VM):
|
||||
# dragonpilot
|
||||
cur_time = sec_since_boot()
|
||||
if cur_time - self.last_ts > 5.:
|
||||
self.dragon_assisted_lc_enabled = self.lane_change_enabled
|
||||
if self.dragon_assisted_lc_enabled:
|
||||
self.dragon_auto_lc_enabled = True if self.params.get("DragonEnableAutoLC", encoding='utf8') == "1" else False
|
||||
# adjustable assisted lc min speed
|
||||
self.dragon_assisted_lc_min_mph = int(self.params.get("DragonAssistedLCMinMPH", encoding='utf8')) * CV.MPH_TO_MS
|
||||
if self.dragon_assisted_lc_min_mph < 0:
|
||||
self.dragon_assisted_lc_min_mph = 0
|
||||
if self.dragon_auto_lc_enabled:
|
||||
# adjustable auto lc min speed
|
||||
self.dragon_auto_lc_min_mph = int(self.params.get("DragonAutoLCMinMPH", encoding='utf8')) * CV.MPH_TO_MS
|
||||
if self.dragon_auto_lc_min_mph < 0:
|
||||
self.dragon_auto_lc_min_mph = 0
|
||||
# when auto lc is smaller than assisted lc, we set assisted lc to the same speed as auto lc
|
||||
if self.dragon_auto_lc_min_mph < self.dragon_assisted_lc_min_mph:
|
||||
self.dragon_assisted_lc_min_mph = self.dragon_auto_lc_min_mph
|
||||
# adjustable auto lc delay
|
||||
self.dragon_auto_lc_delay = int(self.params.get("DragonAutoLCDelay", encoding='utf8'))
|
||||
if self.dragon_auto_lc_delay < 0:
|
||||
self.dragon_auto_lc_delay = 0
|
||||
if cur_time - self.last_ts >= 5.:
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_assisted_lc_enabled = self.lane_change_enabled
|
||||
if self.dragon_assisted_lc_enabled:
|
||||
self.dragon_auto_lc_enabled = True if self.params.get("DragonEnableAutoLC", encoding='utf8') == "1" else False
|
||||
# adjustable assisted lc min speed
|
||||
self.dragon_assisted_lc_min_mph = int(self.params.get("DragonAssistedLCMinMPH", encoding='utf8')) * CV.MPH_TO_MS
|
||||
if self.dragon_assisted_lc_min_mph < 0:
|
||||
self.dragon_assisted_lc_min_mph = 0
|
||||
if self.dragon_auto_lc_enabled:
|
||||
# adjustable auto lc min speed
|
||||
self.dragon_auto_lc_min_mph = int(self.params.get("DragonAutoLCMinMPH", encoding='utf8')) * CV.MPH_TO_MS
|
||||
if self.dragon_auto_lc_min_mph < 0:
|
||||
self.dragon_auto_lc_min_mph = 0
|
||||
# when auto lc is smaller than assisted lc, we set assisted lc to the same speed as auto lc
|
||||
if self.dragon_auto_lc_min_mph < self.dragon_assisted_lc_min_mph:
|
||||
self.dragon_assisted_lc_min_mph = self.dragon_auto_lc_min_mph
|
||||
# adjustable auto lc delay
|
||||
self.dragon_auto_lc_delay = int(self.params.get("DragonAutoLCDelay", encoding='utf8'))
|
||||
if self.dragon_auto_lc_delay < 0:
|
||||
self.dragon_auto_lc_delay = 0
|
||||
self.dp_last_modified = modified
|
||||
self.last_ts = cur_time
|
||||
|
||||
v_ego = sm['carState'].vEgo
|
||||
|
||||
@@ -13,6 +13,7 @@ from selfdrive.controls.lib.speed_smoother import speed_smoother
|
||||
from selfdrive.controls.lib.longcontrol import LongCtrlState, MIN_CAN_SPEED
|
||||
from selfdrive.controls.lib.fcw import FCWChecker
|
||||
from selfdrive.controls.lib.long_mpc import LongitudinalMpc
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
MAX_SPEED = 255.0
|
||||
|
||||
@@ -111,6 +112,7 @@ class Planner():
|
||||
self.dragon_fast_accel = False
|
||||
self.dragon_accel_profile = ACCEL_NORMAL_MODE
|
||||
self.last_ts = 0.
|
||||
self.dp_last_modified = None
|
||||
|
||||
def choose_solution(self, v_cruise_setpoint, enabled):
|
||||
if enabled:
|
||||
@@ -147,10 +149,13 @@ class Planner():
|
||||
# dragonpilot
|
||||
# update variable status every 5 secs
|
||||
if cur_time - self.last_ts >= 5.:
|
||||
self.dragon_slow_on_curve = False if self.params.get("DragonEnableSlowOnCurve", encoding='utf8') == "0" else True
|
||||
self.dragon_accel_profile = int(self.params.get("DragonAccelProfile", encoding='utf8'))
|
||||
if self.dragon_accel_profile >= 2 or self.dragon_accel_profile <= -2:
|
||||
self.dragon_accel_profile = 0
|
||||
modified = dp_get_last_modified()
|
||||
if self.dp_last_modified != modified:
|
||||
self.dragon_slow_on_curve = False if self.params.get("DragonEnableSlowOnCurve", encoding='utf8') == "0" else True
|
||||
self.dragon_accel_profile = int(self.params.get("DragonAccelProfile", encoding='utf8'))
|
||||
if self.dragon_accel_profile >= 2 or self.dragon_accel_profile <= -2:
|
||||
self.dragon_accel_profile = 0
|
||||
self.dp_last_modified = modified
|
||||
self.last_ts = cur_time
|
||||
|
||||
long_control_state = sm['controlsState'].longControlState
|
||||
|
||||
@@ -8,6 +8,8 @@ from selfdrive.swaglog import cloudlog
|
||||
from common.realtime import sec_since_boot
|
||||
from common.params import Params, put_nonblocking
|
||||
params = Params()
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
from math import floor
|
||||
|
||||
class App():
|
||||
|
||||
@@ -72,6 +74,8 @@ class App():
|
||||
|
||||
self.set_package_permissions()
|
||||
self.system("pm disable %s" % self.app)
|
||||
if self.manual_ctrl_param is not None:
|
||||
put_nonblocking(self.manual_ctrl_param, '0')
|
||||
self.last_ts = sec_since_boot()
|
||||
|
||||
def read_params(self):
|
||||
@@ -107,6 +111,7 @@ class App():
|
||||
# app is manually ctrl, we record that
|
||||
if self.manual_ctrl_param is not None and self.manual_ctrl_status == self.MANUAL_ON:
|
||||
put_nonblocking(self.manual_ctrl_param, '0')
|
||||
put_nonblocking('DragonLastModified', str(floor(time.time())))
|
||||
self.manually_ctrled = True
|
||||
self.is_running = False
|
||||
|
||||
@@ -280,6 +285,7 @@ def main():
|
||||
thermal_status = None
|
||||
start_ts = sec_since_boot()
|
||||
init_done = False
|
||||
last_modified = None
|
||||
|
||||
while 1: #has_enabled_apps:
|
||||
if not init_done and sec_since_boot() - start_ts >= 10:
|
||||
@@ -289,10 +295,11 @@ def main():
|
||||
if init_done:
|
||||
enabled_apps = []
|
||||
has_fullscreen_apps = False
|
||||
|
||||
modified = dp_get_last_modified()
|
||||
for app in apps:
|
||||
# read params loop
|
||||
app.read_params()
|
||||
if last_modified != modified:
|
||||
app.read_params()
|
||||
if app.last_is_enabled and not app.is_enabled and app.is_running:
|
||||
app.kill(True)
|
||||
|
||||
@@ -305,7 +312,7 @@ def main():
|
||||
app.run(True) if app.manual_ctrl_status == App.MANUAL_ON else app.kill(True)
|
||||
|
||||
enabled_apps.append(app)
|
||||
|
||||
last_modified = modified
|
||||
msg = messaging.recv_sock(thermal_sock, wait=True)
|
||||
started = msg.thermal.started
|
||||
# when car is running
|
||||
|
||||
@@ -29,7 +29,7 @@ def main(gctx=None):
|
||||
|
||||
thermal_sock = messaging.sub_sock('thermal')
|
||||
while 1:
|
||||
if params.get("DragonWazeMode", encoding='utf8') == "0" and params.get("DragonEnableDashcam", encoding='utf8') == "1":
|
||||
if params.get("DragonEnableDashcam", encoding='utf8') == "1":
|
||||
now = datetime.datetime.now()
|
||||
file_name = now.strftime("%Y-%m-%d_%H-%M-%S")
|
||||
os.system("screenrecord --bit-rate %s --time-limit %s %s%s.mp4 &" % (bit_rates, duration, dashcam_videos, file_name))
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#!/usr/bin/env python2.7
|
||||
from common.params import Params, put_nonblocking
|
||||
import time
|
||||
from math import floor
|
||||
|
||||
default_conf = {
|
||||
'DragonEnableDashcam': '0',
|
||||
'DragonEnableDriverSafetyCheck': '1',
|
||||
'DragonEnableAutoShutdown': '1',
|
||||
'DragonAutoShutdownAt': '0', # in minute
|
||||
'DragonEnableSteeringOnSignal': '0',
|
||||
'DragonEnableLogger': '1',
|
||||
@@ -66,6 +69,7 @@ default_conf = {
|
||||
'DragonBTG': 0,
|
||||
'DragonBootHotspot': 0,
|
||||
'DragonAccelProfile': '0',
|
||||
'DragonLastModified': str(floor(time.time()))
|
||||
}
|
||||
|
||||
deprecated_conf = {
|
||||
@@ -79,18 +83,21 @@ deprecated_conf_invert = {
|
||||
# 'DragonBBUI': False
|
||||
}
|
||||
|
||||
def dp_get_last_modified():
|
||||
return Params().get('DragonLastModified', encoding='utf-8')
|
||||
|
||||
def dragonpilot_set_params(params):
|
||||
# remove deprecated params
|
||||
for old, new in deprecated_conf.items():
|
||||
if params.get(old) is not None:
|
||||
if new is not None:
|
||||
old_val = str(params.get(old))
|
||||
new_val = old_val
|
||||
# invert the value if true
|
||||
if old in deprecated_conf_invert and deprecated_conf_invert[old] is True:
|
||||
new_val = "1" if old_val == "0" else "0"
|
||||
put_nonblocking(new, new_val)
|
||||
params.delete(old)
|
||||
# # remove deprecated params
|
||||
# for old, new in deprecated_conf.items():
|
||||
# if params.get(old) is not None:
|
||||
# if new is not None:
|
||||
# old_val = str(params.get(old))
|
||||
# new_val = old_val
|
||||
# # invert the value if true
|
||||
# if old in deprecated_conf_invert and deprecated_conf_invert[old] is True:
|
||||
# new_val = "1" if old_val == "0" else "0"
|
||||
# put_nonblocking(new, new_val)
|
||||
# params.delete(old)
|
||||
|
||||
# set params
|
||||
for key, val in default_conf.items():
|
||||
|
||||
@@ -1,53 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import time
|
||||
from common.params import Params
|
||||
params = Params()
|
||||
import cereal
|
||||
import cereal.messaging as messaging
|
||||
from common.realtime import sec_since_boot
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
|
||||
def main(gctx=None):
|
||||
|
||||
shutdown_count = 0
|
||||
auto_shutdown_at = get_shutdown_val()
|
||||
frame = 0
|
||||
last_shutdown_val = auto_shutdown_at
|
||||
def main():
|
||||
thermal_sock = messaging.sub_sock('thermal')
|
||||
last_ts = 0
|
||||
secs = 0
|
||||
last_secs = None
|
||||
shutdown_at = 0
|
||||
started = False
|
||||
|
||||
usb_online = False
|
||||
enabled = False
|
||||
last_enabled = None
|
||||
dp_last_modified = None
|
||||
while 1:
|
||||
if frame % 5 == 0:
|
||||
msg = messaging.recv_sock(thermal_sock, wait=True)
|
||||
started = msg.thermal.started
|
||||
with open("/sys/class/power_supply/usb/present") as f:
|
||||
usb_online = bool(int(f.read()))
|
||||
auto_shutdown_at = get_shutdown_val()
|
||||
if not last_shutdown_val == auto_shutdown_at:
|
||||
shutdown_count = 0
|
||||
last_shutdown_val = auto_shutdown_at
|
||||
cur_time = sec_since_boot()
|
||||
if cur_time - last_ts >= 10.:
|
||||
modified = dp_get_last_modified()
|
||||
if dp_last_modified != modified:
|
||||
enabled = True if params.get("DragonEnableAutoShutdown", encoding='utf8') == '1' else False
|
||||
if enabled:
|
||||
secs = int(params.get("DragonAutoShutdownAt", encoding='utf8')) * 60
|
||||
|
||||
if not started and not usb_online:
|
||||
shutdown_count += 1
|
||||
else:
|
||||
shutdown_count = 0
|
||||
dp_last_modified = modified
|
||||
|
||||
if auto_shutdown_at is None:
|
||||
auto_shutdown_at = get_shutdown_val()
|
||||
else:
|
||||
if shutdown_count >= auto_shutdown_at > 0:
|
||||
os.system('LD_LIBRARY_PATH="" svc power shutdown')
|
||||
if enabled:
|
||||
msg = messaging.recv_sock(thermal_sock, wait=True)
|
||||
started = msg.thermal.started
|
||||
usb_online = msg.thermal.usbOnline
|
||||
|
||||
time.sleep(1)
|
||||
if last_enabled != enabled or last_secs != secs or started or usb_online:
|
||||
shutdown_at = cur_time + secs
|
||||
|
||||
def get_shutdown_val():
|
||||
val = params.get("DragonAutoShutdownAt", encoding='utf8')
|
||||
if val is None:
|
||||
return None
|
||||
else:
|
||||
return int(val)*60 # convert to seconds
|
||||
last_enabled = enabled
|
||||
last_secs = secs
|
||||
last_ts = cur_time
|
||||
|
||||
if enabled and not started and not usb_online and secs > 0 and cur_time >= shutdown_at:
|
||||
os.system('LD_LIBRARY_PATH="" svc power shutdown')
|
||||
time.sleep(10)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -24,6 +24,7 @@ FW_SIGNATURE = get_expected_signature()
|
||||
params = Params()
|
||||
import subprocess
|
||||
import re
|
||||
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
|
||||
|
||||
ThermalStatus = log.ThermalData.ThermalStatus
|
||||
NetworkType = log.ThermalData.NetworkType
|
||||
@@ -185,13 +186,14 @@ def thermald_thread():
|
||||
|
||||
# dragonpilot
|
||||
ts_last_ip = None
|
||||
ts_last_update_vars = None
|
||||
ts_last_update_vars = 0
|
||||
ts_last_charging_ctrl = None
|
||||
dp_last_modified = None
|
||||
|
||||
ip_addr = '255.255.255.255'
|
||||
dragon_charging_ctrl = True if params.get('DragonChargingCtrl', encoding='utf8') == "1" else False
|
||||
dragon_charging_max = int(params.get('DragonCharging'))
|
||||
dragon_discharging_min = int(params.get('DragonDisCharging'))
|
||||
dragon_charging_ctrl = False
|
||||
dragon_to_discharge = 70
|
||||
dragon_to_charge = 60
|
||||
|
||||
while 1:
|
||||
health = messaging.recv_sock(health_sock, wait=True)
|
||||
@@ -241,7 +243,7 @@ def thermald_thread():
|
||||
# dragonpilot ip Mod
|
||||
# update ip every 10 seconds
|
||||
ts = sec_since_boot()
|
||||
if ts_last_ip is None or ts - ts_last_ip > 10.:
|
||||
if ts_last_ip is None or ts - ts_last_ip >= 10.:
|
||||
try:
|
||||
result = subprocess.check_output(["ifconfig", "wlan0"], encoding='utf8') # pylint: disable=unexpected-keyword-arg
|
||||
ip_addr = re.findall(r"inet addr:((\d+\.){3}\d+)", result)[0][0]
|
||||
@@ -284,15 +286,16 @@ def thermald_thread():
|
||||
# **** starting logic ****
|
||||
|
||||
# Check for last update time and display alerts if needed
|
||||
now = datetime.datetime.now()
|
||||
|
||||
# show invalid date/time alert
|
||||
time_valid = now.year >= 2019
|
||||
if time_valid and not time_valid_prev:
|
||||
params.delete("Offroad_InvalidTime")
|
||||
if not time_valid and time_valid_prev:
|
||||
params.put("Offroad_InvalidTime", json.dumps(OFFROAD_ALERTS["Offroad_InvalidTime"]))
|
||||
time_valid_prev = time_valid
|
||||
# now = datetime.datetime.now()
|
||||
#
|
||||
# # show invalid date/time alert
|
||||
# time_valid = now.year >= 2019
|
||||
# if time_valid and not time_valid_prev:
|
||||
# params.delete("Offroad_InvalidTime")
|
||||
# if not time_valid and time_valid_prev:
|
||||
# params.put("Offroad_InvalidTime", json.dumps(OFFROAD_ALERTS["Offroad_InvalidTime"]))
|
||||
# time_valid_prev = time_valid
|
||||
time_valid = True
|
||||
|
||||
# Show update prompt
|
||||
# try:
|
||||
@@ -412,18 +415,28 @@ def thermald_thread():
|
||||
# dragonpilot
|
||||
ts = sec_since_boot()
|
||||
# update variable status every 10 secs
|
||||
if ts_last_update_vars is None or ts - ts_last_update_vars >= 10.:
|
||||
dragon_charging_ctrl = True if params.get('DragonChargingCtrl', encoding='utf8') == "1" else False
|
||||
dragon_charging_max = int(params.get('DragonCharging', encoding='utf8'))
|
||||
dragon_discharging_min = int(params.get('DragonDisCharging', encoding='utf8'))
|
||||
if ts - ts_last_update_vars >= 10.:
|
||||
modified = dp_get_last_modified()
|
||||
if dp_last_modified != modified:
|
||||
dragon_charging_ctrl = True if params.get('DragonChargingCtrl', encoding='utf8') == "1" else False
|
||||
if dragon_charging_ctrl:
|
||||
try:
|
||||
dragon_to_discharge = int(params.get('DragonCharging', encoding='utf8'))
|
||||
except TypeError:
|
||||
dragon_to_discharge = 70
|
||||
try:
|
||||
dragon_to_charge = int(params.get('DragonDisCharging', encoding='utf8'))
|
||||
except TypeError:
|
||||
dragon_to_charge = 60
|
||||
dp_last_modified = modified
|
||||
ts_last_update_vars = ts
|
||||
|
||||
# we update charging status once every min
|
||||
if ts_last_charging_ctrl is None or ts - ts_last_charging_ctrl >= 60.:
|
||||
if dragon_charging_ctrl:
|
||||
if msg.thermal.batteryPercent >= dragon_charging_max:
|
||||
if msg.thermal.batteryPercent >= dragon_to_discharge:
|
||||
os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled')
|
||||
if msg.thermal.batteryPercent <= dragon_discharging_min:
|
||||
if msg.thermal.batteryPercent <= dragon_to_charge:
|
||||
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
|
||||
else:
|
||||
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
|
||||
|
||||
@@ -238,21 +238,21 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
||||
s->limit_set_speed_timeout = UI_FREQ;
|
||||
|
||||
// dragonpilot, 1hz
|
||||
s->dragon_ui_speed_timeout = UI_FREQ * 3.1;
|
||||
s->dragon_ui_event_timeout = UI_FREQ * 3.2;
|
||||
s->dragon_ui_maxspeed_timeout = UI_FREQ * 3.3;
|
||||
s->dragon_ui_face_timeout = UI_FREQ * 3.4;
|
||||
s->dragon_ui_dev_timeout = UI_FREQ * 3.5;
|
||||
s->dragon_ui_dev_mini_timeout = UI_FREQ * 3.6;
|
||||
s->dragon_enable_dashcam_timeout = UI_FREQ * 3.7;
|
||||
s->dragon_ui_volume_boost_timeout = UI_FREQ * 3.8;
|
||||
s->dragon_driving_ui_timeout = UI_FREQ * 3.9;
|
||||
s->dragon_ui_lane_timeout = UI_FREQ * 4.0;
|
||||
s->dragon_ui_lead_timeout = UI_FREQ * 4.1;
|
||||
s->dragon_ui_path_timeout = UI_FREQ * 4.2;
|
||||
s->dragon_ui_blinker_timeout = UI_FREQ * 4.3;
|
||||
s->dragon_waze_mode_timeout = UI_FREQ * 4.4;
|
||||
s->dragon_ui_dm_view_timeout = UI_FREQ * 4.5;
|
||||
s->dragon_ui_speed_timeout = UI_FREQ * 5.1;
|
||||
s->dragon_ui_event_timeout = UI_FREQ * 5.2;
|
||||
s->dragon_ui_maxspeed_timeout = UI_FREQ * 5.3;
|
||||
s->dragon_ui_face_timeout = UI_FREQ * 5.4;
|
||||
s->dragon_ui_dev_timeout = UI_FREQ * 5.5;
|
||||
s->dragon_ui_dev_mini_timeout = UI_FREQ * 5.6;
|
||||
s->dragon_enable_dashcam_timeout = UI_FREQ * 5.7;
|
||||
s->dragon_ui_volume_boost_timeout = UI_FREQ * 5.8;
|
||||
s->dragon_driving_ui_timeout = UI_FREQ * 5.9;
|
||||
s->dragon_ui_lane_timeout = UI_FREQ * 6.0;
|
||||
s->dragon_ui_lead_timeout = UI_FREQ * 6.1;
|
||||
s->dragon_ui_path_timeout = UI_FREQ * 6.2;
|
||||
s->dragon_ui_blinker_timeout = UI_FREQ * 6.3;
|
||||
s->dragon_waze_mode_timeout = UI_FREQ * 6.4;
|
||||
s->dragon_ui_dm_view_timeout = UI_FREQ * 6.5;
|
||||
}
|
||||
|
||||
static PathData read_path(cereal_ModelData_PathData_ptr pathp) {
|
||||
|
||||
Reference in New Issue
Block a user