ui.cc: remove variables from UIScene, use event::Reader to get data (#1585)
* use struct to store lead status * remove white space * use RadarState::LeadData::Reader * use reader to get thermal data * use reader * continue * remove variables reset submodules,fix some errors reset submodules revert * remove s->scene.gps_planner_active * modify * cleanup * done * resolve conflict * remove irrelevant comment * remove white spacealbatross
parent
19512315ff
commit
d720f28ecb
|
@ -110,11 +110,13 @@ static void ui_draw_circle_image(NVGcontext *vg, float x, float y, int size, int
|
|||
ui_draw_circle_image(vg, x, y, size, image, nvgRGBA(0, 0, 0, (255 * bg_alpha)), img_alpha);
|
||||
}
|
||||
|
||||
static void draw_lead(UIState *s, float d_rel, float v_rel, float y_rel){
|
||||
static void draw_lead(UIState *s, const cereal::RadarState::LeadData::Reader &lead){
|
||||
// Draw lead car indicator
|
||||
float fillAlpha = 0;
|
||||
float speedBuff = 10.;
|
||||
float leadBuff = 40.;
|
||||
float d_rel = lead.getDRel();
|
||||
float v_rel = lead.getVRel();
|
||||
if (d_rel < leadBuff) {
|
||||
fillAlpha = 255*(1.0-(d_rel/leadBuff));
|
||||
if (v_rel < 0) {
|
||||
|
@ -122,7 +124,7 @@ static void draw_lead(UIState *s, float d_rel, float v_rel, float y_rel){
|
|||
}
|
||||
fillAlpha = (int)(fmin(fillAlpha, 255));
|
||||
}
|
||||
draw_chevron(s, d_rel, y_rel, 25, nvgRGBA(201, 34, 49, fillAlpha), COLOR_YELLOW);
|
||||
draw_chevron(s, d_rel, lead.getYRel(), 25, nvgRGBA(201, 34, 49, fillAlpha), COLOR_YELLOW);
|
||||
}
|
||||
|
||||
static void ui_draw_lane_line(UIState *s, const model_path_vertices_data *pvd, NVGcolor color) {
|
||||
|
@ -154,7 +156,7 @@ static void update_track_data(UIState *s, bool is_mpc, track_vertices_data *pvd)
|
|||
|
||||
bool started = false;
|
||||
float off = is_mpc?0.3:0.5;
|
||||
float lead_d = scene->lead_d_rel*2.;
|
||||
float lead_d = scene->lead_data[0].getDRel()*2.;
|
||||
float path_height = is_mpc?(lead_d>5.)?fmin(lead_d, 25.)-fmin(lead_d*0.35, 10.):20.
|
||||
:(lead_d>0.)?fmin(lead_d, 50.)-fmin(lead_d*0.35, 10.):49.;
|
||||
pvd->cnt = 0;
|
||||
|
@ -205,7 +207,7 @@ static void update_all_track_data(UIState *s) {
|
|||
// Draw vision path
|
||||
update_track_data(s, false, &s->track_vertices[0]);
|
||||
|
||||
if (scene->engaged) {
|
||||
if (scene->controls_state.getEnabled()) {
|
||||
// Draw MPC path when engaged
|
||||
update_track_data(s, true, &s->track_vertices[1]);
|
||||
}
|
||||
|
@ -340,10 +342,9 @@ static void ui_draw_lane(UIState *s, const PathData *path, model_path_vertices_d
|
|||
static void ui_draw_vision_lanes(UIState *s) {
|
||||
const UIScene *scene = &s->scene;
|
||||
model_path_vertices_data *pvd = &s->model_path_vertices[0];
|
||||
if(s->model_changed) {
|
||||
if(s->sm->updated("model")) {
|
||||
update_all_lane_lines_data(s, scene->model.left_lane, pvd);
|
||||
update_all_lane_lines_data(s, scene->model.right_lane, pvd + MODEL_LANE_PATH_CNT);
|
||||
s->model_changed = false;
|
||||
}
|
||||
// Draw left lane edge
|
||||
ui_draw_lane(
|
||||
|
@ -357,13 +358,12 @@ static void ui_draw_vision_lanes(UIState *s) {
|
|||
pvd + MODEL_LANE_PATH_CNT,
|
||||
nvgRGBAf(1.0, 1.0, 1.0, scene->model.right_lane.prob));
|
||||
|
||||
if(s->livempc_or_radarstate_changed) {
|
||||
if(s->sm->updated("radarState")) {
|
||||
update_all_track_data(s);
|
||||
s->livempc_or_radarstate_changed = false;
|
||||
}
|
||||
// Draw vision path
|
||||
ui_draw_track(s, false, &s->track_vertices[0]);
|
||||
if (scene->engaged) {
|
||||
if (scene->controls_state.getEnabled()) {
|
||||
// Draw MPC path when engaged
|
||||
ui_draw_track(s, true, &s->track_vertices[1]);
|
||||
}
|
||||
|
@ -394,11 +394,11 @@ static void ui_draw_world(UIState *s) {
|
|||
// Draw lane edges and vision/mpc tracks
|
||||
ui_draw_vision_lanes(s);
|
||||
|
||||
if (scene->lead_status) {
|
||||
draw_lead(s, scene->lead_d_rel, scene->lead_v_rel, scene->lead_y_rel);
|
||||
if (scene->lead_data[0].getStatus()) {
|
||||
draw_lead(s, scene->lead_data[0]);
|
||||
}
|
||||
if ((scene->lead_status2) && (std::abs(scene->lead_d_rel - scene->lead_d_rel2) > 3.0)) {
|
||||
draw_lead(s, scene->lead_d_rel2, scene->lead_v_rel2, scene->lead_y_rel2);
|
||||
if (scene->lead_data[1].getStatus() && (std::abs(scene->lead_data[0].getDRel() - scene->lead_data[1].getDRel()) > 3.0)) {
|
||||
draw_lead(s, scene->lead_data[1]);
|
||||
}
|
||||
nvgRestore(s->vg);
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ static void ui_draw_vision_maxspeed(UIState *s) {
|
|||
return;
|
||||
}*/
|
||||
char maxspeed_str[32];
|
||||
float maxspeed = s->scene.v_cruise;
|
||||
float maxspeed = s->scene.controls_state.getVCruise();
|
||||
int maxspeed_calc = maxspeed * 0.6225 + 0.5;
|
||||
float speedlimit = s->scene.speedlimit;
|
||||
int speedlim_calc = speedlimit * 2.2369363 + 0.5;
|
||||
|
@ -421,7 +421,7 @@ static void ui_draw_vision_maxspeed(UIState *s) {
|
|||
|
||||
bool is_cruise_set = (maxspeed != 0 && maxspeed != SET_SPEED_NA);
|
||||
bool is_speedlim_valid = s->scene.speedlimit_valid;
|
||||
bool is_set_over_limit = is_speedlim_valid && s->scene.engaged &&
|
||||
bool is_set_over_limit = is_speedlim_valid && s->scene.controls_state.getEnabled() &&
|
||||
is_cruise_set && maxspeed_calc > (speedlim_calc + speed_lim_off);
|
||||
|
||||
int viz_maxspeed_w = 184;
|
||||
|
@ -476,7 +476,7 @@ static void ui_draw_vision_speedlimit(UIState *s) {
|
|||
if (s->is_ego_over_limit) {
|
||||
hysteresis_offset = 0.0;
|
||||
}
|
||||
s->is_ego_over_limit = is_speedlim_valid && s->scene.v_ego > (speedlimit + s->speed_lim_off + hysteresis_offset);
|
||||
s->is_ego_over_limit = is_speedlim_valid && s->scene.controls_state.getVEgo() > (speedlimit + s->speed_lim_off + hysteresis_offset);
|
||||
|
||||
int viz_speedlim_w = 180;
|
||||
int viz_speedlim_h = 202;
|
||||
|
@ -522,9 +522,10 @@ static void ui_draw_vision_speedlimit(UIState *s) {
|
|||
|
||||
static void ui_draw_vision_speed(UIState *s) {
|
||||
const UIScene *scene = &s->scene;
|
||||
float speed = s->scene.v_ego * 2.2369363 + 0.5;
|
||||
float v_ego = s->scene.controls_state.getVEgo();
|
||||
float speed = v_ego * 2.2369363 + 0.5;
|
||||
if (s->is_metric){
|
||||
speed = s->scene.v_ego * 3.6 + 0.5;
|
||||
speed = v_ego * 3.6 + 0.5;
|
||||
}
|
||||
const int viz_speed_w = 280;
|
||||
const int viz_speed_x = scene->ui_viz_rx+((scene->ui_viz_rw/2)-(viz_speed_w/2));
|
||||
|
@ -543,7 +544,7 @@ static void ui_draw_vision_event(UIState *s) {
|
|||
const int viz_event_w = 220;
|
||||
const int viz_event_x = ((s->scene.ui_viz_rx + s->scene.ui_viz_rw) - (viz_event_w + (bdr_s*2)));
|
||||
const int viz_event_y = (box_y + (bdr_s*1.5));
|
||||
if (s->scene.decel_for_model && s->scene.engaged) {
|
||||
if (s->scene.controls_state.getDecelForModel() && s->scene.controls_state.getEnabled()) {
|
||||
// draw winding road sign
|
||||
const int img_turn_size = 160*1.5;
|
||||
ui_draw_image(s->vg, viz_event_x - (img_turn_size / 4), viz_event_y + bdr_s - 25, img_turn_size, img_turn_size, s->img_turn, 1.0f);
|
||||
|
@ -561,7 +562,7 @@ static void ui_draw_vision_event(UIState *s) {
|
|||
color = nvgRGBA(23, 51, 73, 255);
|
||||
}
|
||||
|
||||
if (s->scene.engageable){
|
||||
if (s->scene.controls_state.getEngageable()){
|
||||
ui_draw_circle_image(s->vg, bg_wheel_x, bg_wheel_y, bg_wheel_size, s->img_wheel, color, 1.0f, bg_wheel_y - 25);
|
||||
}
|
||||
}
|
||||
|
@ -578,7 +579,7 @@ static void ui_draw_vision_face(UIState *s) {
|
|||
const int face_size = 96;
|
||||
const int face_x = (s->scene.ui_viz_rx + face_size + (bdr_s * 2));
|
||||
const int face_y = (footer_y + ((footer_h - face_size) / 2));
|
||||
ui_draw_circle_image(s->vg, face_x, face_y, face_size, s->img_face, s->scene.monitoring_active);
|
||||
ui_draw_circle_image(s->vg, face_x, face_y, face_size, s->img_face, s->scene.controls_state.getDriverMonitoringOn());
|
||||
}
|
||||
|
||||
static void ui_draw_driver_view(UIState *s) {
|
||||
|
@ -610,30 +611,31 @@ static void ui_draw_driver_view(UIState *s) {
|
|||
ui_draw_rect(s->vg, valid_frame_x + valid_frame_w, box_y, frame_w - valid_frame_w - (valid_frame_x - frame_x), box_h, nvgRGBA(23, 51, 73, 255));
|
||||
|
||||
// draw face box
|
||||
if (scene->face_prob > 0.4) {
|
||||
if (scene->driver_state.getFaceProb() > 0.4) {
|
||||
auto fxy_list = scene->driver_state.getFacePosition();
|
||||
const int face_x = fxy_list[0];
|
||||
const int face_y = fxy_list[1];
|
||||
int fbox_x;
|
||||
int fbox_y = box_y + (scene->face_y + 0.5) * box_h - 0.5 * 0.6 * box_h / 2;;
|
||||
int fbox_y = box_y + (face_y + 0.5) * box_h - 0.5 * 0.6 * box_h / 2;;
|
||||
if (!scene->is_rhd) {
|
||||
fbox_x = valid_frame_x + (1 - (scene->face_x + 0.5)) * (box_h / 2) - 0.5 * 0.6 * box_h / 2;
|
||||
fbox_x = valid_frame_x + (1 - (face_x + 0.5)) * (box_h / 2) - 0.5 * 0.6 * box_h / 2;
|
||||
} else {
|
||||
fbox_x = valid_frame_x + valid_frame_w - box_h / 2 + (scene->face_x + 0.5) * (box_h / 2) - 0.5 * 0.6 * box_h / 2;
|
||||
fbox_x = valid_frame_x + valid_frame_w - box_h / 2 + (face_x + 0.5) * (box_h / 2) - 0.5 * 0.6 * box_h / 2;
|
||||
}
|
||||
if (std::abs(scene->face_x) <= 0.35 && std::abs(scene->face_y) <= 0.4) {
|
||||
if (std::abs(face_x) <= 0.35 && std::abs(face_y) <= 0.4) {
|
||||
ui_draw_rect(s->vg, fbox_x, fbox_y, 0.6 * box_h / 2, 0.6 * box_h / 2,
|
||||
nvgRGBAf(1.0, 1.0, 1.0, 0.8 - ((std::abs(scene->face_x) > std::abs(scene->face_y) ? std::abs(scene->face_x) : std::abs(scene->face_y))) * 0.6 / 0.375),
|
||||
nvgRGBAf(1.0, 1.0, 1.0, 0.8 - ((std::abs(face_x) > std::abs(face_y) ? std::abs(face_x) : std::abs(face_y))) * 0.6 / 0.375),
|
||||
35, 10);
|
||||
} else {
|
||||
ui_draw_rect(s->vg, fbox_x, fbox_y, 0.6 * box_h / 2, 0.6 * box_h / 2, nvgRGBAf(1.0, 1.0, 1.0, 0.2), 35, 10);
|
||||
}
|
||||
} else {
|
||||
;
|
||||
}
|
||||
|
||||
// draw face icon
|
||||
const int face_size = 85;
|
||||
const int face_x = (valid_frame_x + face_size + (bdr_s * 2)) + (scene->is_rhd ? valid_frame_w - box_h / 2:0);
|
||||
const int face_y = (box_y + box_h - face_size - bdr_s - (bdr_s * 1.5));
|
||||
ui_draw_circle_image(s->vg, face_x, face_y, face_size, s->img_face, scene->face_prob > 0.4);
|
||||
const int x = (valid_frame_x + face_size + (bdr_s * 2)) + (scene->is_rhd ? valid_frame_w - box_h / 2:0);
|
||||
const int y = (box_y + box_h - face_size - bdr_s - (bdr_s * 1.5));
|
||||
ui_draw_circle_image(s->vg, x, y, face_size, s->img_face, scene->driver_state.getFaceProb() > 0.4);
|
||||
}
|
||||
|
||||
static void ui_draw_vision_header(UIState *s) {
|
||||
|
|
|
@ -34,7 +34,7 @@ static void ui_draw_sidebar_network_strength(UIState *s) {
|
|||
const int network_img_w = 176;
|
||||
const int network_img_x = !s->scene.uilayout_sidebarcollapsed ? 58 : -(sbr_w);
|
||||
const int network_img_y = 196;
|
||||
const int img_idx = s->scene.networkType == cereal::ThermalData::NetworkType::NONE ? 0 : network_strength_map[s->scene.networkStrength];
|
||||
const int img_idx = s->scene.thermal.getNetworkType() == cereal::ThermalData::NetworkType::NONE ? 0 : network_strength_map[s->scene.thermal.getNetworkStrength()];
|
||||
ui_draw_image(s->vg, network_img_x, network_img_y, network_img_w, network_img_h, s->img_network[img_idx], 1.0f);
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,10 @@ static void ui_draw_sidebar_battery_icon(UIState *s) {
|
|||
const int battery_img_x = !s->scene.uilayout_sidebarcollapsed ? 160 : -(sbr_w);
|
||||
const int battery_img_y = 255;
|
||||
|
||||
int battery_img = s->scene.batteryCharging ? s->img_battery_charging : s->img_battery;
|
||||
int battery_img = s->scene.thermal.getBatteryStatus() == "Charging" ? s->img_battery_charging : s->img_battery;
|
||||
|
||||
ui_draw_rect(s->vg, battery_img_x + 6, battery_img_y + 5,
|
||||
((battery_img_w - 19) * (s->scene.batteryPercent * 0.01)), battery_img_h - 11, COLOR_WHITE);
|
||||
((battery_img_w - 19) * (s->scene.thermal.getBatteryPercent() * 0.01)), battery_img_h - 11, COLOR_WHITE);
|
||||
|
||||
ui_draw_image(s->vg, battery_img_x, battery_img_y, battery_img_w, battery_img_h, battery_img, 1.0f);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ static void ui_draw_sidebar_network_type(UIState *s) {
|
|||
const int network_y = 273;
|
||||
const int network_w = 100;
|
||||
const int network_h = 100;
|
||||
const char *network_type = network_type_map[s->scene.networkType];
|
||||
const char *network_type = network_type_map[s->scene.thermal.getNetworkType()];
|
||||
nvgFillColor(s->vg, COLOR_WHITE);
|
||||
nvgFontSize(s->vg, 48);
|
||||
nvgFontFaceId(s->vg, s->font_sans_regular);
|
||||
|
@ -127,12 +127,12 @@ static void ui_draw_sidebar_temp_metric(UIState *s) {
|
|||
char temp_value_str[32];
|
||||
char temp_value_unit[32];
|
||||
const int temp_y_offset = 0;
|
||||
snprintf(temp_value_str, sizeof(temp_value_str), "%d", s->scene.paTemp);
|
||||
snprintf(temp_value_str, sizeof(temp_value_str), "%d", s->scene.thermal.getPa0());
|
||||
snprintf(temp_value_unit, sizeof(temp_value_unit), "%s", "°C");
|
||||
snprintf(temp_label_str, sizeof(temp_label_str), "%s", "TEMP");
|
||||
strcat(temp_value_str, temp_value_unit);
|
||||
|
||||
ui_draw_sidebar_metric(s, temp_label_str, temp_value_str, temp_severity_map[s->scene.thermalStatus], temp_y_offset, NULL);
|
||||
ui_draw_sidebar_metric(s, temp_label_str, temp_value_str, temp_severity_map[s->scene.thermal.getThermalStatus()], temp_y_offset, NULL);
|
||||
}
|
||||
|
||||
static void ui_draw_sidebar_panda_metric(UIState *s) {
|
||||
|
|
|
@ -207,9 +207,6 @@ static void ui_init(UIState *s) {
|
|||
|
||||
set_awake(s, true);
|
||||
|
||||
s->model_changed = false;
|
||||
s->livempc_or_radarstate_changed = false;
|
||||
|
||||
ui_nvg_init(s);
|
||||
}
|
||||
|
||||
|
@ -228,18 +225,16 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs,
|
|||
s->cur_vision_idx = -1;
|
||||
s->cur_vision_front_idx = -1;
|
||||
|
||||
s->scene = (UIScene){
|
||||
.frontview = getenv("FRONTVIEW") != NULL,
|
||||
.fullview = getenv("FULLVIEW") != NULL,
|
||||
.transformed_width = ui_info.transformed_width,
|
||||
.transformed_height = ui_info.transformed_height,
|
||||
.front_box_x = ui_info.front_box_x,
|
||||
.front_box_y = ui_info.front_box_y,
|
||||
.front_box_width = ui_info.front_box_width,
|
||||
.front_box_height = ui_info.front_box_height,
|
||||
.world_objects_visible = false, // Invisible until we receive a calibration message.
|
||||
.gps_planner_active = false,
|
||||
};
|
||||
s->scene.frontview = getenv("FRONTVIEW") != NULL;
|
||||
s->scene.fullview = getenv("FULLVIEW") != NULL;
|
||||
s->scene.transformed_width = ui_info.transformed_width;
|
||||
s->scene.transformed_height = ui_info.transformed_height;
|
||||
s->scene.front_box_x = ui_info.front_box_x;
|
||||
s->scene.front_box_y = ui_info.front_box_y;
|
||||
s->scene.front_box_width = ui_info.front_box_width;
|
||||
s->scene.front_box_height = ui_info.front_box_height;
|
||||
s->scene.world_objects_visible = false; // Invisible until we receive a calibration message.
|
||||
s->scene.gps_planner_active = false;
|
||||
|
||||
s->rgb_width = back_bufs.width;
|
||||
s->rgb_height = back_bufs.height;
|
||||
|
@ -307,23 +302,12 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
UIScene &scene = s->scene;
|
||||
if (s->started && sm.updated("controlsState")) {
|
||||
auto event = sm["controlsState"];
|
||||
auto data = event.getControlsState();
|
||||
scene.controls_state = event.getControlsState();
|
||||
s->controls_timeout = 1 * UI_FREQ;
|
||||
scene.frontview = data.getRearViewCam();
|
||||
scene.frontview = scene.controls_state.getRearViewCam();
|
||||
if (!scene.frontview){ s->controls_seen = true; }
|
||||
|
||||
if (data.getVCruise() != scene.v_cruise) {
|
||||
scene.v_cruise_update_ts = event.getLogMonoTime();
|
||||
}
|
||||
scene.v_cruise = data.getVCruise();
|
||||
scene.v_ego = data.getVEgo();
|
||||
scene.curvature = data.getCurvature();
|
||||
scene.engaged = data.getEnabled();
|
||||
scene.engageable = data.getEngageable();
|
||||
scene.gps_planner_active = data.getGpsPlannerActive();
|
||||
scene.monitoring_active = data.getDriverMonitoringOn();
|
||||
scene.decel_for_model = data.getDecelForModel();
|
||||
auto alert_sound = data.getAlertSound();
|
||||
auto alert_sound = scene.controls_state.getAlertSound();
|
||||
const auto sound_none = cereal::CarControl::HUDControl::AudibleAlert::NONE;
|
||||
if (alert_sound != s->alert_sound){
|
||||
if (s->alert_sound != sound_none){
|
||||
|
@ -331,34 +315,33 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
}
|
||||
if (alert_sound != sound_none){
|
||||
play_alert_sound(alert_sound);
|
||||
s->alert_type = data.getAlertType();
|
||||
s->alert_type = scene.controls_state.getAlertType();
|
||||
}
|
||||
s->alert_sound = alert_sound;
|
||||
}
|
||||
scene.alert_text1 = data.getAlertText1();
|
||||
scene.alert_text2 = data.getAlertText2();
|
||||
scene.alert_ts = event.getLogMonoTime();
|
||||
scene.alert_size = data.getAlertSize();
|
||||
auto alertStatus = data.getAlertStatus();
|
||||
scene.alert_text1 = scene.controls_state.getAlertText1();
|
||||
scene.alert_text2 = scene.controls_state.getAlertText2();
|
||||
scene.alert_size = scene.controls_state.getAlertSize();
|
||||
auto alertStatus = scene.controls_state.getAlertStatus();
|
||||
if (alertStatus == cereal::ControlsState::AlertStatus::USER_PROMPT) {
|
||||
update_status(s, STATUS_WARNING);
|
||||
} else if (alertStatus == cereal::ControlsState::AlertStatus::CRITICAL) {
|
||||
update_status(s, STATUS_ALERT);
|
||||
} else{
|
||||
update_status(s, scene.engaged ? STATUS_ENGAGED : STATUS_DISENGAGED);
|
||||
update_status(s, scene.controls_state.getEnabled() ? STATUS_ENGAGED : STATUS_DISENGAGED);
|
||||
}
|
||||
|
||||
scene.alert_blinkingrate = data.getAlertBlinkingRate();
|
||||
if (scene.alert_blinkingrate > 0.) {
|
||||
float alert_blinkingrate = scene.controls_state.getAlertBlinkingRate();
|
||||
if (alert_blinkingrate > 0.) {
|
||||
if (s->alert_blinked) {
|
||||
if (s->alert_blinking_alpha > 0.0 && s->alert_blinking_alpha < 1.0) {
|
||||
s->alert_blinking_alpha += (0.05*scene.alert_blinkingrate);
|
||||
s->alert_blinking_alpha += (0.05*alert_blinkingrate);
|
||||
} else {
|
||||
s->alert_blinked = false;
|
||||
}
|
||||
} else {
|
||||
if (s->alert_blinking_alpha > 0.25) {
|
||||
s->alert_blinking_alpha -= (0.05*scene.alert_blinkingrate);
|
||||
s->alert_blinking_alpha -= (0.05*alert_blinkingrate);
|
||||
} else {
|
||||
s->alert_blinking_alpha += 0.25;
|
||||
s->alert_blinked = true;
|
||||
|
@ -368,18 +351,8 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
}
|
||||
if (sm.updated("radarState")) {
|
||||
auto data = sm["radarState"].getRadarState();
|
||||
|
||||
auto leaddatad = data.getLeadOne();
|
||||
scene.lead_status = leaddatad.getStatus();
|
||||
scene.lead_d_rel = leaddatad.getDRel();
|
||||
scene.lead_y_rel = leaddatad.getYRel();
|
||||
scene.lead_v_rel = leaddatad.getVRel();
|
||||
auto leaddatad2 = data.getLeadTwo();
|
||||
scene.lead_status2 = leaddatad2.getStatus();
|
||||
scene.lead_d_rel2 = leaddatad2.getDRel();
|
||||
scene.lead_y_rel2 = leaddatad2.getYRel();
|
||||
scene.lead_v_rel2 = leaddatad2.getVRel();
|
||||
s->livempc_or_radarstate_changed = true;
|
||||
scene.lead_data[0] = data.getLeadOne();
|
||||
scene.lead_data[1] = data.getLeadTwo();
|
||||
}
|
||||
if (sm.updated("liveCalibration")) {
|
||||
scene.world_objects_visible = true;
|
||||
|
@ -390,7 +363,6 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
}
|
||||
if (sm.updated("model")) {
|
||||
read_model(scene.model, sm["model"].getModel());
|
||||
s->model_changed = true;
|
||||
}
|
||||
// else if (which == cereal::Event::LIVE_MPC) {
|
||||
// auto data = event.getLiveMpc();
|
||||
|
@ -406,9 +378,6 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
auto data = sm["uiLayoutState"].getUiLayoutState();
|
||||
s->active_app = data.getActiveApp();
|
||||
scene.uilayout_sidebarcollapsed = data.getSidebarCollapsed();
|
||||
if (data.getMockEngaged() != scene.uilayout_mockengaged) {
|
||||
scene.uilayout_mockengaged = data.getMockEngaged();
|
||||
}
|
||||
}
|
||||
#ifdef SHOW_SPEEDLIMIT
|
||||
if (sm.updated("liveMapData")) {
|
||||
|
@ -416,16 +385,7 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
}
|
||||
#endif
|
||||
if (sm.updated("thermal")) {
|
||||
auto data = sm["thermal"].getThermal();
|
||||
scene.networkType = data.getNetworkType();
|
||||
scene.networkStrength = data.getNetworkStrength();
|
||||
scene.batteryPercent = data.getBatteryPercent();
|
||||
scene.batteryCharging = data.getBatteryStatus() == "Charging";
|
||||
scene.freeSpace = data.getFreeSpace();
|
||||
scene.thermalStatus = data.getThermalStatus();
|
||||
scene.paTemp = data.getPa0();
|
||||
|
||||
s->thermal_started = data.getStarted();
|
||||
scene.thermal = sm["thermal"].getThermal();
|
||||
}
|
||||
if (sm.updated("ubloxGnss")) {
|
||||
auto data = sm["ubloxGnss"].getUbloxGnss();
|
||||
|
@ -438,20 +398,15 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
s->hardware_timeout = 5*30; // 5 seconds at 30 fps
|
||||
}
|
||||
if (sm.updated("driverState")) {
|
||||
auto data = sm["driverState"].getDriverState();
|
||||
scene.face_prob = data.getFaceProb();
|
||||
auto fxy_list = data.getFacePosition();
|
||||
scene.face_x = fxy_list[0];
|
||||
scene.face_y = fxy_list[1];
|
||||
scene.driver_state = sm["driverState"].getDriverState();
|
||||
}
|
||||
if (sm.updated("dMonitoringState")) {
|
||||
auto data = sm["dMonitoringState"].getDMonitoringState();
|
||||
scene.is_rhd = data.getIsRHD();
|
||||
scene.awareness_status = data.getAwarenessStatus();
|
||||
s->preview_started = data.getIsPreview();
|
||||
}
|
||||
|
||||
s->started = s->thermal_started || s->preview_started ;
|
||||
s->started = scene.thermal.getStarted() || s->preview_started ;
|
||||
// Handle onroad/offroad transition
|
||||
if (!s->started) {
|
||||
if (s->status != STATUS_STOPPED) {
|
||||
|
@ -471,9 +426,7 @@ void handle_message(UIState *s, SubMaster &sm) {
|
|||
}
|
||||
|
||||
static void check_messages(UIState *s) {
|
||||
while (true) {
|
||||
if (s->sm->update(0) == 0)
|
||||
break;
|
||||
if (s->sm->update(0) > 0){
|
||||
handle_message(s, *(s->sm));
|
||||
}
|
||||
}
|
||||
|
@ -911,7 +864,7 @@ int main(int argc, char* argv[]) {
|
|||
if (s->volume_timeout > 0) {
|
||||
s->volume_timeout--;
|
||||
} else {
|
||||
int volume = fmin(MAX_VOLUME, MIN_VOLUME + s->scene.v_ego / 5); // up one notch every 5 m/s
|
||||
int volume = fmin(MAX_VOLUME, MIN_VOLUME + s->scene.controls_state.getVEgo() / 5); // up one notch every 5 m/s
|
||||
set_volume(volume);
|
||||
s->volume_timeout = 5 * UI_FREQ;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ const uint8_t bg_colors[][4] = {
|
|||
[STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xff},
|
||||
};
|
||||
|
||||
|
||||
typedef struct UIScene {
|
||||
int frontview;
|
||||
int fullview;
|
||||
|
@ -105,61 +104,35 @@ typedef struct UIScene {
|
|||
bool world_objects_visible;
|
||||
mat4 extrinsic_matrix; // Last row is 0 so we can use mat4.
|
||||
|
||||
float v_cruise;
|
||||
uint64_t v_cruise_update_ts;
|
||||
float v_ego;
|
||||
bool decel_for_model;
|
||||
|
||||
float speedlimit;
|
||||
bool speedlimit_valid;
|
||||
|
||||
bool is_rhd;
|
||||
bool map_valid;
|
||||
|
||||
float curvature;
|
||||
int engaged;
|
||||
bool engageable;
|
||||
bool monitoring_active;
|
||||
|
||||
bool uilayout_sidebarcollapsed;
|
||||
bool uilayout_mapenabled;
|
||||
bool uilayout_mockengaged;
|
||||
// responsive layout
|
||||
int ui_viz_rx;
|
||||
int ui_viz_rw;
|
||||
int ui_viz_ro;
|
||||
|
||||
int lead_status;
|
||||
float lead_d_rel, lead_y_rel, lead_v_rel;
|
||||
|
||||
int lead_status2;
|
||||
float lead_d_rel2, lead_y_rel2, lead_v_rel2;
|
||||
|
||||
float face_prob;
|
||||
bool is_rhd;
|
||||
float face_x, face_y;
|
||||
|
||||
int front_box_x, front_box_y, front_box_width, front_box_height;
|
||||
|
||||
uint64_t alert_ts;
|
||||
std::string alert_text1;
|
||||
std::string alert_text2;
|
||||
cereal::ControlsState::AlertSize alert_size;
|
||||
float alert_blinkingrate;
|
||||
|
||||
float awareness_status;
|
||||
|
||||
// Used to show gps planner status
|
||||
bool gps_planner_active;
|
||||
|
||||
cereal::ThermalData::NetworkType networkType;
|
||||
cereal::ThermalData::NetworkStrength networkStrength;
|
||||
int batteryPercent;
|
||||
bool batteryCharging;
|
||||
float freeSpace;
|
||||
cereal::ThermalData::ThermalStatus thermalStatus;
|
||||
int paTemp;
|
||||
cereal::HealthData::HwType hwType;
|
||||
int satelliteCount;
|
||||
uint8_t athenaStatus;
|
||||
|
||||
cereal::ThermalData::Reader thermal;
|
||||
cereal::RadarState::LeadData::Reader lead_data[2];
|
||||
cereal::ControlsState::Reader controls_state;
|
||||
cereal::DriverState::Reader driver_state;
|
||||
} UIScene;
|
||||
|
||||
typedef struct {
|
||||
|
@ -266,17 +239,13 @@ typedef struct UIState {
|
|||
float alert_blinking_alpha;
|
||||
bool alert_blinked;
|
||||
bool started;
|
||||
bool thermal_started, preview_started;
|
||||
bool preview_started;
|
||||
bool vision_seen;
|
||||
|
||||
std::atomic<float> light_sensor;
|
||||
|
||||
int touch_fd;
|
||||
|
||||
// Hints for re-calculations and redrawing
|
||||
bool model_changed;
|
||||
bool livempc_or_radarstate_changed;
|
||||
|
||||
GLuint frame_vao[2], frame_vbo[2], frame_ibo[2];
|
||||
mat4 rear_frame_mat, front_frame_mat;
|
||||
|
||||
|
|
Loading…
Reference in New Issue