performance optimisation.

This commit is contained in:
dragonpilot
2020-03-10 15:41:01 +10:00
parent 35d27ee879
commit d0e76602cf
18 changed files with 205 additions and 112 deletions
+1
View File
@@ -168,6 +168,7 @@ keys = {
"DragonBTG": [TxType.PERSISTENT],
"DragonBootHotspot": [TxType.PERSISTENT],
"DragonAccelProfile": [TxType.PERSISTENT],
"DragonLastModified": [TxType.PERSISTENT],
}
+7 -2
View File
@@ -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)
+9 -4
View File
@@ -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 *******************
+7 -3
View File
@@ -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
+9 -4
View File
@@ -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 *******************
+9 -4
View File
@@ -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 ***
+9 -4
View File
@@ -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):
@@ -382,10 +384,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 *******************
+10 -5
View File
@@ -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()
+21 -5
View File
@@ -1,11 +1,12 @@
from common.numpy_fast import interp
from math import atan2, sqrt
from common.realtime import DT_DMON
from common.realtime import DT_DMON, sec_since_boot
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()
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
_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 +115,11 @@ 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.last_ts = 0
self.dp_last_modified = None
self.awareness_time = 100
self.dragon_enable_driver_safety_check = True
self.dragon_enable_driver_monitoring = True
self._set_timers(active_monitoring=True)
@@ -220,6 +222,20 @@ class DriverStatus():
self.hi_stds = 0
def update(self, events, driver_engaged, ctrl_active, standstill):
cur_time = sec_since_boot()
if cur_time - self.last_ts >= 5.:
modified = dp_get_last_modified()
if self.dp_last_modified != modified:
self.awareness_time = int(params.get("DragonSteeringMonitorTimer", encoding='utf8'))
self.awareness_time = 100 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
if self.dragon_enable_driver_safety_check:
self.dragon_enable_driver_monitoring = False if params.get("DragonEnableDriverMonitoring", encoding='utf8') == "0" else True
else:
self.dragon_enable_driver_monitoring = False
self.dp_last_modified = modified
self.last_ts = cur_time
if (driver_engaged and self.awareness > 0) or not ctrl_active or not self.dragon_enable_driver_safety_check:
# reset only when on disengagement if red reached
self.awareness = 1.
+1 -1
View File
@@ -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
+25 -20
View File
@@ -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
+9 -4
View File
@@ -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
+12 -3
View File
@@ -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,13 @@ def main():
if init_done:
enabled_apps = []
has_fullscreen_apps = False
modified = dp_get_last_modified()
if last_modified != modified:
print("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 +314,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
+1 -1
View File
@@ -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))
+17 -11
View File
@@ -1,5 +1,7 @@
#!/usr/bin/env python2.7
from common.params import Params, put_nonblocking
import time
from math import floor
default_conf = {
'DragonEnableDashcam': '0',
@@ -67,6 +69,7 @@ default_conf = {
'DragonBTG': 0,
'DragonBootHotspot': 0,
'DragonAccelProfile': '0',
'DragonLastModified': str(floor(time.time()))
}
deprecated_conf = {
@@ -80,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():
+20 -15
View File
@@ -5,6 +5,7 @@ from common.params import Params
params = Params()
import cereal.messaging as messaging
from common.realtime import sec_since_boot
from selfdrive.dragonpilot.dragonconf import dp_get_last_modified
def main():
thermal_sock = messaging.sub_sock('thermal')
@@ -16,26 +17,30 @@ def main():
usb_online = False
enabled = False
last_enabled = False
dp_last_modified = None
while 1:
cur_time = sec_since_boot()
if cur_time - last_ts >= 10.:
enabled = True if params.get("DragonEnableAutoShutdown", encoding='utf8') == '1' else False
# reset timer when enabled status has changed
if not last_enabled and enabled:
shutdown_at = cur_time + secs
last_enabled = enabled
if enabled:
secs = int(params.get("DragonAutoShutdownAt", encoding='utf8')) * 60
# reset timer when secs num has changed
if last_secs != secs:
modified = dp_get_last_modified()
if dp_last_modified != modified:
enabled = True if params.get("DragonEnableAutoShutdown", encoding='utf8') == '1' else False
# reset timer when enabled status has changed
if not last_enabled and enabled:
shutdown_at = cur_time + secs
last_secs = secs
last_enabled = enabled
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()))
if enabled:
secs = int(params.get("DragonAutoShutdownAt", encoding='utf8')) * 60
# reset timer when secs num has changed
if last_secs != secs:
shutdown_at = cur_time + secs
last_secs = secs
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()))
dp_last_modified = modified
if enabled:
if started or usb_online:
+23 -11
View File
@@ -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_charging_at = 70
dragon_discharging_at = 80
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]
@@ -412,18 +414,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_charging_at = int(params.get('DragonCharging', encoding='utf8'))
except TypeError:
dragon_charging_at = 70
try:
dragon_discharging_at = int(params.get('DragonDisCharging', encoding='utf8'))
except TypeError:
dragon_discharging_at = 80
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_charging_at:
os.system('echo "0" > /sys/class/power_supply/battery/charging_enabled')
if msg.thermal.batteryPercent <= dragon_discharging_min:
if msg.thermal.batteryPercent <= dragon_discharging_at:
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
else:
os.system('echo "1" > /sys/class/power_supply/battery/charging_enabled')
+15 -15
View File
@@ -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) {