mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-19 21:12:04 +08:00
Merge branch 'devel-en' into devel-zhs
# Conflicts: # apk/ai.comma.plus.offroad.apk
This commit is contained in:
Binary file not shown.
+10
-5
@@ -94,14 +94,19 @@ keys = {
|
||||
"DragonDisableUploader": [TxType.PERSISTENT], # deprecated
|
||||
"DragonEnableUploader": [TxType.PERSISTENT],
|
||||
"DragonNoctuaMode": [TxType.PERSISTENT],
|
||||
"DragonCacheCar": [TxType.PERSISTENT], # deprecated
|
||||
"DragonCachedModel": [TxType.PERSISTENT], # deprecated
|
||||
"DragonCachedFP": [TxType.PERSISTENT], # deprecated
|
||||
"DragonCachedVIN": [TxType.PERSISTENT], # deprecated
|
||||
"DragonCacheCar": [TxType.PERSISTENT],
|
||||
"DragonCachedModel": [TxType.PERSISTENT],
|
||||
"DragonCachedFP": [TxType.PERSISTENT],
|
||||
"DragonCachedVIN": [TxType.PERSISTENT],
|
||||
"DragonAllowGas": [TxType.PERSISTENT],
|
||||
"DragonBBUI": [TxType.PERSISTENT],
|
||||
"DragonBBUI": [TxType.PERSISTENT], # deprecated
|
||||
"DragonToyotaStockDSU": [TxType.PERSISTENT],
|
||||
"DragonLatCtrl": [TxType.PERSISTENT],
|
||||
"DragonUIEvent": [TxType.PERSISTENT],
|
||||
"DragonUIMaxSpeed": [TxType.PERSISTENT],
|
||||
"DragonUIFace": [TxType.PERSISTENT],
|
||||
"DragonUIDev": [TxType.PERSISTENT],
|
||||
"DragonUIDevMini": [TxType.PERSISTENT],
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from common.basedir import BASEDIR
|
||||
from common.fingerprints import eliminate_incompatible_cars, all_known_cars
|
||||
from selfdrive.swaglog import cloudlog
|
||||
import selfdrive.messaging as messaging
|
||||
import pickle
|
||||
|
||||
|
||||
def get_startup_alert(car_recognized, controller_available):
|
||||
@@ -65,58 +66,67 @@ def fingerprint(logcan, sendcan, is_panda_black):
|
||||
params = Params()
|
||||
car_params = params.get("CarParams")
|
||||
|
||||
if car_params is not None:
|
||||
# use already stored VIN: a new VIN query cannot be done, since panda isn't in ELM327 mode
|
||||
car_params = car.CarParams.from_bytes(car_params)
|
||||
vin = VIN_UNKNOWN if car_params.carVin == "" else car_params.carVin
|
||||
elif is_panda_black:
|
||||
# Vin query only reliably works thorugh OBDII
|
||||
vin = get_vin(logcan, sendcan, 1)
|
||||
if params.get("DragonCacheCar") == "1" and params.get("DragonCachedFP") != "" and params.get("DragonCachedModel") != "":
|
||||
car_fingerprint = pickle.loads(params.get("DragonCachedModel"))
|
||||
finger = pickle.loads(params.get("DragonCachedFP"))
|
||||
vin = pickle.loads(params.get("DragonCachedVIN"))
|
||||
else:
|
||||
vin = VIN_UNKNOWN
|
||||
if car_params is not None:
|
||||
# use already stored VIN: a new VIN query cannot be done, since panda isn't in ELM327 mode
|
||||
car_params = car.CarParams.from_bytes(car_params)
|
||||
vin = VIN_UNKNOWN if car_params.carVin == "" else car_params.carVin
|
||||
elif is_panda_black:
|
||||
# Vin query only reliably works thorugh OBDII
|
||||
vin = get_vin(logcan, sendcan, 1)
|
||||
else:
|
||||
vin = VIN_UNKNOWN
|
||||
|
||||
cloudlog.warning("VIN %s", vin)
|
||||
Params().put("CarVin", vin)
|
||||
cloudlog.warning("VIN %s", vin)
|
||||
Params().put("CarVin", vin)
|
||||
|
||||
finger = {i: {} for i in range(0, 4)} # collect on all buses
|
||||
candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1
|
||||
frame = 0
|
||||
frame_fingerprint = 10 # 0.1s
|
||||
car_fingerprint = None
|
||||
done = False
|
||||
finger = {i: {} for i in range(0, 4)} # collect on all buses
|
||||
candidate_cars = {i: all_known_cars() for i in [0, 1]} # attempt fingerprint on both bus 0 and 1
|
||||
frame = 0
|
||||
frame_fingerprint = 10 # 0.1s
|
||||
car_fingerprint = None
|
||||
done = False
|
||||
|
||||
while not done:
|
||||
a = messaging.recv_one(logcan)
|
||||
while not done:
|
||||
a = messaging.recv_one(logcan)
|
||||
|
||||
for can in a.can:
|
||||
# need to independently try to fingerprint both bus 0 and 1 to work
|
||||
# for the combo black_panda and honda_bosch. Ignore extended messages
|
||||
# and VIN query response.
|
||||
# Include bus 2 for toyotas to disambiguate cars using camera messages
|
||||
# (ideally should be done for all cars but we can't for Honda Bosch)
|
||||
for can in a.can:
|
||||
# need to independently try to fingerprint both bus 0 and 1 to work
|
||||
# for the combo black_panda and honda_bosch. Ignore extended messages
|
||||
# and VIN query response.
|
||||
# Include bus 2 for toyotas to disambiguate cars using camera messages
|
||||
# (ideally should be done for all cars but we can't for Honda Bosch)
|
||||
for b in candidate_cars:
|
||||
if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \
|
||||
can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]:
|
||||
finger[can.src][can.address] = len(can.dat)
|
||||
candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b])
|
||||
|
||||
# if we only have one car choice and the time since we got our first
|
||||
# message has elapsed, exit
|
||||
for b in candidate_cars:
|
||||
if (can.src == b or (only_toyota_left(candidate_cars[b]) and can.src == 2)) and \
|
||||
can.address < 0x800 and can.address not in [0x7df, 0x7e0, 0x7e8]:
|
||||
finger[can.src][can.address] = len(can.dat)
|
||||
candidate_cars[b] = eliminate_incompatible_cars(can, candidate_cars[b])
|
||||
# Toyota needs higher time to fingerprint, since DSU does not broadcast immediately
|
||||
if only_toyota_left(candidate_cars[b]):
|
||||
frame_fingerprint = 100 # 1s
|
||||
if len(candidate_cars[b]) == 1:
|
||||
if frame > frame_fingerprint:
|
||||
# fingerprint done
|
||||
car_fingerprint = candidate_cars[b][0]
|
||||
|
||||
# if we only have one car choice and the time since we got our first
|
||||
# message has elapsed, exit
|
||||
for b in candidate_cars:
|
||||
# Toyota needs higher time to fingerprint, since DSU does not broadcast immediately
|
||||
if only_toyota_left(candidate_cars[b]):
|
||||
frame_fingerprint = 100 # 1s
|
||||
if len(candidate_cars[b]) == 1:
|
||||
if frame > frame_fingerprint:
|
||||
# fingerprint done
|
||||
car_fingerprint = candidate_cars[b][0]
|
||||
# bail if no cars left or we've been waiting for more than 2s
|
||||
failed = all(len(cc) == 0 for cc in candidate_cars.itervalues()) or frame > 200
|
||||
succeeded = car_fingerprint is not None
|
||||
done = failed or succeeded
|
||||
|
||||
# bail if no cars left or we've been waiting for more than 2s
|
||||
failed = all(len(cc) == 0 for cc in candidate_cars.itervalues()) or frame > 200
|
||||
succeeded = car_fingerprint is not None
|
||||
done = failed or succeeded
|
||||
frame += 1
|
||||
|
||||
frame += 1
|
||||
params.put("DragonCachedModel", pickle.dumps(car_fingerprint))
|
||||
params.put("DragonCachedFP", pickle.dumps(finger))
|
||||
params.put("DragonCachedVIN", pickle.dumps(vin))
|
||||
|
||||
cloudlog.warning("fingerprinted %s", car_fingerprint)
|
||||
return car_fingerprint, finger, vin
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
#!/usr/bin/env python2.7
|
||||
import os
|
||||
from common.params import Params
|
||||
# import json
|
||||
|
||||
# file = '/data/dragonpilot.json'
|
||||
|
||||
|
||||
default_conf = {
|
||||
'DragonEnableDashcam': '1',
|
||||
@@ -18,14 +13,19 @@ default_conf = {
|
||||
'DragonDisableUploader': '0', # deprecated
|
||||
'DragonEnableUploader': '1',
|
||||
'DragonNoctuaMode': '0',
|
||||
'DragonCacheCar': '1', # deprecated
|
||||
'DragonCachedModel': '', # for cache car # deprecated
|
||||
'DragonCachedFP': '', # for cache car # deprecated
|
||||
'DragonCachedVIN': '', # for cache car # deprecated
|
||||
'DragonCacheCar': '0',
|
||||
'DragonCachedModel': '', # for cache car
|
||||
'DragonCachedFP': '', # for cache car
|
||||
'DragonCachedVIN': '', # for cache car
|
||||
'DragonAllowGas': '0',
|
||||
'DragonBBUI': '0',
|
||||
'DragonBBUI': '0', # deprecated
|
||||
'DragonToyotaStockDSU': '0',
|
||||
'DragonLatCtrl': '1',
|
||||
'DragonUIEvent': '0',
|
||||
'DragonUIMaxSpeed': '0',
|
||||
'DragonUIFace': '0',
|
||||
'DragonUIDev': '0',
|
||||
'DragonUIDevMini': '1',
|
||||
}
|
||||
|
||||
deprecated_conf = {
|
||||
@@ -33,10 +33,7 @@ deprecated_conf = {
|
||||
'DragonTempDisableSteerOnSignal': 'DragonEnableSteeringOnSignal',
|
||||
'DragonDisableLogger': 'DragonEnableLogger',
|
||||
'DragonDisableUploader': 'DragonEnableUploader',
|
||||
'DragonCacheCar': None,
|
||||
'DragonCachedModel': None,
|
||||
'DragonCachedFP': None,
|
||||
'DragonCachedVIN': None,
|
||||
'DragonBBUI': 'DragonUIDev',
|
||||
}
|
||||
|
||||
deprecated_conf_invert = {
|
||||
@@ -44,6 +41,7 @@ deprecated_conf_invert = {
|
||||
'DragonTempDisableSteerOnSignal': False,
|
||||
'DragonDisableLogger': True,
|
||||
'DragonDisableUploader': True,
|
||||
'DragonBBUI': False
|
||||
}
|
||||
|
||||
def dragonpilot_set_params(params):
|
||||
|
||||
+95
-40
@@ -266,13 +266,11 @@ typedef struct UIState {
|
||||
int is_metric_timeout;
|
||||
int longitudinal_control_timeout;
|
||||
int limit_set_speed_timeout;
|
||||
int dragon_bbui_timeout;
|
||||
|
||||
int status;
|
||||
bool is_metric;
|
||||
bool longitudinal_control;
|
||||
bool limit_set_speed;
|
||||
bool dragon_bbui;
|
||||
float speed_lim_off;
|
||||
bool is_ego_over_limit;
|
||||
char alert_type[64];
|
||||
@@ -295,6 +293,22 @@ typedef struct UIState {
|
||||
model_path_vertices_data model_path_vertices[MODEL_LANE_PATH_CNT * 2];
|
||||
|
||||
track_vertices_data track_vertices[2];
|
||||
|
||||
// dragonpilot
|
||||
int dragon_ui_event_timeout;
|
||||
int dragon_ui_maxspeed_timeout;
|
||||
int dragon_ui_face_timeout;
|
||||
int dragon_ui_dev_timeout;
|
||||
int dragon_ui_dev_mini_timeout;
|
||||
int dragon_enable_dashcam_timeout;
|
||||
|
||||
bool dragon_ui_event;
|
||||
bool dragon_ui_maxspeed;
|
||||
bool dragon_ui_face;
|
||||
bool dragon_ui_dev;
|
||||
bool dragon_ui_dev_mini;
|
||||
bool dragon_enable_dashcam;
|
||||
|
||||
} UIState;
|
||||
|
||||
static int last_brightness = -1;
|
||||
@@ -664,14 +678,27 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
||||
read_param_bool(&s->is_metric, "IsMetric");
|
||||
read_param_bool(&s->longitudinal_control, "LongitudinalControl");
|
||||
read_param_bool(&s->limit_set_speed, "LimitSetSpeed");
|
||||
read_param_bool(&s->dragon_bbui, "DragonBBUI");
|
||||
// dragonpilot
|
||||
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");
|
||||
|
||||
|
||||
// Set offsets so params don't get read at the same time
|
||||
s->longitudinal_control_timeout = UI_FREQ / 3;
|
||||
s->is_metric_timeout = UI_FREQ / 2;
|
||||
s->limit_set_speed_timeout = UI_FREQ;
|
||||
s->dragon_bbui_timeout = UI_FREQ / 4;
|
||||
|
||||
// dragonpilot, 1 sec
|
||||
s->dragon_ui_event_timeout = 100;
|
||||
s->dragon_ui_maxspeed_timeout = 100;
|
||||
s->dragon_ui_face_timeout = 100;
|
||||
s->dragon_ui_dev_timeout = 100;
|
||||
s->dragon_ui_dev_mini_timeout = 100;
|
||||
s->dragon_enable_dashcam_timeout = 100;
|
||||
}
|
||||
|
||||
static void ui_draw_transformed_box(UIState *s, uint32_t color) {
|
||||
@@ -1412,13 +1439,17 @@ 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);
|
||||
if (s->dragon_ui_maxspeed) {
|
||||
ui_draw_vision_maxspeed(s);
|
||||
}
|
||||
|
||||
#ifdef SHOW_SPEEDLIMIT
|
||||
ui_draw_vision_speedlimit(s);
|
||||
#endif
|
||||
ui_draw_vision_speed(s);
|
||||
//ui_draw_vision_event(s);
|
||||
if (s->dragon_ui_event) {
|
||||
ui_draw_vision_event(s);
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_draw_infobar(UIState *s) {
|
||||
@@ -1439,40 +1470,54 @@ static void ui_draw_infobar(UIState *s) {
|
||||
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));
|
||||
if (s->dragon_ui_dev_mini) {
|
||||
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));
|
||||
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
|
||||
);
|
||||
} else {
|
||||
snprintf(des_steer, sizeof(des_steer), "%7s", "N/A");
|
||||
snprintf(
|
||||
infobar,
|
||||
sizeof(infobar),
|
||||
"%04d/%02d/%02d %02d:%02d:%02d",
|
||||
tm.tm_year + 1900,
|
||||
tm.tm_mon + 1,
|
||||
tm.tm_mday,
|
||||
tm.tm_hour,
|
||||
tm.tm_min,
|
||||
tm.tm_sec
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
@@ -1695,15 +1740,19 @@ 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);
|
||||
if (s->dragon_ui_face) {
|
||||
ui_draw_vision_face(s);
|
||||
}
|
||||
|
||||
#ifdef SHOW_SPEEDLIMIT
|
||||
ui_draw_vision_map(s);
|
||||
#endif
|
||||
if (s->dragon_bbui) {
|
||||
if (s->dragon_ui_dev) {
|
||||
ui_draw_bbui(s);
|
||||
}
|
||||
ui_draw_infobar(s);
|
||||
if (s->dragon_ui_dev_mini || s->dragon_enable_dashcam) {
|
||||
ui_draw_infobar(s);
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
|
||||
@@ -2603,7 +2652,13 @@ int main(int argc, char* argv[]) {
|
||||
read_param_bool_timeout(&s->longitudinal_control, "LongitudinalControl", &s->longitudinal_control_timeout);
|
||||
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);
|
||||
read_param_bool_timeout(&s->dragon_bbui, "DragonBBUI", &s->dragon_bbui_timeout);
|
||||
// dragonpilot
|
||||
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);
|
||||
|
||||
pthread_mutex_unlock(&s->lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user