Merge pull request #1 from eFiniLan/dragonpilot-dev

Dragonpilot 客制功能
This commit is contained in:
dragonpilot
2019-07-03 14:04:24 +10:00
committed by GitHub
26 changed files with 4222 additions and 879 deletions
+5
View File
@@ -77,6 +77,11 @@ keys = {
"SubscriberInfo": [TxType.PERSISTENT],
"TrainingVersion": [TxType.PERSISTENT],
"Version": [TxType.PERSISTENT],
#dragonpilot config
"DragonEnableDashcam": [TxType.PERSISTENT],
"DragonDisableDriverSafetyCheck": [TxType.PERSISTENT],
"DragonAutoShutdownAt": [TxType.PERSISTENT],
"DragonTempDisableSteerOnSignal": [TxType.PERSISTENT],
}
+371
View File
@@ -0,0 +1,371 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
NOTE: this is the newer (L) version of the system font configuration,
supporting richer weight selection. Some apps will expect the older
version, so please keep system_fonts.xml and fallback_fonts.xml in sync
with any changes, even though framework will only read this file.
All fonts withohut names are added to the default list. Fonts are chosen
based on a match: full BCP-47 language tag including script, then just
language, and finally order (the first font containing the glyph).
Order of appearance is also the tiebreaker for weight matching. This is
the reason why the 900 weights of Roboto precede the 700 weights - we
prefer the former when an 800 weight is requested. Since bold spans
effectively add 300 to the weight, this ensures that 900 is the bold
paired with the 500 weight, ensuring adequate contrast.
-->
<familyset version="22">
<!-- first font is default -->
<family name="sans-serif">
<font weight="100" style="normal">Roboto-Thin.ttf</font>
<font weight="100" style="italic">Roboto-ThinItalic.ttf</font>
<font weight="300" style="normal">Roboto-Light.ttf</font>
<font weight="300" style="italic">Roboto-LightItalic.ttf</font>
<font weight="400" style="normal">Roboto-Regular.ttf</font>
<font weight="400" style="italic">Roboto-Italic.ttf</font>
<font weight="500" style="normal">Roboto-Medium.ttf</font>
<font weight="500" style="italic">Roboto-MediumItalic.ttf</font>
<font weight="900" style="normal">Roboto-Black.ttf</font>
<font weight="900" style="italic">Roboto-BlackItalic.ttf</font>
<font weight="700" style="normal">Roboto-Bold.ttf</font>
<font weight="700" style="italic">Roboto-BoldItalic.ttf</font>
</family>
<!-- Note that aliases must come after the fonts they reference. -->
<alias name="sans-serif-thin" to="sans-serif" weight="100" />
<alias name="sans-serif-light" to="sans-serif" weight="300" />
<alias name="sans-serif-medium" to="sans-serif" weight="500" />
<alias name="sans-serif-black" to="sans-serif" weight="900" />
<alias name="arial" to="sans-serif" />
<alias name="helvetica" to="sans-serif" />
<alias name="tahoma" to="sans-serif" />
<alias name="verdana" to="sans-serif" />
<family name="sans-serif-condensed">
<font weight="300" style="normal">RobotoCondensed-Light.ttf</font>
<font weight="300" style="italic">RobotoCondensed-LightItalic.ttf</font>
<font weight="400" style="normal">RobotoCondensed-Regular.ttf</font>
<font weight="400" style="italic">RobotoCondensed-Italic.ttf</font>
<font weight="700" style="normal">RobotoCondensed-Bold.ttf</font>
<font weight="700" style="italic">RobotoCondensed-BoldItalic.ttf</font>
</family>
<alias name="sans-serif-condensed-light" to="sans-serif-condensed" weight="300" />
<family name="serif">
<font weight="400" style="normal">NotoSerif-Regular.ttf</font>
<font weight="700" style="normal">NotoSerif-Bold.ttf</font>
<font weight="400" style="italic">NotoSerif-Italic.ttf</font>
<font weight="700" style="italic">NotoSerif-BoldItalic.ttf</font>
</family>
<alias name="times" to="serif" />
<alias name="times new roman" to="serif" />
<alias name="palatino" to="serif" />
<alias name="georgia" to="serif" />
<alias name="baskerville" to="serif" />
<alias name="goudy" to="serif" />
<alias name="fantasy" to="serif" />
<alias name="ITC Stone Serif" to="serif" />
<family name="monospace">
<font weight="400" style="normal">DroidSansMono.ttf</font>
</family>
<alias name="sans-serif-monospace" to="monospace" />
<alias name="monaco" to="monospace" />
<family name="serif-monospace">
<font weight="400" style="normal">CutiveMono.ttf</font>
</family>
<alias name="courier" to="serif-monospace" />
<alias name="courier new" to="serif-monospace" />
<family name="casual">
<font weight="400" style="normal">ComingSoon.ttf</font>
</family>
<family name="cursive">
<font weight="400" style="normal">DancingScript-Regular.ttf</font>
<font weight="700" style="normal">DancingScript-Bold.ttf</font>
</family>
<family name="sans-serif-smallcaps">
<font weight="400" style="normal">CarroisGothicSC-Regular.ttf</font>
</family>
<!-- fallback fonts -->
<family variant="elegant">
<font weight="400" style="normal">NotoNaskhArabic-Regular.ttf</font>
<font weight="700" style="normal">NotoNaskhArabic-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoNaskhArabicUI-Regular.ttf</font>
<font weight="700" style="normal">NotoNaskhArabicUI-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansEthiopic-Regular.ttf</font>
<font weight="700" style="normal">NotoSansEthiopic-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansHebrew-Regular.ttf</font>
<font weight="700" style="normal">NotoSansHebrew-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansThai-Regular.ttf</font>
<font weight="700" style="normal">NotoSansThai-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansThaiUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansThaiUI-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansArmenian-Regular.ttf</font>
<font weight="700" style="normal">NotoSansArmenian-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansGeorgian-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGeorgian-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansDevanagari-Regular.ttf</font>
<font weight="700" style="normal">NotoSansDevanagari-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansDevanagariUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansDevanagariUI-Bold.ttf</font>
</family>
<!-- Gujarati should come after Devanagari -->
<family variant="elegant">
<font weight="400" style="normal">NotoSansGujarati-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGujarati-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansGujaratiUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGujaratiUI-Bold.ttf</font>
</family>
<!-- Gurmukhi should come after Devanagari -->
<family variant="elegant">
<font weight="400" style="normal">NotoSansGurmukhi-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGurmukhi-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansGurmukhiUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansGurmukhiUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansTamil-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTamil-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansTamilUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTamilUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansMalayalam-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMalayalam-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansMalayalamUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMalayalamUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansBengali-Regular.ttf</font>
<font weight="700" style="normal">NotoSansBengali-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansBengaliUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansBengaliUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansTelugu-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTelugu-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansTeluguUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansTeluguUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansKannada-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKannada-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansKannadaUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKannadaUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansOriya-Regular.ttf</font>
<font weight="700" style="normal">NotoSansOriya-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansOriyaUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansOriyaUI-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansSinhala-Regular.ttf</font>
<font weight="700" style="normal">NotoSansSinhala-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansKhmer-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKhmer-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansKhmerUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansKhmerUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansLao-Regular.ttf</font>
<font weight="700" style="normal">NotoSansLao-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansLaoUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansLaoUI-Bold.ttf</font>
</family>
<family variant="elegant">
<font weight="400" style="normal">NotoSansMyanmar-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMyanmar-Bold.ttf</font>
</family>
<family variant="compact">
<font weight="400" style="normal">NotoSansMyanmarUI-Regular.ttf</font>
<font weight="700" style="normal">NotoSansMyanmarUI-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansThaana-Regular.ttf</font>
<font weight="700" style="normal">NotoSansThaana-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansCham-Regular.ttf</font>
<font weight="700" style="normal">NotoSansCham-Bold.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansBalinese-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansBamum-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansBatak-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansBuginese-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansBuhid-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansCanadianAboriginal-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansCherokee-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansCoptic-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansGlagolitic-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansHanunoo-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansJavanese-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansKayahLi-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansLepcha-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansLimbu-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansLisu-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansMandaic-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansMeeteiMayek-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansNewTaiLue-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansNKo-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansOlChiki-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansRejang-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansSaurashtra-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansSundanese-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansSylotiNagri-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansSyriacEstrangela-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansTagbanwa-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansTaiTham-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansTaiViet-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansTibetan-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansTifinagh-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansVai-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansYi-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansSymbols-Regular-Subsetted.ttf</font>
</family>
<family lang="zh-Hans">
<font weight="400" style="normal">NotoSansSC-Regular.otf</font>
</family>
<family lang="zh-Hant">
<font weight="400" style="normal">NotoSansTC-Regular.otf</font>
</family>
<family lang="ja">
<font weight="400" style="normal">NotoSansJP-Regular.otf</font>
</family>
<family lang="ko">
<font weight="400" style="normal">NotoSansKR-Regular.otf</font>
</family>
<family>
<font weight="400" style="normal">NanumGothic.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoColorEmoji.ttf</font>
</family>
<family>
<font weight="400" style="normal">Miui-Regular.ttf</font>
</family>
<family lang="ja">
<font weight="400" style="normal">MTLmr3m.ttf</font>
</family>
<!--
Tai Le and Mongolian are intentionally kept last, to make sure they don't override
the East Asian punctuation for Chinese.
-->
<family>
<font weight="400" style="normal">NotoSansTaiLe-Regular.ttf</font>
</family>
<family>
<font weight="400" style="normal">NotoSansMongolian-Regular.ttf</font>
</family>
</familyset>
+50
View File
@@ -0,0 +1,50 @@
#!/usr/bin/bash
# Anndroid system locale, zh-TW = Traditional Chinese, zh-CN = Simplified Chinese
lang=en
update_font_reg=0
update_font_bold=0
remove_old_font=0
# check regular font
if [ ! -f "/system/fonts/Miui-Regular.ttf" ]; then
update_font_reg=1
fi
# check bold font
if [ ! -f "/system/fonts/Miui-Bold.ttf" ]; then
update_font_bold=1
fi
# check droidsans font
if ls /system/fonts/DroidSansFallback*.ttf 1> /dev/null 2>&1; then
remove_old_font=1
fi
if [ $update_font_reg -eq "1" ] || [ $update_font_bold -eq "1" ] || [ $remove_old_font -eq "1" ]; then
# sleep 5 secs in case, make sure the /system is remountable
sleep 5
mount -o remount,rw /system
if [ $update_font_reg -eq "1" ] || [ $update_font_bold -eq "1" ]; then
# download regular font
if [ $update_font_reg -eq "1" ]; then
yes | cp -rf /data/openpilot/dragonpilot/chinese-fonts/Miui-Regular.ttf /system/fonts/Miui-Regular.ttf
fi
# download bold font
if [ $update_font_bold -eq "1" ]; then
yes | cp -rf /data/openpilot/dragonpilot/chinese-fonts/Miui-Bold.ttf /system/fonts/Miui-Bold.ttf
fi
# dont new font mapping
yes | cp -rf /data/openpilot/dragonpilot/chinese-fonts/fonts.xml /system/etc/fonts.xml
chmod 644 /system/etc/fonts.xml
chmod 644 /system/fonts/Miui-*
fi
# remove driodsans font
if [ $remove_old_font -eq "1" ]; then
rm -fr /system/fonts/DroidSansFallback*.ttf
fi
mount -o remount,r /system
# change system locale
setprop persist.sys.locale $lang
fi
+1
View File
@@ -1,5 +1,6 @@
#!/usr/bin/bash
/usr/bin/sh /data/openpilot/dragonpilot/chinese-fonts/installer.sh &
export PASSIVE="0"
exec ./launch_chffrplus.sh
+1643 -710
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+13
View File
@@ -6,6 +6,8 @@ from selfdrive.car import create_gas_command
from selfdrive.car.honda import hondacan
from selfdrive.car.honda.values import AH, CruiseButtons, CAR
from selfdrive.can.packer import CANPacker
from common.params import Params
params = Params()
def actuator_hystereses(brake, braking, brake_steady, v_ego, car_fingerprint):
@@ -83,6 +85,9 @@ class CarController(object):
self.packer = CANPacker(dbc_name)
self.new_radar_config = False
# dragonpilot
self.turning_signal_timer = 0
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, \
@@ -146,6 +151,14 @@ class CarController(object):
# Send CAN commands.
can_sends = []
# dragonpilot
if enabled and (CS.left_blinker_on > 0 or CS.right_blinker_on > 0) and params.get("DragonTempDisableSteerOnSignal") == "1":
self.turning_signal_timer = 100
if self.turning_signal_timer > 0:
self.turning_signal_timer -= 1
apply_steer = 0
# Send steering command.
idx = frame % 4
can_sends.append(hondacan.create_steering_control(self.packer, apply_steer,
+14
View File
@@ -8,6 +8,9 @@ from selfdrive.car.toyota.toyotacan import make_can_msg, create_video_target,\
create_fcw_command
from selfdrive.car.toyota.values import ECU, STATIC_MSGS, TSS2_CAR
from selfdrive.can.packer import CANPacker
from common.params import Params
params = Params()
VisualAlert = car.CarControl.HUDControl.VisualAlert
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
@@ -123,6 +126,9 @@ class CarController(object):
self.packer = CANPacker(dbc_name)
# dragonpilot
self.turning_signal_timer = 0
def update(self, enabled, CS, frame, actuators,
pcm_cancel_cmd, hud_alert, audible_alert, forwarding_camera,
left_line, right_line, lead, left_lane_depart, right_lane_depart):
@@ -197,6 +203,14 @@ class CarController(object):
can_sends = []
# dragonpilot
if enabled and (CS.left_blinker_on or CS.right_blinker_on) and params.get("DragonTempDisableSteerOnSignal") == "1":
self.turning_signal_timer = 100
if self.turning_signal_timer > 0:
self.turning_signal_timer -= 1
apply_steer = 0
#*** control msgs ***
#print("steer {0} {1} {2} {3}".format(apply_steer, min_lim, max_lim, CS.steer_torque_motor)
+2
View File
@@ -1,3 +1,5 @@
# This Python file uses the following encoding: utf-8
# -*- coding: utf-8 -*-
from cereal import car, log
# Priority
+15 -12
View File
@@ -2,6 +2,8 @@ import numpy as np
from common.realtime import sec_since_boot, DT_CTRL, DT_DMON
from selfdrive.controls.lib.drive_helpers import create_event, EventTypes as ET
from common.filter_simple import FirstOrderFilter
from common.params import Params
params = Params()
_AWARENESS_TIME = 180 # 3 minutes limit without user touching steering wheels make the car enter a terminal status
_AWARENESS_PRE_TIME = 20. # a first alert is issued 20s before expiration
@@ -143,18 +145,19 @@ class DriverStatus():
not (standstill and self.awareness - self.step_change <= self.threshold_prompt):
self.awareness = max(self.awareness - self.step_change, -0.1)
alert = None
if self.awareness <= 0.:
# terminal red alert: disengagement required
alert = 'driverDistracted' if self.monitor_on else 'driverUnresponsive'
elif self.awareness <= self.threshold_prompt:
# prompt orange alert
alert = 'promptDriverDistracted' if self.monitor_on else 'promptDriverUnresponsive'
elif self.awareness <= self.threshold_pre:
# pre green alert
alert = 'preDriverDistracted' if self.monitor_on else 'preDriverUnresponsive'
if alert is not None:
events.append(create_event(alert, [ET.WARNING]))
if params.get("DragonDisableDriverSafetyCheck") == "0":
alert = None
if self.awareness <= 0.:
# terminal red alert: disengagement required
alert = 'driverDistracted' if self.monitor_on else 'driverUnresponsive'
elif self.awareness <= self.threshold_prompt:
# prompt orange alert
alert = 'promptDriverDistracted' if self.monitor_on else 'promptDriverUnresponsive'
elif self.awareness <= self.threshold_pre:
# pre green alert
alert = 'preDriverDistracted' if self.monitor_on else 'preDriverUnresponsive'
if alert is not None:
events.append(create_event(alert, [ET.WARNING]))
return events
+3 -3
View File
@@ -14,9 +14,9 @@ class ModelParser(object):
self.lead_dist, self.lead_prob, self.lead_var = 0, 0, 1
self._path_pinv = compute_path_pinv()
self.lane_width_estimate = 3.7
self.lane_width_estimate = 3.5
self.lane_width_certainty = 1.0
self.lane_width = 3.7
self.lane_width = 3.5
self.l_prob = 0.
self.r_prob = 0.
self.x_points = np.arange(50)
@@ -44,7 +44,7 @@ class ModelParser(object):
self.lane_width_certainty += 0.05 * (lr_prob - self.lane_width_certainty)
current_lane_width = abs(l_poly[3] - r_poly[3])
self.lane_width_estimate += 0.005 * (current_lane_width - self.lane_width_estimate)
speed_lane_width = interp(v_ego, [0., 31.], [3., 3.8])
speed_lane_width = interp(v_ego, [0., 31.], [3., 3.6])
self.lane_width = self.lane_width_certainty * self.lane_width_estimate + \
(1 - self.lane_width_certainty) * speed_lane_width
+25 -2
View File
@@ -19,8 +19,31 @@ if os.getenv("NOLOG") or os.getenv("NOCRASH"):
else:
from raven import Client
from raven.transport.http import HTTPTransport
client = Client('https://1994756b5e6f41cf939a4c65de45f4f2:cefebaf3a8aa40d182609785f7189bd7@app.getsentry.com/77924',
install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty})
with open("/data/openpilot/.git/HEAD", "r") as f:
content = f.read().split(' ')
branch = content[1]
error_tags = {'dirty': dirty, 'branch': branch}
try:
with open("/data/data/ai.comma.plus.offroad/files/persistStore/persist-auth", "r") as f:
auth = json.loads(f.read())
auth = json.loads(auth['commaUser'])
error_tags['username'] = auth['username']
error_tags['email'] = auth['email']
except:
pass
client = Client('https://980a0cba712a4c3593c33c78a12446e1:fecab286bcaf4dba8b04f7cff0188e2d@sentry.io/1488600',
install_sys_hook=False, transport=HTTPTransport, release=version, tags=error_tags)
try:
client.user_context(error_tags['username'])
except:
pass
def capture_warning(warning_string):
client.captureMessage(warning_string, level='warning')
def capture_info(info_string):
client.captureMessage(info_string, level='info')
def capture_exception(*args, **kwargs):
exc_info = sys.exc_info()
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env python2.7
#
# courtesy of pjlao307 (https://github.com/pjlao307/)
# this is just his original implementation but
# in openpilot service form so it's always on
#
# with the highest bit rates, the video is approx. 0.5MB per second
# the default value is set to 2.56Mbps = 0.32MB per second
#
import os
import time
import datetime
import zmq
import selfdrive.messaging as messaging
from selfdrive.services import service_list
from common.params import Params
params = Params()
dashcam_videos = '/sdcard/dashcam/'
duration = 60 # max is 180
bit_rates = 2560000 # max is 4000000
max_size_per_file = bit_rates/8*duration # 2.56Mbps / 8 * 60 = 19.2MB per 60 seconds
max_storage = max_size_per_file/duration*60*60*6 # 6 hours worth of footage (around 7gb)
freespace_limit = 0.15 # we start cleaning up footage when freespace is below 15%
def main(gctx=None):
if not os.path.exists(dashcam_videos):
os.makedirs(dashcam_videos)
poller = zmq.Poller()
sock = messaging.sub_sock(service_list['thermal'].port, poller)
poller.poll(timeout=1000)
while 1:
if params.get("DragonEnableDashcam") == "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))
used_spaces = get_used_spaces()
last_used_spaces = used_spaces
# we should clean up files here if use too much spaces
# when used spaces greater than max available storage
# or when free space is less than 10%
# get health of board, log this in "thermal"
msg = messaging.recv_sock(sock, wait=True)
if used_spaces >= max_storage or (msg is not None and msg.thermal.freeSpace < freespace_limit):
# get all the files in the dashcam_videos path
files = [f for f in sorted(os.listdir(dashcam_videos)) if os.path.isfile(dashcam_videos + f)]
for file in files:
msg = messaging.recv_sock(sock, wait=True)
# delete file one by one and once it has enough space for 1 video, we stop deleting
if used_spaces - last_used_spaces < max_size_per_file or msg.thermal.freeSpace < freespace_limit:
os.system("rm -fr %s" % (dashcam_videos + file))
last_used_spaces = get_used_spaces()
else:
break
# we start the process 1 second before screenrecord ended
# to make sure there are no missing footage
time.sleep(duration-1)
else:
time.sleep(1)
def get_used_spaces():
return sum(os.path.getsize(dashcam_videos + f) for f in os.listdir(dashcam_videos) if os.path.isfile(dashcam_videos + f))
if __name__ == "__main__":
main()
@@ -0,0 +1,50 @@
#!/usr/bin/env python2.7
# import os
# import json
# file = '/data/dragonpilot.json'
default_conf = {
'DragonEnableDashcam': '1',
'DragonDisableDriverSafetyCheck': '0',
'DragonAutoShutdownAt': '30', # in minute
'DragonTempDisableSteerOnSignal': '0',
}
# def write_json_config(config):
# with open(file, 'w') as f:
# json.dump(config, f, indent=2, sort_keys=True)
# os.chmod(file, 0644)
def dragonpilot_set_params(params):
# # create new json file
# if not os.path.isfile(file):
# write_json_config(default_conf)
# config = default_conf
# else:
# # load from json
# with open(file, 'r') as f:
# config = json.load(f)
#
# json_update_needed = False
# # add new keys
# for key, val in default_conf.items():
# if key not in config:
# json_update_needed = True
# config[key] = val
#
# # remove invalid keys
# for key, val in config.items():
# if key not in default_conf:
# json_update_needed = True
# config.pop(key, None)
#
# # write to json if update needed
# if json_update_needed:
# write_json_config(config)
# set params
for key, val in default_conf.items():
if params.get(key) is None:
params.put(key, str(val))
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,47 @@
#!/usr/bin/env python2.7
#
# I had a few incidents where OP suddenly stopped while cruising.
# This script is used to detect such event
#
import os
import subprocess
import zmq
from selfdrive.services import service_list
import selfdrive.messaging as messaging
mediaplayer = '/data/openpilot/selfdrive/dragonpilot/mediaplayer/'
def main(gctx=None):
poller = zmq.Poller()
sock = messaging.sub_sock(service_list['controlsState'].port, poller)
poller.poll(timeout=1000)
last_v_ego = 0.
last_active = False
env = dict(os.environ)
env['LD_LIBRARY_PATH'] = mediaplayer
while 1:
v_ego = 0
active = False
controls_state = messaging.recv_sock(sock, wait=True)
if controls_state is not None:
v_ego = controls_state.controlsState.vEgo
active = controls_state.controlsState.active
# we are driving and all of sudden we dont have any speed at all
# we better warn the driver before it's too late
if last_active and last_v_ego >= 5 and v_ego == 0:
subprocess.Popen([mediaplayer + 'mediaplayer', '/data/openpilot/selfdrive/dragonpilot/safeguardd/error.wav'], shell = False, stdin=None, stdout=None, stderr=None, env = env, close_fds=True)
last_active = active
last_v_ego = v_ego
if __name__ == "__main__":
main()
@@ -0,0 +1,39 @@
#!/usr/bin/env python2.7
import os
import time
from common.params import Params
params = Params()
def main(gctx=None):
shutdown_count = 0
autoShutdownAt = get_shutdown_val()
while 1:
with open("/sys/class/power_supply/usb/present") as f:
usb_online = bool(int(f.read()))
if not usb_online:
shutdown_count += 1
else:
shutdown_count = 0
if autoShutdownAt is None:
autoShutdownAt = get_shutdown_val()
else:
if shutdown_count >= autoShutdownAt > 0:
os.system('LD_LIBRARY_PATH="" svc power shutdown')
time.sleep(1)
def get_shutdown_val():
val = params.get("DragonAutoShutdownAt")
if val is None:
return None
else:
return int(val)*60 # convert to seconds
if __name__ == "__main__":
main()
+11 -1
View File
@@ -10,6 +10,8 @@ from common.basedir import BASEDIR
sys.path.append(os.path.join(BASEDIR, "pyextra"))
os.environ['BASEDIR'] = BASEDIR
from selfdrive.dragonpilot.dragonconf import dragonpilot_set_params
def unblock_stdout():
# get a non-blocking stdout
child_pid, child_pty = os.forkpty()
@@ -115,6 +117,9 @@ managed_processes = {
"gpsd": ("selfdrive/sensord", ["./start_gpsd.py"]),
"updated": "selfdrive.updated",
"athena": "selfdrive.athena.athenad",
"dashcamd": "selfdrive.dragonpilot.dashcamd.dashcamd",
"safeguardd": "selfdrive.dragonpilot.safeguardd.safeguardd",
"shutdownd": "selfdrive.dragonpilot.shutdownd.shutdownd",
}
android_packages = ("ai.comma.plus.offroad", "ai.comma.plus.frame")
@@ -137,6 +142,8 @@ persistent_processes = [
'ui',
'updated',
'athena',
'safeguardd',
'shutdownd',
]
car_started_processes = [
@@ -152,6 +159,7 @@ car_started_processes = [
'ubloxd',
'gpsd',
'deleter',
'dashcamd',
]
def register_managed_process(name, desc, car_started=False):
@@ -499,6 +507,8 @@ def main():
if params.get("LimitSetSpeed") is None:
params.put("LimitSetSpeed", "0")
dragonpilot_set_params(params)
# is this chffrplus?
if os.getenv("PASSIVE") is not None:
params.put("Passive", str(int(os.getenv("PASSIVE"))))
@@ -510,7 +520,7 @@ def main():
if os.getenv("PREPAREONLY") is not None:
spinner_proc = None
else:
spinner_text = "chffrplus" if params.get("Passive")=="1" else "openpilot"
spinner_text = "chffrplus" if params.get("Passive")=="1" else "dragonpilot"
spinner_proc = subprocess.Popen(["./spinner", "loading %s"%spinner_text],
cwd=os.path.join(BASEDIR, "selfdrive", "ui", "spinner"),
close_fds=True)
+1 -1
View File
@@ -104,7 +104,7 @@ def report_tombstone(fn, client):
def main(gctx=None):
initial_tombstones = set(get_tombstones())
client = Client('https://d3b175702f62402c91ade04d1c547e68:b20d68c813c74f63a7cdf9c4039d8f56@sentry.io/157615',
client = Client('https://980a0cba712a4c3593c33c78a12446e1:fecab286bcaf4dba8b04f7cff0188e2d@sentry.io/1488600',
install_sys_hook=False, transport=HTTPTransport, release=version, tags={'dirty': dirty}, string_max_length=10000)
client.user_context({'id': os.environ.get('DONGLE_ID')})
+87 -8
View File
@@ -35,6 +35,7 @@
#include "cereal/gen/c/log.capnp.h"
#include "slplay.h"
#include <time.h>
#define STATUS_STOPPED 0
#define STATUS_DISENGAGED 1
@@ -164,6 +165,11 @@ typedef struct UIScene {
bool gps_planner_active;
bool is_playing_alert;
// for minimal UI
float angleSteersDes;
float angleSteers;
} UIScene;
typedef struct {
@@ -196,6 +202,8 @@ typedef struct UIState {
int font_sans_regular;
int font_sans_semibold;
int font_sans_bold;
int font_miui_regular;
int font_miui_bold;
int img_wheel;
int img_turn;
int img_face;
@@ -511,6 +519,10 @@ static void ui_init(UIState *s) {
assert(s->font_sans_semibold >= 0);
s->font_sans_bold = nvgCreateFont(s->vg, "sans-bold", "../assets/OpenSans-Bold.ttf");
assert(s->font_sans_bold >= 0);
s->font_miui_regular = nvgCreateFont(s->vg, "miui-regular", "/system/fonts/Miui-Regular.ttf");
assert(s->font_miui_regular >= 0);
s->font_miui_bold = nvgCreateFont(s->vg, "miui-bold", "/system/fonts/Miui-Bold.ttf");
assert(s->font_miui_bold >= 0);
assert(s->img_wheel >= 0);
s->img_wheel = nvgCreateImage(s->vg, "../assets/img_chffr_wheel.png", 1);
@@ -1406,13 +1418,76 @@ static void ui_draw_vision_header(UIState *s) {
nvgRect(s->vg, ui_viz_rx, box_y, ui_viz_rw, header_h);
nvgFill(s->vg);
ui_draw_vision_maxspeed(s);
//ui_draw_vision_maxspeed(s);
#ifdef SHOW_SPEEDLIMIT
ui_draw_vision_speedlimit(s);
#endif
ui_draw_vision_speed(s);
ui_draw_vision_event(s);
//ui_draw_vision_event(s);
}
static void ui_draw_infobar(UIState *s) {
// timestamp from pjlao307 dashcam (https://github.com/pjlao307)
int rect_w = 1440; // 1920 * 0.75
int rect_h = 50;
int rect_x = (1920-rect_w)/2;
int rect_y = (1080-rect_h-50);
int sidebar_offset = 0;
bool hasSidebar = !s->scene.uilayout_sidebarcollapsed;
if (hasSidebar) {
sidebar_offset = 100;
}
// Get local time to display
char infobar[68];
time_t t = time(NULL);
struct tm tm = *localtime(&t);
char rel_steer[9];
snprintf(rel_steer, sizeof(rel_steer), "%s%05.1f°", s->scene.angleSteers < 0? "-" : "+", fabs(s->scene.angleSteers));
char des_steer[9];
if (s->scene.engaged) {
snprintf(des_steer, sizeof(des_steer), "%s%05.1f°", s->scene.angleSteersDes < 0? "-" : "+", fabs(s->scene.angleSteersDes));
} else {
snprintf(des_steer, sizeof(des_steer), "%7s", "N/A");
}
char lead_dist[8];
if (s->scene.lead_status) {
snprintf(lead_dist, sizeof(lead_dist), "%06.2fm", s->scene.lead_d_rel);
} else {
snprintf(lead_dist, sizeof(lead_dist), "%7s", "N/A");
}
snprintf(
infobar,
sizeof(infobar),
"%04d/%02d/%02d %02d:%02d:%02d | REL: %s | DES: %s | DIST: %s",
tm.tm_year + 1900,
tm.tm_mon + 1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
rel_steer,
des_steer,
lead_dist
);
nvgBeginPath(s->vg);
nvgRoundedRect(s->vg, rect_x + sidebar_offset, rect_y, rect_w, rect_h, 15);
nvgFillColor(s->vg, nvgRGBA(0, 0, 0, 100));
nvgFill(s->vg);
nvgFontSize(s->vg, 40);
nvgFontFace(s->vg, "courbd");
nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 175));
nvgText(s->vg, rect_x + 720 + sidebar_offset, rect_y + 35, infobar, NULL);
}
static void ui_draw_vision_footer(UIState *s) {
@@ -1423,11 +1498,12 @@ static void ui_draw_vision_footer(UIState *s) {
nvgBeginPath(s->vg);
nvgRect(s->vg, ui_viz_rx, footer_y, ui_viz_rw, footer_h);
ui_draw_vision_face(s);
//ui_draw_vision_face(s);
#ifdef SHOW_SPEEDLIMIT
ui_draw_vision_map(s);
#endif
ui_draw_infobar(s);
}
static void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
@@ -1462,23 +1538,23 @@ static void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BASELINE);
if (va_size == ALERTSIZE_SMALL) {
nvgFontFace(s->vg, "sans-semibold");
nvgFontFace(s->vg, "miui-bold");
nvgFontSize(s->vg, 40*2.5);
nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+15, va_text1, NULL);
} else if (va_size== ALERTSIZE_MID) {
nvgFontFace(s->vg, "sans-bold");
nvgFontFace(s->vg, "miui-bold");
nvgFontSize(s->vg, 48*2.5);
nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2-45, va_text1, NULL);
nvgFontFace(s->vg, "sans-regular");
nvgFontFace(s->vg, "miui-regular");
nvgFontSize(s->vg, 36*2.5);
nvgText(s->vg, alr_x+alr_w/2, alr_y+alr_h/2+75, va_text2, NULL);
} else if (va_size== ALERTSIZE_FULL) {
nvgFontSize(s->vg, (longAlert1?72:96)*2.5);
nvgFontFace(s->vg, "sans-bold");
nvgFontFace(s->vg, "miui-bold");
nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_MIDDLE);
nvgTextBox(s->vg, alr_x, alr_y+(longAlert1?360:420), alr_w-60, va_text1, NULL);
nvgFontSize(s->vg, 48*2.5);
nvgFontFace(s->vg, "sans-regular");
nvgFontFace(s->vg, "miui-regular");
nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_BOTTOM);
nvgTextBox(s->vg, alr_x, alr_h-(longAlert1?300:360), alr_w-60, va_text2, NULL);
}
@@ -1646,6 +1722,9 @@ void handle_message(UIState *s, void *which) {
s->scene.v_curvature = datad.vCurvature;
s->scene.decel_for_turn = datad.decelForTurn;
s->scene.angleSteers = datad.angleSteers;
s->scene.angleSteersDes = datad.angleSteersDes;
if (datad.alertSound.str && datad.alertSound.str[0] != '\0' && strcmp(s->alert_type, datad.alertType.str) != 0) {
char* error = NULL;
if (s->alert_sound[0] != '\0') {