mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-19 00:33:52 +08:00
add waze mode
This commit is contained in:
@@ -150,6 +150,8 @@ keys = {
|
||||
"DragonIsEON": [TxType.PERSISTENT],
|
||||
"DragonHWChecked": [TxType.PERSISTENT],
|
||||
"DragonEnableSRLearner": [TxType.PERSISTENT],
|
||||
"DragonWazeMode": [TxType.PERSISTENT],
|
||||
"DragonRunWaze": [TxType.PERSISTENT],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,16 @@ gpsservice_main = "cn.dragonpilot.gpsservice.MainService"
|
||||
aegis = "tw.com.ainvest.outpack"
|
||||
aegis_main = "tw.com.ainvest.outpack.ui.MainActivity"
|
||||
|
||||
# v4.57.2.0
|
||||
waze = "com.waze"
|
||||
waze_main = "com.waze.MainActivity"
|
||||
|
||||
frame = "ai.comma.plus.frame"
|
||||
frame_main = ".MainActivity"
|
||||
|
||||
offroad = "ai.comma.plus.offroad"
|
||||
offroad_main = ".MainActivity"
|
||||
|
||||
def main(gctx=None):
|
||||
|
||||
dragon_enable_tomtom = True if params.get('DragonEnableTomTom', encoding='utf8') == "1" else False
|
||||
@@ -39,16 +49,23 @@ def main(gctx=None):
|
||||
dragon_boot_autonavi = True if params.get("DragonBootAutonavi", encoding='utf8') == "1" else False
|
||||
dragon_boot_aegis = True if params.get("DragonBootAegis", encoding='utf8') == "1" else False
|
||||
dragon_greypanda_mode = True if params.get("DragonGreyPandaMode", encoding='utf8') == "1" else False
|
||||
dragon_waze_mode = True if params.get("DragonWazeMode", encoding='utf8') == "1" else False
|
||||
if dragon_waze_mode:
|
||||
dragon_enable_tomtom = False
|
||||
dragon_enable_autonavi = False
|
||||
dragon_enable_aegis = False
|
||||
|
||||
dragon_grepanda_mode_started = False
|
||||
tomtom_is_running = False
|
||||
autonavi_is_running = False
|
||||
aegis_is_running = False
|
||||
mixplorer_is_running = False
|
||||
waze_is_running = False
|
||||
allow_auto_boot = True
|
||||
manual_tomtom = False
|
||||
manual_autonavi = False
|
||||
manual_aegis = False
|
||||
manual_waze = False
|
||||
last_started = False
|
||||
frame = 0
|
||||
start_delay = None
|
||||
@@ -58,6 +75,7 @@ def main(gctx=None):
|
||||
put_nonblocking('DragonRunAutonavi', '0')
|
||||
put_nonblocking('DragonRunMixplorer', '0')
|
||||
put_nonblocking('DragonRunAegis', '0')
|
||||
put_nonblocking('DragonRunWaze', '0')
|
||||
|
||||
# we want to disable all app when boot
|
||||
system("pm disable %s" % tomtom)
|
||||
@@ -65,10 +83,11 @@ def main(gctx=None):
|
||||
system("pm disable %s" % mixplorer)
|
||||
system("pm disable %s" % gpsservice)
|
||||
system("pm disable %s" % aegis)
|
||||
system("pm disable %s" % waze)
|
||||
|
||||
thermal_sock = messaging.sub_sock('thermal')
|
||||
|
||||
while dragon_enable_tomtom or dragon_enable_autonavi or dragon_enable_aegis or dragon_enable_mixplorer or dragon_greypanda_mode:
|
||||
while dragon_enable_tomtom or dragon_enable_autonavi or dragon_enable_aegis or dragon_enable_mixplorer or dragon_greypanda_mode or dragon_waze_mode:
|
||||
|
||||
# allow user to manually start/stop app
|
||||
if dragon_enable_tomtom:
|
||||
@@ -98,6 +117,17 @@ def main(gctx=None):
|
||||
mixplorer_is_running = exec_app(status, mixplorer, mixplorer_main)
|
||||
put_nonblocking('DragonRunMixplorer', '0')
|
||||
|
||||
if dragon_waze_mode:
|
||||
status = params.get('DragonRunWaze', encoding='utf8')
|
||||
if not status == "0":
|
||||
if status == "1":
|
||||
start_waze_prep()
|
||||
elif status == "-1":
|
||||
stop_waze_prep()
|
||||
waze_is_running = exec_app(status, waze, waze_main)
|
||||
put_nonblocking('DragonRunWaze', '0')
|
||||
manual_waze = status != "0"
|
||||
|
||||
# if manual control is set, we do not allow any of the auto actions
|
||||
auto_tomtom = not manual_tomtom and dragon_enable_tomtom and dragon_boot_tomtom
|
||||
auto_autonavi = not manual_autonavi and dragon_enable_autonavi and dragon_boot_autonavi
|
||||
@@ -107,41 +137,48 @@ def main(gctx=None):
|
||||
started = msg.thermal.started
|
||||
# car on
|
||||
if started:
|
||||
stop_delay = None
|
||||
if start_delay is None:
|
||||
start_delay = frame + 3
|
||||
|
||||
if dragon_greypanda_mode and not dragon_grepanda_mode_started:
|
||||
dragon_grepanda_mode_started = True
|
||||
system("pm enable %s" % gpsservice)
|
||||
system("am startservice %s/%s" % (gpsservice, gpsservice_main))
|
||||
|
||||
stop_delay = None
|
||||
if start_delay is None:
|
||||
start_delay = frame + 5
|
||||
#
|
||||
# Logic:
|
||||
# if temp reach red, we disable all 3rd party apps.
|
||||
# once the temp drop below yellow, we then re-enable them
|
||||
#
|
||||
# set allow_auto_boot back to True once the thermal status is < yellow
|
||||
thermal_status = msg.thermal.thermalStatus
|
||||
if not allow_auto_boot and thermal_status < ThermalStatus.yellow:
|
||||
allow_auto_boot = True
|
||||
if allow_auto_boot:
|
||||
# only allow auto boot when thermal status is < red
|
||||
if thermal_status < ThermalStatus.red:
|
||||
if auto_tomtom and not tomtom_is_running and frame > start_delay:
|
||||
tomtom_is_running = exec_app('1', tomtom, tomtom_main)
|
||||
if auto_autonavi and not autonavi_is_running and frame > start_delay:
|
||||
autonavi_is_running = exec_app('1', autonavi, autonavi_main)
|
||||
if auto_aegis and not aegis_is_running and frame > start_delay:
|
||||
aegis_is_running = exec_app('1', aegis, aegis_main)
|
||||
else:
|
||||
if auto_tomtom and tomtom_is_running:
|
||||
tomtom_is_running = exec_app('-1', tomtom, tomtom_main)
|
||||
if auto_autonavi and autonavi_is_running:
|
||||
autonavi_is_running = exec_app('-1', autonavi, autonavi_main)
|
||||
if auto_aegis and aegis_is_running:
|
||||
aegis_is_running = exec_app('-1', aegis, aegis_main)
|
||||
# set allow_auto_boot to False once the thermal status is >= red
|
||||
allow_auto_boot = False
|
||||
if dragon_waze_mode:
|
||||
if not manual_waze and not waze_is_running:
|
||||
start_waze_prep()
|
||||
waze_is_running = exec_app('1', waze, waze_main)
|
||||
else:
|
||||
|
||||
#
|
||||
# Logic:
|
||||
# if temp reach red, we disable all 3rd party apps.
|
||||
# once the temp drop below yellow, we then re-enable them
|
||||
#
|
||||
# set allow_auto_boot back to True once the thermal status is < yellow
|
||||
thermal_status = msg.thermal.thermalStatus
|
||||
if not allow_auto_boot and thermal_status < ThermalStatus.yellow:
|
||||
allow_auto_boot = True
|
||||
if allow_auto_boot:
|
||||
# only allow auto boot when thermal status is < red
|
||||
if thermal_status < ThermalStatus.red:
|
||||
if auto_tomtom and not tomtom_is_running and frame > start_delay:
|
||||
tomtom_is_running = exec_app('1', tomtom, tomtom_main)
|
||||
if auto_autonavi and not autonavi_is_running and frame > start_delay:
|
||||
autonavi_is_running = exec_app('1', autonavi, autonavi_main)
|
||||
if auto_aegis and not aegis_is_running and frame > start_delay:
|
||||
aegis_is_running = exec_app('1', aegis, aegis_main)
|
||||
else:
|
||||
if auto_tomtom and tomtom_is_running:
|
||||
tomtom_is_running = exec_app('-1', tomtom, tomtom_main)
|
||||
if auto_autonavi and autonavi_is_running:
|
||||
autonavi_is_running = exec_app('-1', autonavi, autonavi_main)
|
||||
if auto_aegis and aegis_is_running:
|
||||
aegis_is_running = exec_app('-1', aegis, aegis_main)
|
||||
# set allow_auto_boot to False once the thermal status is >= red
|
||||
allow_auto_boot = False
|
||||
|
||||
# kill mixplorer when car started
|
||||
if mixplorer_is_running:
|
||||
@@ -149,31 +186,52 @@ def main(gctx=None):
|
||||
|
||||
# car off
|
||||
else:
|
||||
start_delay = None
|
||||
if stop_delay is None:
|
||||
stop_delay = frame + 30
|
||||
|
||||
if dragon_greypanda_mode and dragon_grepanda_mode_started:
|
||||
dragon_grepanda_mode_started = False
|
||||
system("pm disable %s" % gpsservice)
|
||||
|
||||
start_delay = None
|
||||
if stop_delay is None:
|
||||
stop_delay = frame + 30
|
||||
if auto_tomtom and tomtom_is_running and frame > stop_delay:
|
||||
tomtom_is_running = exec_app('-1', tomtom, tomtom_main)
|
||||
if auto_autonavi and autonavi_is_running and frame > stop_delay:
|
||||
autonavi_is_running = exec_app('-1', autonavi, autonavi_main)
|
||||
if auto_aegis and aegis_is_running and frame > stop_delay:
|
||||
aegis_is_running = exec_app('-1', aegis, aegis_main)
|
||||
if dragon_waze_mode:
|
||||
if not manual_waze and waze_is_running:
|
||||
stop_waze_prep()
|
||||
waze_is_running = exec_app('-1', waze, waze_main)
|
||||
else:
|
||||
if auto_tomtom and tomtom_is_running and frame > stop_delay:
|
||||
tomtom_is_running = exec_app('-1', tomtom, tomtom_main)
|
||||
if auto_autonavi and autonavi_is_running and frame > stop_delay:
|
||||
autonavi_is_running = exec_app('-1', autonavi, autonavi_main)
|
||||
if auto_aegis and aegis_is_running and frame > stop_delay:
|
||||
aegis_is_running = exec_app('-1', aegis, aegis_main)
|
||||
|
||||
# if car state changed, we remove manual control state
|
||||
if not last_started == started:
|
||||
manual_tomtom = False
|
||||
manual_autonavi = False
|
||||
manual_aegis = False
|
||||
manual_waze = False
|
||||
|
||||
last_started = started
|
||||
frame += 3
|
||||
# every 3 seconds, we re-check status
|
||||
time.sleep(3)
|
||||
|
||||
# when starting waze, we want to disable frame
|
||||
def start_waze_prep():
|
||||
system("pm disable %s" % frame)
|
||||
system("am start -n %s/%s" % (offroad, offroad_main))
|
||||
|
||||
# when stopping waze
|
||||
# we want to disable offroad first and enable offroad (this way the offroad sits in the background waiting for launch.)
|
||||
# then we re-enable frame and start frame app (the offroad app will start shortly after)
|
||||
def stop_waze_prep():
|
||||
system("pm disable %s" % offroad)
|
||||
system("pm enable %s" % offroad)
|
||||
system("pm enable %s" % frame)
|
||||
system("am start -n %s/%s" % (frame, frame_main))
|
||||
|
||||
def exec_app(status, app, app_main):
|
||||
if status == "1":
|
||||
system("pm enable %s" % app)
|
||||
|
||||
@@ -30,7 +30,7 @@ def main(gctx=None):
|
||||
|
||||
thermal_sock = messaging.sub_sock('thermal')
|
||||
while 1:
|
||||
if params.get("DragonEnableDashcam", encoding='utf8') == "1":
|
||||
if params.get("DragonWazeMode", encoding='utf8') == "0" and 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))
|
||||
@@ -61,7 +61,7 @@ def main(gctx=None):
|
||||
# to make sure there are no missing footage
|
||||
time.sleep(duration-1-time_diff)
|
||||
else:
|
||||
time.sleep(1)
|
||||
time.sleep(5)
|
||||
|
||||
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))
|
||||
|
||||
@@ -57,6 +57,8 @@ default_conf = {
|
||||
'DragonIsEON': '1',
|
||||
'DragonHWChecked': '0',
|
||||
'DragonEnableSRLearner': '1',
|
||||
'DragonWazeMode': '0',
|
||||
'DragonRunWaze': '0',
|
||||
}
|
||||
|
||||
deprecated_conf = {
|
||||
|
||||
@@ -99,7 +99,7 @@ managed_processes = {
|
||||
daemon_processes = {
|
||||
"manage_athenad": ("selfdrive.athena.manage_athenad", "AthenadPid"),
|
||||
}
|
||||
android_packages = ("tw.com.ainvest.outpack", "cn.dragonpilot.gpsservice", "com.autonavi.amapauto", "com.mixplorer", "com.tomtom.speedcams.android.map", "ai.comma.plus.offroad", "ai.comma.plus.frame")
|
||||
android_packages = ("tw.com.ainvest.outpack", "cn.dragonpilot.gpsservice", "com.autonavi.amapauto", "com.mixplorer", "com.tomtom.speedcams.android.map", "com.waze", "ai.comma.plus.offroad", "ai.comma.plus.frame")
|
||||
|
||||
running = {}
|
||||
def get_running():
|
||||
@@ -445,10 +445,10 @@ def update_apks():
|
||||
def manager_update():
|
||||
update_apks()
|
||||
|
||||
uninstall = [app for app in get_installed_apks().keys() if app in ("com.spotify.music", "com.waze")]
|
||||
for app in uninstall:
|
||||
cloudlog.info("uninstalling %s" % app)
|
||||
os.system("pm uninstall % s" % app)
|
||||
#uninstall = [app for app in get_installed_apks().keys() if app in ("com.spotify.music", "com.waze")]
|
||||
#for app in uninstall:
|
||||
# cloudlog.info("uninstalling %s" % app)
|
||||
# os.system("pm uninstall % s" % app)
|
||||
|
||||
def manager_prepare(spinner=None):
|
||||
# build cereal first
|
||||
|
||||
@@ -323,6 +323,7 @@ typedef struct UIState {
|
||||
int dragon_ui_lead_timeout;
|
||||
int dragon_ui_path_timeout;
|
||||
int dragon_ui_blinker_timeout;
|
||||
int dragon_waze_mode_timeout;
|
||||
|
||||
bool dragon_ui_speed;
|
||||
bool dragon_ui_event;
|
||||
@@ -337,6 +338,7 @@ typedef struct UIState {
|
||||
bool dragon_ui_lead;
|
||||
bool dragon_ui_path;
|
||||
bool dragon_ui_blinker;
|
||||
bool dragon_waze_mode;
|
||||
|
||||
} UIState;
|
||||
|
||||
@@ -733,19 +735,35 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
||||
read_param_bool(&s->longitudinal_control, "LongitudinalControl");
|
||||
read_param_bool(&s->limit_set_speed, "LimitSetSpeed");
|
||||
// dragonpilot
|
||||
read_param_bool(&s->dragon_ui_speed, "DragonUISpeed");
|
||||
read_param_bool(&s->dragon_ui_event, "DragonUIEvent");
|
||||
read_param_bool(&s->dragon_ui_maxspeed, "DragonUIMaxSpeed");
|
||||
read_param_bool(&s->dragon_ui_face, "DragonUIFace");
|
||||
read_param_bool(&s->dragon_ui_dev, "DragonUIDev");
|
||||
read_param_bool(&s->dragon_ui_dev_mini, "DragonUIDevMini");
|
||||
read_param_bool(&s->dragon_enable_dashcam, "DragonEnableDashcam");
|
||||
read_param_float(&s->dragon_ui_volume_boost, "DragonUIVolumeBoost");
|
||||
read_param_bool(&s->dragon_driving_ui, "DragonDrivingUI");
|
||||
read_param_bool(&s->dragon_ui_lane, "DragonUILane");
|
||||
read_param_bool(&s->dragon_ui_lead, "DragonUILead");
|
||||
read_param_bool(&s->dragon_ui_path, "DragonUIPath");
|
||||
read_param_bool(&s->dragon_ui_blinker, "DragonUIBlinker");
|
||||
read_param_bool(&s->dragon_waze_mode, "DragonWazeMode");
|
||||
if (s->dragon_waze_mode) {
|
||||
s->dragon_ui_speed = false;
|
||||
s->dragon_ui_event = false;
|
||||
s->dragon_ui_maxspeed = false;
|
||||
s->dragon_ui_face = false;
|
||||
s->dragon_ui_dev = false;
|
||||
s->dragon_ui_dev_mini = false;
|
||||
s->dragon_enable_dashcam = false;
|
||||
s->dragon_driving_ui = false;
|
||||
s->dragon_ui_lane = false;
|
||||
s->dragon_ui_lead = false;
|
||||
s->dragon_ui_path = false;
|
||||
s->dragon_ui_blinker = false;
|
||||
} else {
|
||||
read_param_bool(&s->dragon_ui_speed, "DragonUISpeed");
|
||||
read_param_bool(&s->dragon_ui_event, "DragonUIEvent");
|
||||
read_param_bool(&s->dragon_ui_maxspeed, "DragonUIMaxSpeed");
|
||||
read_param_bool(&s->dragon_ui_face, "DragonUIFace");
|
||||
read_param_bool(&s->dragon_ui_dev, "DragonUIDev");
|
||||
read_param_bool(&s->dragon_ui_dev_mini, "DragonUIDevMini");
|
||||
read_param_bool(&s->dragon_enable_dashcam, "DragonEnableDashcam");
|
||||
read_param_bool(&s->dragon_driving_ui, "DragonDrivingUI");
|
||||
read_param_bool(&s->dragon_ui_lane, "DragonUILane");
|
||||
read_param_bool(&s->dragon_ui_lead, "DragonUILead");
|
||||
read_param_bool(&s->dragon_ui_path, "DragonUIPath");
|
||||
read_param_bool(&s->dragon_ui_blinker, "DragonUIBlinker");
|
||||
}
|
||||
|
||||
|
||||
// Set offsets so params don't get read at the same time
|
||||
@@ -767,6 +785,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
||||
s->dragon_ui_lead_timeout = 100;
|
||||
s->dragon_ui_path_timeout = 100;
|
||||
s->dragon_ui_blinker_timeout = 100;
|
||||
s->dragon_waze_mode_timeout = 100;
|
||||
}
|
||||
|
||||
// Projects a point in car to space to the corresponding point in full frame
|
||||
@@ -2706,19 +2725,36 @@ int main(int argc, char* argv[]) {
|
||||
read_param_bool_timeout(&s->limit_set_speed, "LimitSetSpeed", &s->limit_set_speed_timeout);
|
||||
read_param_float_timeout(&s->speed_lim_off, "SpeedLimitOffset", &s->limit_set_speed_timeout);
|
||||
// dragonpilot
|
||||
read_param_bool_timeout(&s->dragon_ui_speed, "DragonUISpeed", &s->dragon_ui_speed_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_event, "DragonUIEvent", &s->dragon_ui_event_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_maxspeed, "DragonUIMaxSpeed", &s->dragon_ui_maxspeed_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_face, "DragonUIFace", &s->dragon_ui_face_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_dev, "DragonUIDev", &s->dragon_ui_dev_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_dev_mini, "DragonUIDevMini", &s->dragon_ui_dev_mini_timeout);
|
||||
read_param_bool_timeout(&s->dragon_enable_dashcam, "DragonEnableDashcam", &s->dragon_enable_dashcam_timeout);
|
||||
read_param_float_timeout(&s->dragon_ui_volume_boost, "DragonUIVolumeBoost", &s->dragon_ui_volume_boost_timeout);
|
||||
read_param_bool_timeout(&s->dragon_driving_ui, "DragonDrivingUI", &s->dragon_driving_ui_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_lane, "DragonUILane", &s->dragon_ui_lane_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_lead, "DragonUILead", &s->dragon_ui_lead_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_path, "DragonUIPath", &s->dragon_ui_path_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_blinker, "DragonUIBlinker", &s->dragon_ui_blinker_timeout);
|
||||
read_param_bool_timeout(&s->dragon_waze_mode, "DragonWazeMode", &s->dragon_waze_mode_timeout);
|
||||
|
||||
if (s->dragon_waze_mode) {
|
||||
s->dragon_ui_speed = false;
|
||||
s->dragon_ui_event = false;
|
||||
s->dragon_ui_maxspeed = false;
|
||||
s->dragon_ui_face = false;
|
||||
s->dragon_ui_dev = false;
|
||||
s->dragon_ui_dev_mini = false;
|
||||
s->dragon_enable_dashcam = false;
|
||||
s->dragon_driving_ui = false;
|
||||
s->dragon_ui_lane = false;
|
||||
s->dragon_ui_lead = false;
|
||||
s->dragon_ui_path = false;
|
||||
s->dragon_ui_blinker = false;
|
||||
} else {
|
||||
read_param_bool_timeout(&s->dragon_ui_speed, "DragonUISpeed", &s->dragon_ui_speed_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_event, "DragonUIEvent", &s->dragon_ui_event_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_maxspeed, "DragonUIMaxSpeed", &s->dragon_ui_maxspeed_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_face, "DragonUIFace", &s->dragon_ui_face_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_dev, "DragonUIDev", &s->dragon_ui_dev_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_dev_mini, "DragonUIDevMini", &s->dragon_ui_dev_mini_timeout);
|
||||
read_param_bool_timeout(&s->dragon_enable_dashcam, "DragonEnableDashcam", &s->dragon_enable_dashcam_timeout);
|
||||
read_param_bool_timeout(&s->dragon_driving_ui, "DragonDrivingUI", &s->dragon_driving_ui_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_lane, "DragonUILane", &s->dragon_ui_lane_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_lead, "DragonUILead", &s->dragon_ui_lead_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_path, "DragonUIPath", &s->dragon_ui_path_timeout);
|
||||
read_param_bool_timeout(&s->dragon_ui_blinker, "DragonUIBlinker", &s->dragon_ui_blinker_timeout);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&s->lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user