From 8ba3985c0e60fc3cac6081c84e9f634c992c1723 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:20:00 -0500 Subject: [PATCH 01/99] Show ui by starting with ./ui debug (#129) * enable UI drawing when manually running ./ui * get args test * get args test * get args test * get args test * ohhh * test * test * test * test * test * test * see if this is cleaner * this should work! * remove --- selfdrive/ui/ui | 3 +-- selfdrive/ui/ui.cc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/ui b/selfdrive/ui/ui index d212c92da72524..b663dce0f4bddb 100755 --- a/selfdrive/ui/ui +++ b/selfdrive/ui/ui @@ -1,4 +1,3 @@ #!/bin/sh export LD_LIBRARY_PATH="/system/lib64:$LD_LIBRARY_PATH" -exec ./_ui - +exec ./_ui "$@" diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 675911e60499c1..f2bf698108df40 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -807,8 +807,23 @@ int main(int argc, char* argv[]) { int draws = 0; + bool debug_ui = false; + if (argc == 2) { + if (strcmp(argv[1], "debug") == 0) { + debug_ui = true; + } + } + while (!do_exit) { bool should_swap = false; + if (debug_ui) { + s->started = true; + s->status = STATUS_DISENGAGED; + s->controls_seen = true; + s->vision_seen = true; + s->active_app = cereal::UiLayoutState::App::NONE; + s->controls_timeout = UI_FREQ; + } if (!s->started) { // Delay a while to avoid 9% cpu usage while car is not started and user is keeping touching on the screen. // Don't hold the lock while sleeping, so that vision_connect_thread have chances to get the lock. From 40f22c15c8ad425b2539872c577b95a9f8f96127 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:22:30 -0500 Subject: [PATCH 02/99] start to add model ui toggle --- selfdrive/ui/paint.cc | 27 +++++++++++++++++++++++++++ selfdrive/ui/ui.cc | 3 ++- selfdrive/ui/ui.hpp | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 9cd5871250ee51..a92d39edea0dc5 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -658,6 +658,32 @@ static void ui_draw_df_button(UIState *s) { nvgText(s->vg, btn_x - 34, btn_y + 50 + 15, "profile", NULL); } +static void ui_draw_ml_button(UIState *s) { + int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); + + int btn_w = 150; + int btn_h = 150; + int btn_x = 1920 - btn_w - 200; // 150 + 50 padding + int btn_y = 1080 - btn_h - 50; + + ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); + + +// nvgBeginPath(s->vg); +// nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 100); +// nvgStrokeColor(s->vg, nvgRGBA(12, 79, 130, 255)); +// nvgStrokeWidth(s->vg, 11); +// nvgStroke(s->vg); +// +// nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); +// nvgFontSize(s->vg, 80); +// nvgText(s->vg, btn_x - 38, btn_y + 30, "LS", NULL); +// +// nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); +// nvgFontSize(s->vg, 45); +// nvgText(s->vg, btn_x - 34, btn_y + 50 + 15, "mode", NULL); +} + static void ui_draw_vision_header(UIState *s) { const UIScene *scene = &s->scene; int ui_viz_rx = scene->ui_viz_rx; @@ -685,6 +711,7 @@ static void ui_draw_vision_footer(UIState *s) { ui_draw_vision_face(s); ui_draw_df_button(s); ui_draw_ls_button(s); + ui_draw_ml_button(s); #ifdef SHOW_SPEEDLIMIT // ui_draw_vision_map(s); diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index f2bf698108df40..d925e4ce5a9f46 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -271,7 +271,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, s->scene.dfButtonStatus = 0; s->scene.lsButtonStatus = 0; - + s->scene.mlButtonStatus = 0; s->rgb_width = back_bufs.width; s->rgb_height = back_bufs.height; @@ -849,6 +849,7 @@ int main(int argc, char* argv[]) { int touch_x = -1, touch_y = -1; int touched = touch_poll(&touch, &touch_x, &touch_y, 0); if (touched == 1) { + printf("touched x: %d, y: %d\n", touch_x, touch_y); set_awake(s, true); handle_sidebar_touch(s, touch_x, touch_y); diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index 6a2d6bfe6501d7..4f9095a5a4c5bf 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -126,6 +126,7 @@ typedef struct UIScene { int dfButtonStatus; int lsButtonStatus; + int mlButtonStatus; cereal::HealthData::HwType hwType; int satelliteCount; From 204d707dfdfff88abdf9e270384bbc7329280899 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:23:28 -0500 Subject: [PATCH 03/99] add struct --- cereal/log.capnp | 5 +++++ cereal/service_list.yaml | 1 + selfdrive/ui/ui.cc | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cereal/log.capnp b/cereal/log.capnp index d1b16bff7905fa..215cfa8127aa19 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -2014,6 +2014,10 @@ struct DynamicCameraOffset { keepingRight @1 :Bool; } +struct ModelLongButton { + enabled @0 :Bool; +} + struct Event { # in nanoseconds? logMonoTime @0 :UInt64; @@ -2098,5 +2102,6 @@ struct Event { laneSpeed @76 :LaneSpeed; laneSpeedButton @77 :LaneSpeedButton; dynamicCameraOffset @78 :DynamicCameraOffset; + modelLongButton @79 :ModelLongButton; } } diff --git a/cereal/service_list.yaml b/cereal/service_list.yaml index 0bc29df212765e..466489740c75a6 100644 --- a/cereal/service_list.yaml +++ b/cereal/service_list.yaml @@ -83,6 +83,7 @@ dynamicFollowButton: [8076, false, 0.] laneSpeed: [8077, false, 0.] laneSpeedButton: [8078, false, 0.] dynamicCameraOffset: [8079, false, 0.] +modelLongButton: [8080, false, 0.] testModel: [8040, false, 0.] testLiveLocation: [8045, false, 0.] diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index d925e4ce5a9f46..454b2ebff26973 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -227,7 +227,7 @@ static void ui_init(UIState *s) { , "liveMapData" #endif }); - s->pm = new PubMaster({"offroadLayout", "laneSpeedButton", "dynamicFollowButton"}); + s->pm = new PubMaster({"offroadLayout", "laneSpeedButton", "dynamicFollowButton", "modelLongButton"}); s->ipc_fd = -1; s->scene.satelliteCount = -1; From f2af14712c0e828dc1d86c31327bfcd9ab64b736 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:43:41 -0500 Subject: [PATCH 04/99] try a wider button --- selfdrive/ui/paint.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index a92d39edea0dc5..7cdf914a2fac28 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -661,20 +661,22 @@ static void ui_draw_df_button(UIState *s) { static void ui_draw_ml_button(UIState *s) { int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); - int btn_w = 150; + int btn_w = 400; int btn_h = 150; - int btn_x = 1920 - btn_w - 200; // 150 + 50 padding - int btn_y = 1080 - btn_h - 50; +// int btn_x = 1051 - btn_w - 200; // 150 + 50 padding + int btn_x = 1051; // 150 + 50 padding +// int btn_y = 934 - btn_h - 50; + int btn_y = 934; - ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); +// ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); -// nvgBeginPath(s->vg); -// nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 100); -// nvgStrokeColor(s->vg, nvgRGBA(12, 79, 130, 255)); -// nvgStrokeWidth(s->vg, 11); -// nvgStroke(s->vg); -// + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 25); + nvgStrokeColor(s->vg, nvgRGBA(12, 79, 130, 255)); + nvgStrokeWidth(s->vg, 14); + nvgStroke(s->vg); + // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 80); // nvgText(s->vg, btn_x - 38, btn_y + 30, "LS", NULL); From c3cb611cab4cbf51b69e6862f0a28a63148ac9bf Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:44:48 -0500 Subject: [PATCH 05/99] comment --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 7cdf914a2fac28..156ebd7fba3d5f 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -659,7 +659,7 @@ static void ui_draw_df_button(UIState *s) { } static void ui_draw_ml_button(UIState *s) { - int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); +// int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); int btn_w = 400; int btn_h = 150; From faed8c8b5c3d1bf90f6c61c9425def639e3e7e5e Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:45:04 -0500 Subject: [PATCH 06/99] what is this, get rid of it --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 156ebd7fba3d5f..70d276d55fd568 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -672,7 +672,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 25); + nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); nvgStrokeColor(s->vg, nvgRGBA(12, 79, 130, 255)); nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); From 1e131f8ca44d09127d20ecb3643fe0edae08210d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:46:27 -0500 Subject: [PATCH 07/99] now center --- selfdrive/ui/paint.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 70d276d55fd568..142ca80d7d8bc0 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -663,10 +663,8 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; -// int btn_x = 1051 - btn_w - 200; // 150 + 50 padding - int btn_x = 1051; // 150 + 50 padding -// int btn_y = 934 - btn_h - 50; - int btn_y = 934; + int btn_x = 1051 - btn_w; // 150 + 50 padding + int btn_y = 934 - btn_h; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 9565d6818950ac59eb8d73e936c4b449647ae665 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:47:47 -0500 Subject: [PATCH 08/99] is this better? --- selfdrive/ui/paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 142ca80d7d8bc0..b04f67951d5c88 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -663,15 +663,15 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; - int btn_x = 1051 - btn_w; // 150 + 50 padding - int btn_y = 934 - btn_h; + int btn_x = 1051 - btn_w / 2; // 150 + 50 padding + int btn_y = 934 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgStrokeColor(s->vg, nvgRGBA(12, 79, 130, 255)); + nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); From 34383b0de86290b6b86c4f27099bf10aad89635c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:52:13 -0500 Subject: [PATCH 09/99] x and y padding --- selfdrive/ui/paint.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index b04f67951d5c88..616f77554ba5d9 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -619,8 +619,10 @@ static void ui_draw_driver_view(UIState *s) { static void ui_draw_ls_button(UIState *s) { int btn_w = 150; int btn_h = 150; - int btn_x = 1920 - btn_w - 200; // 150 + 50 padding - int btn_y = 1080 - btn_h - 50; + int x_padding = 200; + int y_padding = 50; + int btn_x = 1920 - btn_w - x_padding; + int btn_y = 1080 - btn_h - y_padding; nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 100); @@ -640,8 +642,9 @@ static void ui_draw_ls_button(UIState *s) { static void ui_draw_df_button(UIState *s) { int btn_w = 150; int btn_h = 150; + int y_padding = 50; int btn_x = 1920 - btn_w; - int btn_y = 1080 - btn_h - 50; + int btn_y = 1080 - btn_h - y_padding; nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x-110, btn_y-45, btn_w, btn_h, 100); @@ -663,8 +666,9 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; + int y_padding = 50; int btn_x = 1051 - btn_w / 2; // 150 + 50 padding - int btn_y = 934 - btn_h / 2; + int btn_y = 934 - btn_h / 2 - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 52ac6fb4f4dbb8a1cdbf97d47c241ccd3df9a624 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:53:43 -0500 Subject: [PATCH 10/99] change coords --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 616f77554ba5d9..c0527b5a991b94 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -667,8 +667,8 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; int y_padding = 50; - int btn_x = 1051 - btn_w / 2; // 150 + 50 padding - int btn_y = 934 - btn_h / 2 - y_padding; + int btn_x = 960 - btn_w / 2; // 150 + 50 padding + int btn_y = 1080 - btn_h / 2 - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 879a5df50cfbce39ea20d04563808b8fa55c3d24 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:54:39 -0500 Subject: [PATCH 11/99] add text --- selfdrive/ui/paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index c0527b5a991b94..d7dbc150a17790 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -679,9 +679,9 @@ static void ui_draw_ml_button(UIState *s) { nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); -// nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); -// nvgFontSize(s->vg, 80); -// nvgText(s->vg, btn_x - 38, btn_y + 30, "LS", NULL); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); + nvgFontSize(s->vg, 80); + nvgText(s->vg, btn_x - 38, btn_y + 30, "Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 6645c1a4fd971604e86459a916d0757003d5adf2 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:56:41 -0500 Subject: [PATCH 12/99] coords --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index d7dbc150a17790..477c7a116695c4 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -667,8 +667,8 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; int y_padding = 50; - int btn_x = 960 - btn_w / 2; // 150 + 50 padding - int btn_y = 1080 - btn_h / 2 - y_padding; + int btn_x = 1027 - btn_w / 2; // 150 + 50 padding + int btn_y = 910 - btn_h / 2 - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From e60c10280b2629277bb5d410e74a5c168db557d3 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 22:58:34 -0500 Subject: [PATCH 13/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 477c7a116695c4..6b0ce46d10bf8d 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -668,7 +668,7 @@ static void ui_draw_ml_button(UIState *s) { int btn_h = 150; int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding - int btn_y = 910 - btn_h / 2 - y_padding; + int btn_y = 940 - btn_h / 2 - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From d94d48153a60643f853614a65c031552b4d51ae1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:00:27 -0500 Subject: [PATCH 14/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 6b0ce46d10bf8d..2b8074935ba8bd 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -681,7 +681,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 80); - nvgText(s->vg, btn_x - 38, btn_y + 30, "Model Long", NULL); + nvgText(s->vg, btn_x, btn_y, "Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 1b3c8bc3e17d4fe08866cb34a22b595d60327d11 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:01:20 -0500 Subject: [PATCH 15/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 2b8074935ba8bd..dcb8e01d8eb427 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -668,7 +668,7 @@ static void ui_draw_ml_button(UIState *s) { int btn_h = 150; int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding - int btn_y = 940 - btn_h / 2 - y_padding; + int btn_y = 980 - btn_h / 2 - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From bad2104b6b5de504861160fa1c2ca6265e814b31 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:01:52 -0500 Subject: [PATCH 16/99] just want to see how the cordinates work --- selfdrive/ui/paint.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index dcb8e01d8eb427..a192cf3613cf35 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,6 +669,8 @@ static void ui_draw_ml_button(UIState *s) { int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding int btn_y = 980 - btn_h / 2 - y_padding; + btn_y = 0; + btn_x = 0; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From c93900d0de4a8e6b0f83caa7d271dfbaa8eb21ee Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:03:06 -0500 Subject: [PATCH 17/99] center --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index a192cf3613cf35..1be3c0478c2131 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,8 +669,8 @@ static void ui_draw_ml_button(UIState *s) { int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding int btn_y = 980 - btn_h / 2 - y_padding; - btn_y = 0; - btn_x = 0; + btn_y = 1920/2; + btn_x = 1080/2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 0b6c8f8a398f8e5502464298d799f372600b6e61 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:05:30 -0500 Subject: [PATCH 18/99] got it wrong lol --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 1be3c0478c2131..bd1f6ee107d693 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,8 +669,8 @@ static void ui_draw_ml_button(UIState *s) { int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding int btn_y = 980 - btn_h / 2 - y_padding; - btn_y = 1920/2; - btn_x = 1080/2; + btn_y = 540; + btn_x = 960; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From cec13a146f5c7bce894bcd902677cc5430e70bce Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:06:54 -0500 Subject: [PATCH 19/99] okay, this should center it --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index bd1f6ee107d693..c7bb1671421675 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,8 +669,8 @@ static void ui_draw_ml_button(UIState *s) { int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding int btn_y = 980 - btn_h / 2 - y_padding; - btn_y = 540; - btn_x = 960; + btn_y = 540 - btn_w / 2; + btn_x = 960 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From d8f9d8d43e0d85468c7024f96e33794b893694d4 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:07:34 -0500 Subject: [PATCH 20/99] same thing as before but don't change text's coords --- selfdrive/ui/paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index c7bb1671421675..d21ff0b718e393 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,14 +669,14 @@ static void ui_draw_ml_button(UIState *s) { int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding int btn_y = 980 - btn_h / 2 - y_padding; - btn_y = 540 - btn_w / 2; - btn_x = 960 - btn_h / 2; + btn_y = 540; + btn_x = 960; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); + nvgRoundedRect(s->vg, btn_x - btn_h / 2, btn_y - btn_w / 2, btn_w, btn_h, 25); nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); From 4d777ce070c1e24d671433c03481f61b5bd4947c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:08:00 -0500 Subject: [PATCH 21/99] same thing as before but don't change text's coords --- selfdrive/ui/paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index d21ff0b718e393..c7bb1671421675 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,14 +669,14 @@ static void ui_draw_ml_button(UIState *s) { int y_padding = 50; int btn_x = 1027 - btn_w / 2; // 150 + 50 padding int btn_y = 980 - btn_h / 2 - y_padding; - btn_y = 540; - btn_x = 960; + btn_y = 540 - btn_w / 2; + btn_x = 960 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, btn_x - btn_h / 2, btn_y - btn_w / 2, btn_w, btn_h, 25); + nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); From 4717eb38bcae918f89ca57cd8867aabaef15c599 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:08:17 -0500 Subject: [PATCH 22/99] hide text --- selfdrive/ui/paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index c7bb1671421675..2a260428c0e9a4 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -681,9 +681,9 @@ static void ui_draw_ml_button(UIState *s) { nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgFontSize(s->vg, 80); - nvgText(s->vg, btn_x, btn_y, "Model Long", NULL); +// nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); +// nvgFontSize(s->vg, 80); +// nvgText(s->vg, btn_x, btn_y, "Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 0de38d73f508e0444eff79a308231683db50b9a2 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:10:23 -0500 Subject: [PATCH 23/99] here we go --- selfdrive/ui/paint.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 2a260428c0e9a4..479fb74c46a2bf 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -667,10 +667,13 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; int y_padding = 50; - int btn_x = 1027 - btn_w / 2; // 150 + 50 padding - int btn_y = 980 - btn_h / 2 - y_padding; - btn_y = 540 - btn_w / 2; - btn_x = 960 - btn_h / 2; +// int btn_x = 1027 - btn_w / 2; // 150 + 50 padding +// int btn_y = 980 - btn_h / 2 - y_padding; + int btn_x = 960; + int btn_y = 540; + + int btn_x_center = 960 - btn_h / 2; + int btn_y_center = 540 - btn_w / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); @@ -681,6 +684,12 @@ static void ui_draw_ml_button(UIState *s) { nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, btn_x_center, btn_y_center, btn_w, btn_h, 25); + nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); + nvgStrokeWidth(s->vg, 14); + nvgStroke(s->vg); + // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 80); // nvgText(s->vg, btn_x, btn_y, "Model Long", NULL); From b6442c8e350c4e6556d556ebfa260864e4710827 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:11:04 -0500 Subject: [PATCH 24/99] here we go --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 479fb74c46a2bf..4d02aec0b823a2 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -666,7 +666,7 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; - int y_padding = 50; +// int y_padding = 50; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 960; From cd623531579cc73543940dd2bae24c031391a182 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:12:18 -0500 Subject: [PATCH 25/99] make center greeeeen! --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 4d02aec0b823a2..2e8eb623faf038 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -686,7 +686,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x_center, btn_y_center, btn_w, btn_h, 25); - nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); + nvgStrokeColor(s->vg, nvgRGBA(0, 255, 0, 255)); nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); From c66006cdcb56fd53a913a1ff41e9c0698107aecb Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:13:50 -0500 Subject: [PATCH 26/99] ohhh... does this fix it all? --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 2e8eb623faf038..2bbf3dd2fe31b7 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -672,8 +672,8 @@ static void ui_draw_ml_button(UIState *s) { int btn_x = 960; int btn_y = 540; - int btn_x_center = 960 - btn_h / 2; - int btn_y_center = 540 - btn_w / 2; + int btn_x_center = 960 - btn_w / 2; + int btn_y_center = 540 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 4fb05882fe85bb31e091652194312c6f54590932 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:18:41 -0500 Subject: [PATCH 27/99] coords --- selfdrive/ui/paint.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 2bbf3dd2fe31b7..ec01b14cf851c9 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,27 +669,17 @@ static void ui_draw_ml_button(UIState *s) { // int y_padding = 50; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; - int btn_x = 960; - int btn_y = 540; - - int btn_x_center = 960 - btn_w / 2; - int btn_y_center = 540 - btn_h / 2; + int btn_x = 1920 / 2 - btn_w / 2; + int btn_y = 1080 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); - nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); - nvgBeginPath(s->vg); - nvgRoundedRect(s->vg, btn_x_center, btn_y_center, btn_w, btn_h, 25); - nvgStrokeColor(s->vg, nvgRGBA(0, 255, 0, 255)); - nvgStrokeWidth(s->vg, 14); - nvgStroke(s->vg); - // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 80); // nvgText(s->vg, btn_x, btn_y, "Model Long", NULL); From ed44453b09e67126cd150f0fba5ac5f04f7a881f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:19:51 -0500 Subject: [PATCH 28/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index ec01b14cf851c9..4f7d00cedae503 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -670,7 +670,7 @@ static void ui_draw_ml_button(UIState *s) { // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 1080 - btn_h / 2; + int btn_y = 946 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 2cddbb7ce457d31f18fa039e0d02ede81abea249 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:20:36 -0500 Subject: [PATCH 29/99] padding --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 4f7d00cedae503..de6f03ba7d34cb 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -666,11 +666,11 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; -// int y_padding = 50; + int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 946 - btn_h / 2; + int btn_y = 1080 - btn_h / 2 - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 09ad042a3f9e335945bf2e2a3f6008e9fbbe3b35 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:22:46 -0500 Subject: [PATCH 30/99] padding --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index de6f03ba7d34cb..ec1736561b2ce5 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -666,11 +666,11 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; - int y_padding = 100; + int y_padding = 50; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 1080 - btn_h / 2 - y_padding; + int btn_y = 1080 - btn_h - y_padding; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From a589d016f0ec480cb5e1d3f677179041891e62ca Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:24:14 -0500 Subject: [PATCH 31/99] coords --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index ec1736561b2ce5..f9657c1c9967e7 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -666,11 +666,11 @@ static void ui_draw_ml_button(UIState *s) { int btn_w = 400; int btn_h = 150; - int y_padding = 50; +// int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 1080 - btn_h - y_padding; + int btn_y = 898 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 5c70f532537ef7e801e2b89b2d303b8bb1ff8b99 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:25:31 -0500 Subject: [PATCH 32/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index f9657c1c9967e7..ed2ff2b8d009fb 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -670,7 +670,7 @@ static void ui_draw_ml_button(UIState *s) { // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 898 - btn_h / 2; + int btn_y = 900 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 33b3bf2a04771afcf7787f579b4e27517ccf7d28 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:27:00 -0500 Subject: [PATCH 33/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index ed2ff2b8d009fb..8c7bc9258b6584 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -670,7 +670,7 @@ static void ui_draw_ml_button(UIState *s) { // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 900 - btn_h / 2; + int btn_y = 910 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From 6a1fd218d26e931d8f832df3fb8d8c3c2adb32d1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:27:54 -0500 Subject: [PATCH 34/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 8c7bc9258b6584..53bf60000ade70 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -670,7 +670,7 @@ static void ui_draw_ml_button(UIState *s) { // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 910 - btn_h / 2; + int btn_y = 905 - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); From b65fd16fee39e776a228c11b7f77f98fa0e39863 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:29:12 -0500 Subject: [PATCH 35/99] coords --- selfdrive/ui/paint.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 53bf60000ade70..82e1d1c255ed5d 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -669,8 +669,10 @@ static void ui_draw_ml_button(UIState *s) { // int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; - int btn_x = 1920 / 2 - btn_w / 2; - int btn_y = 905 - btn_h / 2; + int x = 1920 / 2; + int y = 905; + int btn_x = x - btn_w / 2; + int btn_y = y - btn_h / 2; // ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); @@ -680,9 +682,9 @@ static void ui_draw_ml_button(UIState *s) { nvgStrokeWidth(s->vg, 14); nvgStroke(s->vg); -// nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); -// nvgFontSize(s->vg, 80); -// nvgText(s->vg, btn_x, btn_y, "Model Long", NULL); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); + nvgFontSize(s->vg, 80); + nvgText(s->vg, x, y, "Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 2c40cca2615569e7a97dcb1f178832f2f13feadb Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:30:15 -0500 Subject: [PATCH 36/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 82e1d1c255ed5d..3341ccc2fa2418 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 80); - nvgText(s->vg, x, y, "Model Long", NULL); + nvgText(s->vg, x, btn_y, "Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From fc8f004b4c91826b014b6c72595b53361d20c08c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:31:23 -0500 Subject: [PATCH 37/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 3341ccc2fa2418..beef1fa4251bf9 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 80); - nvgText(s->vg, x, btn_y, "Model Long", NULL); + nvgText(s->vg, x, y + 80/2, "Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 71f451e4eeb133f96d2f445fcfd7e25aa4fec35a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:33:02 -0500 Subject: [PATCH 38/99] coords --- selfdrive/ui/paint.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index beef1fa4251bf9..db3a6a8994aa19 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -664,8 +664,8 @@ static void ui_draw_df_button(UIState *s) { static void ui_draw_ml_button(UIState *s) { // int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); - int btn_w = 400; - int btn_h = 150; + int btn_w = 450; + int btn_h = 100; // int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; @@ -683,8 +683,8 @@ static void ui_draw_ml_button(UIState *s) { nvgStroke(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); - nvgFontSize(s->vg, 80); - nvgText(s->vg, x, y + 80/2, "Model Long", NULL); + nvgFontSize(s->vg, 65); + nvgText(s->vg, x, y, "Toggle Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 10d3ff51df6572a964ecec9bef2e2696652ef956 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:34:02 -0500 Subject: [PATCH 39/99] coords --- selfdrive/ui/paint.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index db3a6a8994aa19..495a55e90abfa8 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -664,8 +664,8 @@ static void ui_draw_df_button(UIState *s) { static void ui_draw_ml_button(UIState *s) { // int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); - int btn_w = 450; - int btn_h = 100; + int btn_w = 500; + int btn_h = 125; // int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; From 185bc4019f00ec3d449686118296b22d3738514f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:36:23 -0500 Subject: [PATCH 40/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 495a55e90abfa8..873cd0bb265bc2 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -679,7 +679,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); - nvgStrokeWidth(s->vg, 14); + nvgStrokeWidth(s->vg, 12); nvgStroke(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From 7fde9d22aa1c04790e47f2d3c404ec67ae592363 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:38:27 -0500 Subject: [PATCH 41/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 873cd0bb265bc2..0f3ceae8c25e74 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); - nvgText(s->vg, x, y, "Toggle Model Long", NULL); + nvgText(s->vg, x, y + btn_h / 2, "Toggle Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From d1ed437c5f37c06771f171aec791956be6a3e054 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:39:44 -0500 Subject: [PATCH 42/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 0f3ceae8c25e74..b006c0eab072fc 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); - nvgText(s->vg, x, y + btn_h / 2, "Toggle Model Long", NULL); + nvgText(s->vg, x, y + btn_h / 4 + 65 / 2, "Toggle Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 089e7312ba89afdd0e391584c0a900d3e2f5b228 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:40:33 -0500 Subject: [PATCH 43/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index b006c0eab072fc..0714a2fae1098a 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); - nvgText(s->vg, x, y + btn_h / 4 + 65 / 2, "Toggle Model Long", NULL); + nvgText(s->vg, x, y + btn_h / 4, "Toggle Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From a4fa837805db8ca785da288c13e04fb34ffd410a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:41:26 -0500 Subject: [PATCH 44/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 0714a2fae1098a..15c8d3ff7659ea 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); - nvgText(s->vg, x, y + btn_h / 4, "Toggle Model Long", NULL); + nvgText(s->vg, x, y + btn_h / 6, "Toggle Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 74412a873f66e39fe20a8b43a1024aedc6e8b912 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:42:46 -0500 Subject: [PATCH 45/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 15c8d3ff7659ea..837707ee7cedf4 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -684,7 +684,7 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); - nvgText(s->vg, x, y + btn_h / 6, "Toggle Model Long", NULL); + nvgText(s->vg, x, y + btn_h / 8, "Toggle Model Long", NULL); // // nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); // nvgFontSize(s->vg, 45); From 4fd0b1e4c4ba506ef7f2dfa402badc9a0a4b5fa1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:43:41 -0500 Subject: [PATCH 46/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 837707ee7cedf4..df8f5e46779c3e 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -665,7 +665,7 @@ static void ui_draw_ml_button(UIState *s) { // int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); int btn_w = 500; - int btn_h = 125; + int btn_h = 150; // int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; From f5e630e9cea2eac13497733d1a1bc45f34afef56 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:44:38 -0500 Subject: [PATCH 47/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index df8f5e46779c3e..f7195fcfe0b36f 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -665,7 +665,7 @@ static void ui_draw_ml_button(UIState *s) { // int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); int btn_w = 500; - int btn_h = 150; + int btn_h = 138; // int y_padding = 100; // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; From 25408c94c383858162821b81b92c3b51beba97b7 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:45:59 -0500 Subject: [PATCH 48/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index f7195fcfe0b36f..2ceb8cc8cd48fd 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -670,7 +670,7 @@ static void ui_draw_ml_button(UIState *s) { // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int x = 1920 / 2; - int y = 905; + int y = 920; int btn_x = x - btn_w / 2; int btn_y = y - btn_h / 2; From 15edbff7559381c79d0d45ca6b2cd05f48ebf7b8 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 23 Jul 2020 23:48:18 -0500 Subject: [PATCH 49/99] coords --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 2ceb8cc8cd48fd..7e481a3ff4703e 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -670,7 +670,7 @@ static void ui_draw_ml_button(UIState *s) { // int btn_x = 1027 - btn_w / 2; // 150 + 50 padding // int btn_y = 980 - btn_h / 2 - y_padding; int x = 1920 / 2; - int y = 920; + int y = 915; int btn_x = x - btn_w / 2; int btn_y = y - btn_h / 2; From 3a63f1ce5648a16ae37db6903581ece315726943 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:28:26 -0500 Subject: [PATCH 50/99] add uiview.py for debugging the ui and update scons nodes --- CMakeLists.txt | 0 selfdrive/ui/ui.cc | 22 +++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 454b2ebff26973..3ec08e1879ca8f 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -142,6 +142,26 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { return false; } +static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { + //lsButton manager + if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { + int padding = 40; +// int btn_x_1 = 1660 - 200; + int btn_x_2 = 1660 - 50; + int xs[2] = {1660 - 200, 1660 - 50}; + if ((btn_x_1 - padding <= touch_x) && (touch_x <= btn_x_2 + padding) && (855 - padding <= touch_y)) { + s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button + s->scene.lsButtonStatus++; + if (s->scene.lsButtonStatus > 2) { + s->scene.lsButtonStatus = 0; + } + send_ls(s, s->scene.lsButtonStatus); + return true; + } + } + return false; +} + static void handle_sidebar_touch(UIState *s, int touch_x, int touch_y) { if (!s->scene.uilayout_sidebarcollapsed && touch_x <= sbr_w) { if (touch_x >= settings_btn_x && touch_x < (settings_btn_x + settings_btn_w) @@ -853,7 +873,7 @@ int main(int argc, char* argv[]) { set_awake(s, true); handle_sidebar_touch(s, touch_x, touch_y); - if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button + if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y) && !handle_ml_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button handle_vision_touch(s, touch_x, touch_y); } } From 019bbeb4af4b4b902c0d2153d57f3eb635934ed9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:33:58 -0500 Subject: [PATCH 51/99] see if this is correct --- selfdrive/ui/ui.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 3ec08e1879ca8f..4f1dc5f40d1cb2 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -143,13 +143,13 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { } static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { - //lsButton manager + //mlButton manager + int btn_w = 500; + int btn_h = 138; if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { int padding = 40; -// int btn_x_1 = 1660 - 200; - int btn_x_2 = 1660 - 50; - int xs[2] = {1660 - 200, 1660 - 50}; - if ((btn_x_1 - padding <= touch_x) && (touch_x <= btn_x_2 + padding) && (855 - padding <= touch_y)) { + int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; + if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (855 - padding <= touch_y)) { s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { From 13595882acd5c8a2d13a14546484b3973f94e522 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:34:21 -0500 Subject: [PATCH 52/99] see if this is correct --- selfdrive/ui/ui.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 4f1dc5f40d1cb2..72d2f2e570cf07 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -150,6 +150,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (855 - padding <= touch_y)) { + printf("ml button touched!\n") s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { From c76e5f376a139838aa80606e19bc1ac1c3655387 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:36:57 -0500 Subject: [PATCH 53/99] see if this is correct --- selfdrive/ui/ui.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 72d2f2e570cf07..d18e7562a715c3 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -149,7 +149,9 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; - if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (855 - padding <= touch_y)) { + int y_top = 915; + printf("here!\n") + if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (y_top <= touch_y)) { printf("ml button touched!\n") s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button s->scene.lsButtonStatus++; From 501f1a57c11798e4b584526809cf169aa7adb8d9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:38:13 -0500 Subject: [PATCH 54/99] see if this is correct --- selfdrive/ui/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index d18e7562a715c3..cc1374dc7f855c 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -150,7 +150,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; int y_top = 915; - printf("here!\n") + printf("here!\n"); if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (y_top <= touch_y)) { printf("ml button touched!\n") s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button From d98eeaea1fea11af93239fba8ab0500a0ba55088 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:38:24 -0500 Subject: [PATCH 55/99] see if this is correct --- selfdrive/ui/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index cc1374dc7f855c..287a7b77ac51ff 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -152,7 +152,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int y_top = 915; printf("here!\n"); if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (y_top <= touch_y)) { - printf("ml button touched!\n") + printf("ml button touched!\n"); s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { From fe1975fde0b3bc4b86c21756e66a0c0a9e416b58 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:39:59 -0500 Subject: [PATCH 56/99] debug --- selfdrive/ui/ui.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 287a7b77ac51ff..f4bcf51faca79a 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -146,6 +146,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager int btn_w = 500; int btn_h = 138; + printf("hi\n"); if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; @@ -153,7 +154,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { printf("here!\n"); if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (y_top <= touch_y)) { printf("ml button touched!\n"); - s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button + s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button todo: unify this s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { s->scene.lsButtonStatus = 0; From c418e68d4f5c19b6559e96353201c3d7a7a6661f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:40:37 -0500 Subject: [PATCH 57/99] debug --- selfdrive/ui/ui.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index f4bcf51faca79a..8510109e453558 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -144,8 +144,8 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager - int btn_w = 500; - int btn_h = 138; +// int btn_w = 500; +// int btn_h = 138; printf("hi\n"); if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { int padding = 40; From 17d327e022728ee4668dfecc4a0c6c7da1889a9a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:42:01 -0500 Subject: [PATCH 58/99] debug --- selfdrive/ui/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 8510109e453558..541706c3bcbea0 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -144,7 +144,7 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager -// int btn_w = 500; + int btn_w = 500; // int btn_h = 138; printf("hi\n"); if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { From 10277c8665d3bb959eae1aa025ac8505a10ddca3 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:46:56 -0500 Subject: [PATCH 59/99] debug --- selfdrive/ui/ui.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 541706c3bcbea0..c70263ec90d9fb 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -147,7 +147,8 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int btn_w = 500; // int btn_h = 138; printf("hi\n"); - if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { +// if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { + if (true) { int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; int y_top = 915; From ab0755e23e6e702004bd34b4e261a0fe3d7b6059 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:51:57 -0500 Subject: [PATCH 60/99] debug --- selfdrive/ui/ui.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index c70263ec90d9fb..ad754783b531be 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -146,14 +146,12 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager int btn_w = 500; // int btn_h = 138; - printf("hi\n"); // if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { if (true) { int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; int y_top = 915; - printf("here!\n"); - if ((xs[0] - padding <= touch_x) && (touch_x <= xs[1] + padding) && (y_top <= touch_y)) { + if (xs[0] <= touch_x && xs[1] >= touch_x && y_top <= touch_y) { printf("ml button touched!\n"); s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button todo: unify this s->scene.lsButtonStatus++; From 3823e585b520c87265a41e1544b4aacc1de80fdf Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:52:57 -0500 Subject: [PATCH 61/99] debug --- selfdrive/ui/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index ad754783b531be..8a3edc4a211dd5 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -149,7 +149,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { // if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { if (true) { int padding = 40; - int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w}; + int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915; if (xs[0] <= touch_x && xs[1] >= touch_x && y_top <= touch_y) { printf("ml button touched!\n"); From c304dd4c29b3789a2012f89dff98a69ccc90de8d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:53:31 -0500 Subject: [PATCH 62/99] debug --- selfdrive/ui/ui.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 8a3edc4a211dd5..edd14fbd9787c0 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -148,7 +148,6 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { // int btn_h = 138; // if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { if (true) { - int padding = 40; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915; if (xs[0] <= touch_x && xs[1] >= touch_x && y_top <= touch_y) { From ec074a48e0368adc8c45e198539557b3f6dc271c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:55:06 -0500 Subject: [PATCH 63/99] debug --- selfdrive/ui/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index edd14fbd9787c0..203cdbcee53ec6 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -150,7 +150,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { if (true) { int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915; - if (xs[0] <= touch_x && xs[1] >= touch_x && y_top <= touch_y) { + if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { printf("ml button touched!\n"); s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button todo: unify this s->scene.lsButtonStatus++; From 62772ebdcdd1f1b3b6d47d02138fee8370f67643 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:55:56 -0500 Subject: [PATCH 64/99] debug --- selfdrive/ui/ui.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 203cdbcee53ec6..1351af57635032 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -877,6 +877,8 @@ int main(int argc, char* argv[]) { if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y) && !handle_ml_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button handle_vision_touch(s, touch_x, touch_y); + } else { + printf("a SA button has been touched\n"); } } From 80f2d4632d53402c1f1e79dbaa9492b7860bcc3c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 02:57:49 -0500 Subject: [PATCH 65/99] debug --- selfdrive/ui/ui.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 1351af57635032..bf8e25b0c908b2 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -145,11 +145,12 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager int btn_w = 500; + int btn_h = 138; // int btn_h = 138; // if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { if (true) { int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; - int y_top = 915; + int y_top = 915 - btn_h / 2; if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { printf("ml button touched!\n"); s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button todo: unify this From 10169340dbf34fc567f9aa53670be3345d5a344d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:02:20 -0500 Subject: [PATCH 66/99] debug --- selfdrive/ui/ui.cc | 9 +++++---- selfdrive/ui/ui.hpp | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index bf8e25b0c908b2..3e72d91a80da2f 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -99,7 +99,7 @@ static void send_ls(UIState *s, int status) { static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { //lsButton manager - if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { + if (s->awake && s->vision_connected && s->status != STATUS_STOPPED || s->ui_debug) { int padding = 40; int btn_x_1 = 1660 - 200; int btn_x_2 = 1660 - 50; @@ -127,7 +127,7 @@ static void send_df(UIState *s, int status) { static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { //dfButton manager - if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { + if (s->awake && s->vision_connected && s->status != STATUS_STOPPED || s->ui_debug) { int padding = 40; if ((1660 - padding <= touch_x) && (855 - padding <= touch_y)) { s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping df button @@ -147,8 +147,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int btn_w = 500; int btn_h = 138; // int btn_h = 138; -// if (s->awake && s->vision_connected && s->status != STATUS_STOPPED) { - if (true) { + if (s->awake && s->vision_connected && s->status != STATUS_STOPPED || s->ui_debug) { int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915 - btn_h / 2; if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { @@ -256,6 +255,7 @@ static void ui_init(UIState *s) { s->scene.satelliteCount = -1; s->started = false; s->vision_seen = false; + s->ui_debug = true; // change to true while debugging // init display s->fb = framebuffer_init("ui", 0, true, &s->fb_w, &s->fb_h); @@ -879,6 +879,7 @@ int main(int argc, char* argv[]) { if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y) && !handle_ml_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button handle_vision_touch(s, touch_x, touch_y); } else { + s->scene.uilayout_sidebarcollapsed = true; printf("a SA button has been touched\n"); } } diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index 4f9095a5a4c5bf..792eb1180f096b 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -127,6 +127,7 @@ typedef struct UIScene { int dfButtonStatus; int lsButtonStatus; int mlButtonStatus; + bool ui_debug; cereal::HealthData::HwType hwType; int satelliteCount; From 1edc089872ebe856e7311e24ad475410ffb338fb Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:04:40 -0500 Subject: [PATCH 67/99] fix --- selfdrive/ui/ui.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index 792eb1180f096b..4ea817f058d3bc 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -127,7 +127,6 @@ typedef struct UIScene { int dfButtonStatus; int lsButtonStatus; int mlButtonStatus; - bool ui_debug; cereal::HealthData::HwType hwType; int satelliteCount; @@ -240,6 +239,7 @@ typedef struct UIState { bool started; bool preview_started; bool vision_seen; + bool ui_debug; std::atomic light_sensor; From 2c94168403847de5b04a96803fe3ed8adba57302 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:06:11 -0500 Subject: [PATCH 68/99] fix --- selfdrive/ui/ui.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 3e72d91a80da2f..ade37229a8d15c 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -99,12 +99,11 @@ static void send_ls(UIState *s, int status) { static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { //lsButton manager - if (s->awake && s->vision_connected && s->status != STATUS_STOPPED || s->ui_debug) { + if ()s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int padding = 40; int btn_x_1 = 1660 - 200; int btn_x_2 = 1660 - 50; if ((btn_x_1 - padding <= touch_x) && (touch_x <= btn_x_2 + padding) && (855 - padding <= touch_y)) { - s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { s->scene.lsButtonStatus = 0; @@ -127,7 +126,7 @@ static void send_df(UIState *s, int status) { static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { //dfButton manager - if (s->awake && s->vision_connected && s->status != STATUS_STOPPED || s->ui_debug) { + if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int padding = 40; if ((1660 - padding <= touch_x) && (855 - padding <= touch_y)) { s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping df button @@ -147,7 +146,7 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int btn_w = 500; int btn_h = 138; // int btn_h = 138; - if (s->awake && s->vision_connected && s->status != STATUS_STOPPED || s->ui_debug) { + if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915 - btn_h / 2; if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { @@ -879,7 +878,7 @@ int main(int argc, char* argv[]) { if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y) && !handle_ml_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button handle_vision_touch(s, touch_x, touch_y); } else { - s->scene.uilayout_sidebarcollapsed = true; + s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping any SA button printf("a SA button has been touched\n"); } } From 15edac99dde27e65adb3a0e614be3ba9eab87a0d Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:06:33 -0500 Subject: [PATCH 69/99] fix --- selfdrive/ui/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index ade37229a8d15c..a2d3e790c7c0f8 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -99,7 +99,7 @@ static void send_ls(UIState *s, int status) { static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { //lsButton manager - if ()s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { + if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int padding = 40; int btn_x_1 = 1660 - 200; int btn_x_2 = 1660 - 50; From f11e066cc5a76effd28c418e16f3d270592de78b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:11:32 -0500 Subject: [PATCH 70/99] debug --- ml_button.py | 6 +++++ selfdrive/ui/ui.cc | 58 +++++++++++++++++++++++---------------------- selfdrive/ui/ui.hpp | 2 +- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 ml_button.py diff --git a/ml_button.py b/ml_button.py new file mode 100644 index 00000000000000..7d1191252df651 --- /dev/null +++ b/ml_button.py @@ -0,0 +1,6 @@ +from cereal.messaging import SubMaster +sm = SubMaster(['modelLongButton']) +while 1: + input() + sm.update(0) + print(sm['modelLongButton'].status) \ No newline at end of file diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index a2d3e790c7c0f8..4a8bf9a9dc0a1d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -88,15 +88,6 @@ static void update_offroad_layout_state(UIState *s) { #endif } -static void send_ls(UIState *s, int status) { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto lsStatus = event.initLaneSpeedButton(); - lsStatus.setStatus(status); - s->pm->send("laneSpeedButton", msg); -} - static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { //lsButton manager if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { @@ -115,21 +106,11 @@ static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { return false; } -static void send_df(UIState *s, int status) { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto dfStatus = event.initDynamicFollowButton(); - dfStatus.setStatus(status); - s->pm->send("dynamicFollowButton", msg); -} - static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { //dfButton manager if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int padding = 40; if ((1660 - padding <= touch_x) && (855 - padding <= touch_y)) { - s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping df button s->scene.dfButtonStatus++; if (s->scene.dfButtonStatus > 3) { s->scene.dfButtonStatus = 0; @@ -145,24 +126,46 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager int btn_w = 500; int btn_h = 138; -// int btn_h = 138; if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915 - btn_h / 2; if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { printf("ml button touched!\n"); - s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping ls button todo: unify this - s->scene.lsButtonStatus++; - if (s->scene.lsButtonStatus > 2) { - s->scene.lsButtonStatus = 0; - } - send_ls(s, s->scene.lsButtonStatus); + s->scene.mlButtonStatus = !s->scene.mlButtonStatus; + send_ml(s, s->scene.mlButtonStatus); return true; } } return false; } +static void send_ls(UIState *s, int status) { + capnp::MallocMessageBuilder msg; + auto event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto lsStatus = event.initLaneSpeedButton(); + lsStatus.setStatus(status); + s->pm->send("laneSpeedButton", msg); +} + +static void send_df(UIState *s, int status) { + capnp::MallocMessageBuilder msg; + auto event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto dfStatus = event.initDynamicFollowButton(); + dfStatus.setStatus(status); + s->pm->send("dynamicFollowButton", msg); +} + +static void send_ml(UIState *s, bool status) { + capnp::MallocMessageBuilder msg; + auto event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto mlStatus = event.initModelLongButton(); + mlStatus.setStatus(status); + s->pm->send("modelLongButton", msg); +} + static void handle_sidebar_touch(UIState *s, int touch_x, int touch_y) { if (!s->scene.uilayout_sidebarcollapsed && touch_x <= sbr_w) { if (touch_x >= settings_btn_x && touch_x < (settings_btn_x + settings_btn_w) @@ -293,7 +296,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, s->scene.dfButtonStatus = 0; s->scene.lsButtonStatus = 0; - s->scene.mlButtonStatus = 0; + s->scene.mlButtonStatus = false; s->rgb_width = back_bufs.width; s->rgb_height = back_bufs.height; @@ -879,7 +882,6 @@ int main(int argc, char* argv[]) { handle_vision_touch(s, touch_x, touch_y); } else { s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping any SA button - printf("a SA button has been touched\n"); } } diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index 4ea817f058d3bc..c680a919763b5c 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -126,7 +126,7 @@ typedef struct UIScene { int dfButtonStatus; int lsButtonStatus; - int mlButtonStatus; + bool mlButtonStatus; cereal::HealthData::HwType hwType; int satelliteCount; From 79e7e796328b634bb4ad57c51e6d73e7140635e5 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:12:52 -0500 Subject: [PATCH 71/99] debug --- selfdrive/ui/ui.cc | 10 +++++----- selfdrive/ui/ui.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 4a8bf9a9dc0a1d..d1d2ccb5bf5bbd 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -131,8 +131,8 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int y_top = 915 - btn_h / 2; if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { printf("ml button touched!\n"); - s->scene.mlButtonStatus = !s->scene.mlButtonStatus; - send_ml(s, s->scene.mlButtonStatus); + s->scene.mlButtonEnabled = !s->scene.mlButtonEnabled; + send_ml(s, s->scene.mlButtonEnabled); return true; } } @@ -157,12 +157,12 @@ static void send_df(UIState *s, int status) { s->pm->send("dynamicFollowButton", msg); } -static void send_ml(UIState *s, bool status) { +static void send_ml(UIState *s, bool enabled) { capnp::MallocMessageBuilder msg; auto event = msg.initRoot(); event.setLogMonoTime(nanos_since_boot()); auto mlStatus = event.initModelLongButton(); - mlStatus.setStatus(status); + mlStatus.setEnabled(enabled); s->pm->send("modelLongButton", msg); } @@ -296,7 +296,7 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, s->scene.dfButtonStatus = 0; s->scene.lsButtonStatus = 0; - s->scene.mlButtonStatus = false; + s->scene.mlButtonEnabled = false; s->rgb_width = back_bufs.width; s->rgb_height = back_bufs.height; diff --git a/selfdrive/ui/ui.hpp b/selfdrive/ui/ui.hpp index c680a919763b5c..c74b8af5ba6943 100644 --- a/selfdrive/ui/ui.hpp +++ b/selfdrive/ui/ui.hpp @@ -126,7 +126,7 @@ typedef struct UIScene { int dfButtonStatus; int lsButtonStatus; - bool mlButtonStatus; + bool mlButtonEnabled; cereal::HealthData::HwType hwType; int satelliteCount; From a46f31104de1b0f74ed934b3b3e2e2fc60f01763 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:14:14 -0500 Subject: [PATCH 72/99] move up? --- selfdrive/ui/ui.cc | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index d1d2ccb5bf5bbd..8acf1328920a4d 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -88,6 +88,33 @@ static void update_offroad_layout_state(UIState *s) { #endif } +static void send_ls(UIState *s, int status) { + capnp::MallocMessageBuilder msg; + auto event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto lsStatus = event.initLaneSpeedButton(); + lsStatus.setStatus(status); + s->pm->send("laneSpeedButton", msg); +} + +static void send_df(UIState *s, int status) { + capnp::MallocMessageBuilder msg; + auto event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto dfStatus = event.initDynamicFollowButton(); + dfStatus.setStatus(status); + s->pm->send("dynamicFollowButton", msg); +} + +static void send_ml(UIState *s, bool enabled) { + capnp::MallocMessageBuilder msg; + auto event = msg.initRoot(); + event.setLogMonoTime(nanos_since_boot()); + auto mlStatus = event.initModelLongButton(); + mlStatus.setEnabled(enabled); + s->pm->send("modelLongButton", msg); +} + static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { //lsButton manager if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { @@ -139,33 +166,6 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { return false; } -static void send_ls(UIState *s, int status) { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto lsStatus = event.initLaneSpeedButton(); - lsStatus.setStatus(status); - s->pm->send("laneSpeedButton", msg); -} - -static void send_df(UIState *s, int status) { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto dfStatus = event.initDynamicFollowButton(); - dfStatus.setStatus(status); - s->pm->send("dynamicFollowButton", msg); -} - -static void send_ml(UIState *s, bool enabled) { - capnp::MallocMessageBuilder msg; - auto event = msg.initRoot(); - event.setLogMonoTime(nanos_since_boot()); - auto mlStatus = event.initModelLongButton(); - mlStatus.setEnabled(enabled); - s->pm->send("modelLongButton", msg); -} - static void handle_sidebar_touch(UIState *s, int touch_x, int touch_y) { if (!s->scene.uilayout_sidebarcollapsed && touch_x <= sbr_w) { if (touch_x >= settings_btn_x && touch_x < (settings_btn_x + settings_btn_w) From bf14d6847c82a0439af7f7d7743ccf75645979e0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:15:46 -0500 Subject: [PATCH 73/99] debug --- ml_button.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ml_button.py b/ml_button.py index 7d1191252df651..96e1819cfe594b 100644 --- a/ml_button.py +++ b/ml_button.py @@ -3,4 +3,4 @@ while 1: input() sm.update(0) - print(sm['modelLongButton'].status) \ No newline at end of file + print(sm['modelLongButton'].enabled) From 779a6ab4c792821decf226f4acda26a7f0c6ba0b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:16:50 -0500 Subject: [PATCH 74/99] debug --- ml_button.py | 6 ------ selfdrive/ui/ui.cc | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 ml_button.py diff --git a/ml_button.py b/ml_button.py deleted file mode 100644 index 96e1819cfe594b..00000000000000 --- a/ml_button.py +++ /dev/null @@ -1,6 +0,0 @@ -from cereal.messaging import SubMaster -sm = SubMaster(['modelLongButton']) -while 1: - input() - sm.update(0) - print(sm['modelLongButton'].enabled) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 8acf1328920a4d..b8447422a72413 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -881,6 +881,7 @@ int main(int argc, char* argv[]) { if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y) && !handle_ml_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button handle_vision_touch(s, touch_x, touch_y); } else { + printf("SA button touched!\n"); s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping any SA button } } From 294915843432fdf4d66dff424da3a576e06707e0 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:17:14 -0500 Subject: [PATCH 75/99] debug --- selfdrive/ui/ui.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index b8447422a72413..a33f3abfe1af80 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -874,7 +874,9 @@ int main(int argc, char* argv[]) { int touch_x = -1, touch_y = -1; int touched = touch_poll(&touch, &touch_x, &touch_y, 0); if (touched == 1) { - printf("touched x: %d, y: %d\n", touch_x, touch_y); + if (s->ui_debug) { + printf("touched x: %d, y: %d\n", touch_x, touch_y); + } set_awake(s, true); handle_sidebar_touch(s, touch_x, touch_y); From 998972a3cc2f2b07779ea04fd02fb0c018db5077 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:20:41 -0500 Subject: [PATCH 76/99] add padding --- selfdrive/ui/ui.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index a33f3abfe1af80..ef159609040e9b 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -150,19 +150,20 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { } static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { - //mlButton manager + //mlButton manager + if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { + int padding = 40; int btn_w = 500; int btn_h = 138; - if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { - int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; - int y_top = 915 - btn_h / 2; - if (xs[0] <= touch_x && touch_x <= xs[1] && y_top <= touch_y) { - printf("ml button touched!\n"); - s->scene.mlButtonEnabled = !s->scene.mlButtonEnabled; - send_ml(s, s->scene.mlButtonEnabled); - return true; - } + int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; + int y_top = 915 - btn_h / 2; + if (xs[0] <= touch_x + padding && touch_x - padding <= xs[1] && y_top - padding <= touch_y) { + printf("ml button touched!\n"); + s->scene.mlButtonEnabled = !s->scene.mlButtonEnabled; + send_ml(s, s->scene.mlButtonEnabled); + return true; } + } return false; } @@ -883,7 +884,6 @@ int main(int argc, char* argv[]) { if (!handle_df_touch(s, touch_x, touch_y) && !handle_ls_touch(s, touch_x, touch_y) && !handle_ml_touch(s, touch_x, touch_y)) { // disables sidebar from popping out when tapping df or ls button handle_vision_touch(s, touch_x, touch_y); } else { - printf("SA button touched!\n"); s->scene.uilayout_sidebarcollapsed = true; // collapse sidebar when tapping any SA button } } From 0092f08b50a915eb2b9eb21934430518dee77eca Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:36:05 -0500 Subject: [PATCH 77/99] add e2e long --- selfdrive/controls/lib/planner.py | 18 +++++++++++++++--- selfdrive/controls/plannerd.py | 2 +- selfdrive/ui/ui.cc | 4 +++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/selfdrive/controls/lib/planner.py b/selfdrive/controls/lib/planner.py index 4eae35bb347f0f..53366cca2ae726 100755 --- a/selfdrive/controls/lib/planner.py +++ b/selfdrive/controls/lib/planner.py @@ -14,6 +14,7 @@ from selfdrive.controls.lib.fcw import FCWChecker from selfdrive.controls.lib.long_mpc import LongitudinalMpc from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX +from selfdrive.controls.lib.long_mpc_model import LongitudinalMpcModel MAX_SPEED = 255.0 @@ -69,6 +70,7 @@ def __init__(self, CP): self.mpc1 = LongitudinalMpc(1) self.mpc2 = LongitudinalMpc(2) + self.mpc_model = LongitudinalMpcModel() self.v_acc_start = 0.0 self.a_acc_start = 0.0 @@ -86,13 +88,15 @@ def __init__(self, CP): self.params = Params() self.first_loop = True - def choose_solution(self, v_cruise_setpoint, enabled): + def choose_solution(self, v_cruise_setpoint, enabled, model_enabled): if enabled: solutions = {'cruise': self.v_cruise} if self.mpc1.prev_lead_status: solutions['mpc1'] = self.mpc1.v_mpc if self.mpc2.prev_lead_status: solutions['mpc2'] = self.mpc2.v_mpc + if self.mpc_model.valid and model_enabled: + solutions['model'] = self.mpc_model.v_mpc slowest = min(solutions, key=solutions.get) @@ -107,8 +111,11 @@ def choose_solution(self, v_cruise_setpoint, enabled): elif slowest == 'cruise': self.v_acc = self.v_cruise self.a_acc = self.a_cruise + elif slowest == 'model': + self.v_acc = self.mpc_model.v_mpc + self.a_acc = self.mpc_model.a_mpc - self.v_acc_future = min([self.mpc1.v_mpc_future, self.mpc2.v_mpc_future, v_cruise_setpoint]) + self.v_acc_future = min([self.mpc1.v_mpc_future, self.mpc2.v_mpc_future, self.mpc_model.v_mpc_future, v_cruise_setpoint]) def update(self, sm, pm, CP, VM, PP): """Gets called when new radarState is available""" @@ -161,11 +168,16 @@ def update(self, sm, pm, CP, VM, PP): self.mpc1.set_cur_state(self.v_acc_start, self.a_acc_start) self.mpc2.set_cur_state(self.v_acc_start, self.a_acc_start) + self.mpc_model.set_cur_state(self.v_acc_start, self.a_acc_start) self.mpc1.update(pm, sm['carState'], lead_1, v_cruise_setpoint) self.mpc2.update(pm, sm['carState'], lead_2, v_cruise_setpoint) + self.mpc_model.update(sm['carState'].vEgo, sm['carState'].aEgo, + sm['model'].longitudinal.distances, + sm['model'].longitudinal.speeds, + sm['model'].longitudinal.accelerations) - self.choose_solution(v_cruise_setpoint, enabled) + self.choose_solution(v_cruise_setpoint, enabled, sm['modelLongButton'].enabled) # determine fcw if self.mpc1.new_lead: diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index b439681a3a2303..5910c11f756474 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -27,7 +27,7 @@ def plannerd_thread(sm=None, pm=None): VM = VehicleModel(CP) if sm is None: - sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters']) + sm = messaging.SubMaster(['carState', 'controlsState', 'radarState', 'model', 'liveParameters', 'modelLongButton']) if pm is None: pm = messaging.PubMaster(['plan', 'liveLongitudinalMpc', 'pathPlan', 'liveMpc']) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index ef159609040e9b..fd69d7338ca8a0 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -122,6 +122,7 @@ static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { int btn_x_1 = 1660 - 200; int btn_x_2 = 1660 - 50; if ((btn_x_1 - padding <= touch_x) && (touch_x <= btn_x_2 + padding) && (855 - padding <= touch_y)) { + printf("ls button touched!\n"); s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { s->scene.lsButtonStatus = 0; @@ -138,6 +139,7 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int padding = 40; if ((1660 - padding <= touch_x) && (855 - padding <= touch_y)) { + printf("df button touched!\n"); s->scene.dfButtonStatus++; if (s->scene.dfButtonStatus > 3) { s->scene.dfButtonStatus = 0; @@ -152,7 +154,7 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { //mlButton manager if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { - int padding = 40; + int padding = 40; int btn_w = 500; int btn_h = 138; int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; From 108025e558fdd26531b68693cf03525881ea50c9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:48:55 -0500 Subject: [PATCH 78/99] add modelLongAlert and debug --- selfdrive/controls/controlsd.py | 16 ++++++++++++++-- selfdrive/controls/lib/events.py | 6 ++++++ selfdrive/debug/cycle_alerts.py | 5 ++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index e2163274830af3..b083949f05c6a4 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -55,11 +55,13 @@ def __init__(self, sm=None, pm=None, can_sock=None): if self.sm is None: self.sm = messaging.SubMaster(['thermal', 'health', 'frame', 'model', 'liveCalibration', 'dMonitoringState', 'plan', 'pathPlan', 'liveLocationKalman']) - self.sm_smiskol = messaging.SubMaster(['radarState', 'dynamicFollowData', 'liveTracks', 'dynamicFollowButton', 'laneSpeed', 'dynamicCameraOffset']) + self.sm_smiskol = messaging.SubMaster(['radarState', 'dynamicFollowData', 'liveTracks', 'dynamicFollowButton', + 'laneSpeed', 'dynamicCameraOffset', 'modelLongButton']) self.op_params = opParams() self.df_manager = dfManager(self.op_params) - self.hide_auto_df_alerts = self.op_params.get('hide_auto_df_alerts', False) + self.hide_auto_df_alerts = self.op_params.get('hide_auto_df_alerts', False) + self.last_model_long = False self.can_sock = can_sock if can_sock is None: @@ -276,6 +278,15 @@ def data_sample(self): def add_stock_additions_alerts(self, CS): frame = self.sm.frame # alert priority is defined by code location, keeping is highest, then lane speed alert, then auto-df alert + if self.sm_smiskol['modelLongButton'].enabled != self.last_model_long: + if self.last_model_long: + extra_text_1 = 'disabled!' + extra_text_2 = '' + else: + extra_text_1 = 'enabled!' + extra_text_2 = 'Remain alert' + self.AM.add_custom(frame, 'modelLongAlert', self.enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2) + if self.sm_smiskol['dynamicCameraOffset'].keepingLeft: self.AM.add_custom(frame, 'laneSpeedKeeping', self.enabled, extra_text_1='LEFT', extra_text_2='Oncoming traffic in right lane') return @@ -486,6 +497,7 @@ def publish_logs(self, CS, start_time, actuators, v_acc, a_acc, lac_log): alerts = self.events.create_alerts(self.current_alert_types, [self.CP, self.sm, self.is_metric]) self.AM.add_many(self.sm.frame, alerts, self.enabled) self.add_stock_additions_alerts(CS) + self.last_model_long = self.sm_smiskol['modelLongButton'].enabled self.AM.process_alerts(self.sm.frame) CC.hudControl.visualAlert = self.AM.visual_alert diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index d3a5b35e2626ca..dde02b71176626 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -525,6 +525,12 @@ def wrong_car_mode_alert(CP, sm, metric): duration_hud_alert=0.), }, + "modelLongAlert": Alert( + "Model longitudinal ", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + "dfButtonAlert": Alert( "Using profile: ", "", diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py index 63b7d758c5901f..2731fd8599eabf 100755 --- a/selfdrive/debug/cycle_alerts.py +++ b/selfdrive/debug/cycle_alerts.py @@ -10,7 +10,10 @@ from selfdrive.controls.lib.events import EVENTS, Alert def now_millis(): return time.time() * 1000 - +for _, et in EVENTS.items(): + print(et) + for _, a in et.items(): + print(a) ALERTS = [a for _, et in EVENTS.items() for _, a in et.items() if isinstance(a, Alert)] #from cereal import car From ef46fb9cf4f1ed701825c5e0fc6456f355806b1f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:50:36 -0500 Subject: [PATCH 79/99] add modelLongAlert and debug --- selfdrive/controls/lib/events.py | 12 +++++++----- selfdrive/debug/cycle_alerts.py | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index dde02b71176626..fc852ee3c6d67f 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -525,11 +525,13 @@ def wrong_car_mode_alert(CP, sm, metric): duration_hud_alert=0.), }, - "modelLongAlert": Alert( - "Model longitudinal ", - "", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + "modelLongAlert": { + ET.WARNING: Alert( + "Model longitudinal ", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + }, "dfButtonAlert": Alert( "Using profile: ", diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py index 2731fd8599eabf..3d99d409d391ee 100755 --- a/selfdrive/debug/cycle_alerts.py +++ b/selfdrive/debug/cycle_alerts.py @@ -12,6 +12,10 @@ def now_millis(): return time.time() * 1000 for _, et in EVENTS.items(): print(et) + try: + et.items() + except: + continue for _, a in et.items(): print(a) ALERTS = [a for _, et in EVENTS.items() for _, a in et.items() if isinstance(a, Alert)] From 5da8c60cf63d8e971292d76953c13d994b63225b Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:50:56 -0500 Subject: [PATCH 80/99] debug --- selfdrive/controls/lib/events.py | 70 ++++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index fc852ee3c6d67f..65675d8e345c0a 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -533,41 +533,41 @@ def wrong_car_mode_alert(CP, sm, metric): Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), }, - "dfButtonAlert": Alert( - "Using profile: ", - "", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), - - "lsButtonAlert": Alert( - "Lane Speed set to: ", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), - - "dfButtonAlertSilent": Alert( - "Dynamic follow: ", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0.2, 0., 2.), - - "laneSpeedAlert": Alert( - "", - "", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 0.1), - - "laneSpeedAlertSilent": Alert( - "", - "", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), - - "laneSpeedKeeping": Alert( - "KEEPING ", - "", - AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), + # "dfButtonAlert": Alert( + # "Using profile: ", + # "", + # AlertStatus.normal, AlertSize.mid, + # Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + # + # "lsButtonAlert": Alert( + # "Lane Speed set to: ", + # "", + # AlertStatus.normal, AlertSize.small, + # Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + # + # "dfButtonAlertSilent": Alert( + # "Dynamic follow: ", + # "", + # AlertStatus.normal, AlertSize.small, + # Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0.2, 0., 2.), + # + # "laneSpeedAlert": Alert( + # "", + # "", + # AlertStatus.normal, AlertSize.mid, + # Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 0.1), + # + # "laneSpeedAlertSilent": Alert( + # "", + # "", + # AlertStatus.normal, AlertSize.mid, + # Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), + # + # "laneSpeedKeeping": Alert( + # "KEEPING ", + # "", + # AlertStatus.normal, AlertSize.mid, + # Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), EventName.posenetInvalid: { ET.WARNING: Alert( From 161f8e00bdfa28e68d74bb55bd5fb85e0a7eff57 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:51:47 -0500 Subject: [PATCH 81/99] debug --- selfdrive/debug/cycle_alerts.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py index 3d99d409d391ee..11d6c28381cc22 100755 --- a/selfdrive/debug/cycle_alerts.py +++ b/selfdrive/debug/cycle_alerts.py @@ -10,14 +10,6 @@ from selfdrive.controls.lib.events import EVENTS, Alert def now_millis(): return time.time() * 1000 -for _, et in EVENTS.items(): - print(et) - try: - et.items() - except: - continue - for _, a in et.items(): - print(a) ALERTS = [a for _, et in EVENTS.items() for _, a in et.items() if isinstance(a, Alert)] #from cereal import car From ceb32854e50a28b03fb762c636acd2bf36b40686 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 03:59:02 -0500 Subject: [PATCH 82/99] maybe this will enable sound? --- selfdrive/controls/controlsd.py | 14 ++--- selfdrive/controls/lib/alertmanager.py | 4 +- selfdrive/controls/lib/events.py | 82 +++++++++++++++----------- 3 files changed, 56 insertions(+), 44 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index b083949f05c6a4..b2cca0cd742bc6 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -285,18 +285,18 @@ def add_stock_additions_alerts(self, CS): else: extra_text_1 = 'enabled!' extra_text_2 = 'Remain alert' - self.AM.add_custom(frame, 'modelLongAlert', self.enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2) + self.AM.add_custom(frame, 'modelLongAlert', ET.WARNING, self.enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2) if self.sm_smiskol['dynamicCameraOffset'].keepingLeft: - self.AM.add_custom(frame, 'laneSpeedKeeping', self.enabled, extra_text_1='LEFT', extra_text_2='Oncoming traffic in right lane') + self.AM.add_custom(frame, 'laneSpeedKeeping', ET.WARNING, self.enabled, extra_text_1='LEFT', extra_text_2='Oncoming traffic in right lane') return elif self.sm_smiskol['dynamicCameraOffset'].keepingRight: - self.AM.add_custom(frame, 'laneSpeedKeeping', self.enabled, extra_text_1='RIGHT', extra_text_2='Oncoming traffic in left lane') + self.AM.add_custom(frame, 'laneSpeedKeeping', ET.WARNING, self.enabled, extra_text_1='RIGHT', extra_text_2='Oncoming traffic in left lane') return ls_state = self.sm_smiskol['laneSpeed'].state if ls_state != '': - self.AM.add_custom(frame, 'lsButtonAlert', self.enabled, extra_text_1=ls_state) + self.AM.add_custom(frame, 'lsButtonAlert', ET.WARNING, self.enabled, extra_text_1=ls_state) return faster_lane = self.sm_smiskol['laneSpeed'].fastestLane @@ -304,7 +304,7 @@ def add_stock_additions_alerts(self, CS): ls_alert = 'laneSpeedAlert' if not self.sm_smiskol['laneSpeed'].new: ls_alert += 'Silent' - self.AM.add_custom(frame, ls_alert, self.enabled, extra_text_1='{} lane faster'.format(faster_lane).upper(), extra_text_2='Change lanes to faster {} lane'.format(faster_lane)) + self.AM.add_custom(frame, ls_alert, ET.WARNING, self.enabled, extra_text_1='{} lane faster'.format(faster_lane).upper(), extra_text_2='Change lanes to faster {} lane'.format(faster_lane)) return df_out = self.df_manager.update() @@ -314,10 +314,10 @@ def add_stock_additions_alerts(self, CS): # only show auto alert if engaged, not hiding auto, and time since lane speed alert not showing if CS.cruiseState.enabled and not self.hide_auto_df_alerts: df_alert += 'Silent' - self.AM.add_custom(frame, df_alert, self.enabled, extra_text_1=df_out.model_profile_text + ' (auto)') + self.AM.add_custom(frame, df_alert, ET.WARNING, self.enabled, extra_text_1=df_out.model_profile_text + ' (auto)') return else: - self.AM.add_custom(frame, df_alert, self.enabled, extra_text_1=df_out.user_profile_text, extra_text_2='Dynamic follow: {} profile active'.format(df_out.user_profile_text)) + self.AM.add_custom(frame, df_alert, ET.WARNING, self.enabled, extra_text_1=df_out.user_profile_text, extra_text_2='Dynamic follow: {} profile active'.format(df_out.user_profile_text)) return def state_transition(self, CS): diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index 4e6e47e43aef8a..d38164e9974269 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -22,8 +22,8 @@ def add_many(self, frame, alerts, enabled=True): for a in alerts: self.add(frame, a, enabled=enabled) - def add_custom(self, frame, alert_name, enabled=True, extra_text_1='', extra_text_2=''): - alert = EVENTS[alert_name] + def add_custom(self, frame, alert_name, event_type, enabled=True, extra_text_1='', extra_text_2=''): + alert = EVENTS[alert_name][event_type] added_alert = copy.copy(alert) added_alert.start_time = frame * DT_CTRL added_alert.alert_text_1 += extra_text_1 diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 65675d8e345c0a..0c60357e3279cb 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -533,41 +533,53 @@ def wrong_car_mode_alert(CP, sm, metric): Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), }, - # "dfButtonAlert": Alert( - # "Using profile: ", - # "", - # AlertStatus.normal, AlertSize.mid, - # Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), - # - # "lsButtonAlert": Alert( - # "Lane Speed set to: ", - # "", - # AlertStatus.normal, AlertSize.small, - # Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), - # - # "dfButtonAlertSilent": Alert( - # "Dynamic follow: ", - # "", - # AlertStatus.normal, AlertSize.small, - # Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0.2, 0., 2.), - # - # "laneSpeedAlert": Alert( - # "", - # "", - # AlertStatus.normal, AlertSize.mid, - # Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 0.1), - # - # "laneSpeedAlertSilent": Alert( - # "", - # "", - # AlertStatus.normal, AlertSize.mid, - # Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), - # - # "laneSpeedKeeping": Alert( - # "KEEPING ", - # "", - # AlertStatus.normal, AlertSize.mid, - # Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), + "dfButtonAlert": { + ET.WARNING: Alert( + "Using profile: ", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + }, + + "lsButtonAlert": { + ET.WARNING: Alert( + "Lane Speed set to: ", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + }, + + "dfButtonAlertSilent": { + ET.WARNING: Alert( + "Dynamic follow: ", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0.2, 0., 2.), + }, + + "laneSpeedAlert": { + ET.WARNING: Alert( + "", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 0.1), + }, + + "laneSpeedAlertSilent": { + ET.WARNING: Alert( + "", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), + }, + + "laneSpeedKeeping": { + ET.WARNING: Alert( + "KEEPING ", + "", + AlertStatus.normal, AlertSize.mid, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), + }, EventName.posenetInvalid: { ET.WARNING: Alert( From b34ee1e3c97fbf7789751e00f8007d9d2185a4f6 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 04:03:20 -0500 Subject: [PATCH 83/99] update alerts --- selfdrive/controls/lib/events.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 0c60357e3279cb..4e5ab5dcffbfdd 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -530,7 +530,7 @@ def wrong_car_mode_alert(CP, sm, metric): "Model longitudinal ", "", AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, .4, 0., 2.), }, "dfButtonAlert": { @@ -538,7 +538,7 @@ def wrong_car_mode_alert(CP, sm, metric): "Using profile: ", "", AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, .4, 0., 2.), }, "lsButtonAlert": { @@ -546,7 +546,7 @@ def wrong_car_mode_alert(CP, sm, metric): "Lane Speed set to: ", "", AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 2.), + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, .4, 0., 2.), }, "dfButtonAlertSilent": { @@ -554,7 +554,7 @@ def wrong_car_mode_alert(CP, sm, metric): "Dynamic follow: ", "", AlertStatus.normal, AlertSize.small, - Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0.2, 0., 2.), + Priority.LOWER, VisualAlert.none, AudibleAlert.none, .2, 0., 2.), }, "laneSpeedAlert": { @@ -562,7 +562,7 @@ def wrong_car_mode_alert(CP, sm, metric): "", "", AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, 0.2, 0., 0.1), + Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, .4, 0., .1), }, "laneSpeedAlertSilent": { @@ -570,7 +570,7 @@ def wrong_car_mode_alert(CP, sm, metric): "", "", AlertStatus.normal, AlertSize.mid, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0.2, 0., 0.1), + Priority.LOW, VisualAlert.none, AudibleAlert.none, .2, 0., .1), }, "laneSpeedKeeping": { From 6ea1311c131710577d7e86f8baceb5060d07f4b1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:03:07 -0500 Subject: [PATCH 84/99] color code outline --- selfdrive/ui/paint.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 7e481a3ff4703e..2c7013fccdd6f0 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -678,7 +678,11 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgStrokeColor(s->vg, nvgRGBA(130, 12, 128, 255)); + if (s->scene.mlButtonEnabled) { + nvgStrokeColor(s->vg, nvgRGBA(55, 184, 104, 255)); + } else { + nvgStrokeColor(s->vg, nvgRGBA(184, 55, 55, 255)); + } nvgStrokeWidth(s->vg, 12); nvgStroke(s->vg); From d4350b1c0af6ec6da0ed2fd1668e48eee04eb412 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:05:39 -0500 Subject: [PATCH 85/99] add background --- selfdrive/ui/paint.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 2c7013fccdd6f0..8a12f864b13b05 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -686,6 +686,11 @@ static void ui_draw_ml_button(UIState *s) { nvgStrokeWidth(s->vg, 12); nvgStroke(s->vg); + nvgBeginPath(s->vg); + nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); + nvgStrokeColor(s->vg, nvgRGBA(130, 12, 104, 128)); + nvgStroke(s->vg); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); nvgText(s->vg, x, y + btn_h / 8, "Toggle Model Long", NULL); From ddb4ecdcd17dd670dbc1aea28aedfa72a8f419ba Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:06:53 -0500 Subject: [PATCH 86/99] add background --- selfdrive/ui/paint.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 8a12f864b13b05..5ba8767d00b8f9 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -678,7 +678,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - if (s->scene.mlButtonEnabled) { + if (s->scene.mlButtonEnabled) { // change outline color based on status of button nvgStrokeColor(s->vg, nvgRGBA(55, 184, 104, 255)); } else { nvgStrokeColor(s->vg, nvgRGBA(184, 55, 55, 255)); @@ -686,9 +686,9 @@ static void ui_draw_ml_button(UIState *s) { nvgStrokeWidth(s->vg, 12); nvgStroke(s->vg); - nvgBeginPath(s->vg); + nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgStrokeColor(s->vg, nvgRGBA(130, 12, 104, 128)); + nvgFillColor(s->vg, nvgRGBA(130, 12, 104, 128)); nvgStroke(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From 1f37bd1f2507ce504871e31e252a72bf5d6e4a02 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:08:00 -0500 Subject: [PATCH 87/99] add background --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 5ba8767d00b8f9..65b8cc7bce1fa8 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -689,7 +689,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); nvgFillColor(s->vg, nvgRGBA(130, 12, 104, 128)); - nvgStroke(s->vg); + nvgFill(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); From b673711125dd5d7457bfc54cf936f289ed1b5db5 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:09:07 -0500 Subject: [PATCH 88/99] add background --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 65b8cc7bce1fa8..d51d562326f1f4 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -688,7 +688,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgFillColor(s->vg, nvgRGBA(130, 12, 104, 128)); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 128)); nvgFill(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From ff72c0da830291a847f90064ea0fa7abed13f791 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:10:04 -0500 Subject: [PATCH 89/99] add background --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index d51d562326f1f4..50e33845eba61d 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -688,7 +688,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 128)); + nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 64)); nvgFill(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From 58d1ac7582be863ca541338b60962b2114bf2ab8 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:11:13 -0500 Subject: [PATCH 90/99] add background --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 50e33845eba61d..37a9affdcfba94 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -688,7 +688,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 64)); + nvgFillColor(s->vg, nvgRGBA(100, 100, 100, 64)); nvgFill(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From 65f6aeaa2dacedaf359181c406d4baaf98f36ae1 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:12:01 -0500 Subject: [PATCH 91/99] add background --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 37a9affdcfba94..33d9f3f0ff5d7c 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -688,7 +688,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgFillColor(s->vg, nvgRGBA(100, 100, 100, 64)); + nvgFillColor(s->vg, nvgRGBA(75, 75, 75, 128)); nvgFill(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From ff9ed59f0a0cdfe7b40530236707fb67d351544c Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:13:21 -0500 Subject: [PATCH 92/99] add background --- selfdrive/ui/paint.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index 33d9f3f0ff5d7c..e63b88d4a48eb7 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -688,7 +688,7 @@ static void ui_draw_ml_button(UIState *s) { nvgBeginPath(s->vg); // dark background for readability nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); - nvgFillColor(s->vg, nvgRGBA(75, 75, 75, 128)); + nvgFillColor(s->vg, nvgRGBA(75, 75, 75, 75)); nvgFill(s->vg); nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); From f137b09ef340c64d995fe635f11d6d6a924ec3b4 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:17:43 -0500 Subject: [PATCH 93/99] clean up --- CMakeLists.txt | 0 selfdrive/controls/controlsd.py | 10 +++------- selfdrive/controls/lib/events.py | 2 +- selfdrive/debug/cycle_alerts.py | 1 + selfdrive/ui/ui.cc | 20 +------------------- 5 files changed, 6 insertions(+), 27 deletions(-) delete mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index b2cca0cd742bc6..d68f5cb1f65682 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -279,13 +279,9 @@ def add_stock_additions_alerts(self, CS): frame = self.sm.frame # alert priority is defined by code location, keeping is highest, then lane speed alert, then auto-df alert if self.sm_smiskol['modelLongButton'].enabled != self.last_model_long: - if self.last_model_long: - extra_text_1 = 'disabled!' - extra_text_2 = '' - else: - extra_text_1 = 'enabled!' - extra_text_2 = 'Remain alert' - self.AM.add_custom(frame, 'modelLongAlert', ET.WARNING, self.enabled, extra_text_1=extra_text_1, extra_text_2=extra_text_2) + extra_text_1 = 'disabled!' if self.last_model_long else 'enabled!' + self.AM.add_custom(frame, 'modelLongAlert', ET.WARNING, self.enabled, extra_text_1=extra_text_1) + return if self.sm_smiskol['dynamicCameraOffset'].keepingLeft: self.AM.add_custom(frame, 'laneSpeedKeeping', ET.WARNING, self.enabled, extra_text_1='LEFT', extra_text_2='Oncoming traffic in right lane') diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 4e5ab5dcffbfdd..af0eacd4ce2060 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -528,7 +528,7 @@ def wrong_car_mode_alert(CP, sm, metric): "modelLongAlert": { ET.WARNING: Alert( "Model longitudinal ", - "", + "Remain alert", AlertStatus.normal, AlertSize.mid, Priority.LOW, VisualAlert.none, AudibleAlert.chimeWarning1, .4, 0., 2.), }, diff --git a/selfdrive/debug/cycle_alerts.py b/selfdrive/debug/cycle_alerts.py index 11d6c28381cc22..63b7d758c5901f 100755 --- a/selfdrive/debug/cycle_alerts.py +++ b/selfdrive/debug/cycle_alerts.py @@ -10,6 +10,7 @@ from selfdrive.controls.lib.events import EVENTS, Alert def now_millis(): return time.time() * 1000 + ALERTS = [a for _, et in EVENTS.items() for _, a in et.items() if isinstance(a, Alert)] #from cereal import car diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index fd69d7338ca8a0..e5aeb395a6a363 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -122,7 +122,6 @@ static bool handle_ls_touch(UIState *s, int touch_x, int touch_y) { int btn_x_1 = 1660 - 200; int btn_x_2 = 1660 - 50; if ((btn_x_1 - padding <= touch_x) && (touch_x <= btn_x_2 + padding) && (855 - padding <= touch_y)) { - printf("ls button touched!\n"); s->scene.lsButtonStatus++; if (s->scene.lsButtonStatus > 2) { s->scene.lsButtonStatus = 0; @@ -139,7 +138,6 @@ static bool handle_df_touch(UIState *s, int touch_x, int touch_y) { if ((s->awake && s->vision_connected && s->status != STATUS_STOPPED) || s->ui_debug) { int padding = 40; if ((1660 - padding <= touch_x) && (855 - padding <= touch_y)) { - printf("df button touched!\n"); s->scene.dfButtonStatus++; if (s->scene.dfButtonStatus > 3) { s->scene.dfButtonStatus = 0; @@ -160,7 +158,6 @@ static bool handle_ml_touch(UIState *s, int touch_x, int touch_y) { int xs[2] = {1920 / 2 - btn_w / 2, 1920 / 2 + btn_w / 2}; int y_top = 915 - btn_h / 2; if (xs[0] <= touch_x + padding && touch_x - padding <= xs[1] && y_top - padding <= touch_y) { - printf("ml button touched!\n"); s->scene.mlButtonEnabled = !s->scene.mlButtonEnabled; send_ml(s, s->scene.mlButtonEnabled); return true; @@ -260,7 +257,7 @@ static void ui_init(UIState *s) { s->scene.satelliteCount = -1; s->started = false; s->vision_seen = false; - s->ui_debug = true; // change to true while debugging + s->ui_debug = false; // change to true while debugging // init display s->fb = framebuffer_init("ui", 0, true, &s->fb_w, &s->fb_h); @@ -835,23 +832,8 @@ int main(int argc, char* argv[]) { int draws = 0; - bool debug_ui = false; - if (argc == 2) { - if (strcmp(argv[1], "debug") == 0) { - debug_ui = true; - } - } - while (!do_exit) { bool should_swap = false; - if (debug_ui) { - s->started = true; - s->status = STATUS_DISENGAGED; - s->controls_seen = true; - s->vision_seen = true; - s->active_app = cereal::UiLayoutState::App::NONE; - s->controls_timeout = UI_FREQ; - } if (!s->started) { // Delay a while to avoid 9% cpu usage while car is not started and user is keeping touching on the screen. // Don't hold the lock while sleeping, so that vision_connect_thread have chances to get the lock. From 185b9f612f08f10f6cc8b5f11e92015a5583b368 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 05:21:17 -0500 Subject: [PATCH 94/99] clean up --- selfdrive/ui/paint.cc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/selfdrive/ui/paint.cc b/selfdrive/ui/paint.cc index e63b88d4a48eb7..491430409582c4 100644 --- a/selfdrive/ui/paint.cc +++ b/selfdrive/ui/paint.cc @@ -662,20 +662,13 @@ static void ui_draw_df_button(UIState *s) { } static void ui_draw_ml_button(UIState *s) { -// int test_button = nvgCreateImage(s->vg, "../assets/images/button_settings.png", 1); - int btn_w = 500; int btn_h = 138; -// int y_padding = 100; -// int btn_x = 1027 - btn_w / 2; // 150 + 50 padding -// int btn_y = 980 - btn_h / 2 - y_padding; int x = 1920 / 2; int y = 915; int btn_x = x - btn_w / 2; int btn_y = y - btn_h / 2; -// ui_draw_image(s->vg, btn_x, btn_y, btn_w, btn_h, test_button, 1.0f); - nvgBeginPath(s->vg); nvgRoundedRect(s->vg, btn_x, btn_y, btn_w, btn_h, 25); if (s->scene.mlButtonEnabled) { // change outline color based on status of button @@ -694,10 +687,6 @@ static void ui_draw_ml_button(UIState *s) { nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); nvgFontSize(s->vg, 65); nvgText(s->vg, x, y + btn_h / 8, "Toggle Model Long", NULL); -// -// nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 255)); -// nvgFontSize(s->vg, 45); -// nvgText(s->vg, btn_x - 34, btn_y + 50 + 15, "mode", NULL); } static void ui_draw_vision_header(UIState *s) { From a7c06d70a7f19c6ad158e0261e87547b4b012895 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 22:39:37 -0500 Subject: [PATCH 95/99] add uiview --- selfdrive/ui/ui_debug | 1 + selfdrive/ui/uiview.py | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100755 selfdrive/ui/ui_debug create mode 100644 selfdrive/ui/uiview.py diff --git a/selfdrive/ui/ui_debug b/selfdrive/ui/ui_debug new file mode 100755 index 00000000000000..e02cbf0cf8cf87 --- /dev/null +++ b/selfdrive/ui/ui_debug @@ -0,0 +1 @@ +python ./uiview.py diff --git a/selfdrive/ui/uiview.py b/selfdrive/ui/uiview.py new file mode 100644 index 00000000000000..bdaeb1644dcc57 --- /dev/null +++ b/selfdrive/ui/uiview.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +import os +import sys +import time +import signal +import subprocess +import multiprocessing +import cereal.messaging as messaging + +from common.params import Params +from common.basedir import BASEDIR + +KILL_TIMEOUT = 15 + + +def send_controls_packet(pm): + while True: + dat = messaging.new_message('controlsState') + dat.controlsState.rearViewCam = False + pm.send('controlsState', dat) + time.sleep(1 / 100.) + + +def send_thermal_packet(pm): + while True: + dat = messaging.new_message('thermal') + dat.thermal.started = True + pm.send('thermal', dat) + time.sleep(1 / 2.) # 2 hz + + +def main(): + pm = messaging.PubMaster(['controlsState', 'thermal']) + + controls_sender = multiprocessing.Process(target=send_controls_packet, args=[pm]) + controls_sender.start() + thermal_sender = multiprocessing.Process(target=send_thermal_packet, args=[pm]) + thermal_sender.start() + + # TODO: refactor with manager start/kill + proc_cam = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/camerad/camerad"), cwd=os.path.join(BASEDIR, "selfdrive/camerad")) + proc_ui = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/ui/ui"), cwd=os.path.join(BASEDIR, "selfdrive/ui")) + + def terminate(signalNumber, frame): + print('got SIGTERM, exiting..') + proc_cam.send_signal(signal.SIGINT) + kill_start = time.time() + while proc_cam.poll() is None: + if time.time() - kill_start > KILL_TIMEOUT: + from selfdrive.swaglog import cloudlog + cloudlog.critical("FORCE REBOOTING PHONE!") + os.system("date >> /sdcard/unkillable_reboot") + os.system("reboot") + raise RuntimeError + continue + proc_ui.send_signal(signal.SIGINT) + thermal_sender.terminate() + controls_sender.terminate() + exit() + + signal.signal(signal.SIGTERM, terminate) + signal.signal(signal.SIGINT, terminate) # catch ctrl-c as well + + +if __name__ == '__main__': + main() From 6969214ff0de9156fc443ef0c01a8e7a8d2f6988 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 22:42:59 -0500 Subject: [PATCH 96/99] don't need this --- selfdrive/ui/uiview.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/selfdrive/ui/uiview.py b/selfdrive/ui/uiview.py index bdaeb1644dcc57..37be520362e5ad 100644 --- a/selfdrive/ui/uiview.py +++ b/selfdrive/ui/uiview.py @@ -1,13 +1,11 @@ #!/usr/bin/env python3 import os -import sys import time import signal import subprocess import multiprocessing import cereal.messaging as messaging -from common.params import Params from common.basedir import BASEDIR KILL_TIMEOUT = 15 @@ -31,7 +29,6 @@ def send_thermal_packet(pm): def main(): pm = messaging.PubMaster(['controlsState', 'thermal']) - controls_sender = multiprocessing.Process(target=send_controls_packet, args=[pm]) controls_sender.start() thermal_sender = multiprocessing.Process(target=send_thermal_packet, args=[pm]) @@ -44,15 +41,6 @@ def main(): def terminate(signalNumber, frame): print('got SIGTERM, exiting..') proc_cam.send_signal(signal.SIGINT) - kill_start = time.time() - while proc_cam.poll() is None: - if time.time() - kill_start > KILL_TIMEOUT: - from selfdrive.swaglog import cloudlog - cloudlog.critical("FORCE REBOOTING PHONE!") - os.system("date >> /sdcard/unkillable_reboot") - os.system("reboot") - raise RuntimeError - continue proc_ui.send_signal(signal.SIGINT) thermal_sender.terminate() controls_sender.terminate() From 0799a656cafe5b507ff0a2db8b66ef783c43e47a Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 22:46:13 -0500 Subject: [PATCH 97/99] remove uiview --- selfdrive/ui/ui_debug | 1 - selfdrive/ui/uiview.py | 54 ------------------------------------------ 2 files changed, 55 deletions(-) delete mode 100755 selfdrive/ui/ui_debug delete mode 100644 selfdrive/ui/uiview.py diff --git a/selfdrive/ui/ui_debug b/selfdrive/ui/ui_debug deleted file mode 100755 index e02cbf0cf8cf87..00000000000000 --- a/selfdrive/ui/ui_debug +++ /dev/null @@ -1 +0,0 @@ -python ./uiview.py diff --git a/selfdrive/ui/uiview.py b/selfdrive/ui/uiview.py deleted file mode 100644 index 37be520362e5ad..00000000000000 --- a/selfdrive/ui/uiview.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -import os -import time -import signal -import subprocess -import multiprocessing -import cereal.messaging as messaging - -from common.basedir import BASEDIR - -KILL_TIMEOUT = 15 - - -def send_controls_packet(pm): - while True: - dat = messaging.new_message('controlsState') - dat.controlsState.rearViewCam = False - pm.send('controlsState', dat) - time.sleep(1 / 100.) - - -def send_thermal_packet(pm): - while True: - dat = messaging.new_message('thermal') - dat.thermal.started = True - pm.send('thermal', dat) - time.sleep(1 / 2.) # 2 hz - - -def main(): - pm = messaging.PubMaster(['controlsState', 'thermal']) - controls_sender = multiprocessing.Process(target=send_controls_packet, args=[pm]) - controls_sender.start() - thermal_sender = multiprocessing.Process(target=send_thermal_packet, args=[pm]) - thermal_sender.start() - - # TODO: refactor with manager start/kill - proc_cam = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/camerad/camerad"), cwd=os.path.join(BASEDIR, "selfdrive/camerad")) - proc_ui = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/ui/ui"), cwd=os.path.join(BASEDIR, "selfdrive/ui")) - - def terminate(signalNumber, frame): - print('got SIGTERM, exiting..') - proc_cam.send_signal(signal.SIGINT) - proc_ui.send_signal(signal.SIGINT) - thermal_sender.terminate() - controls_sender.terminate() - exit() - - signal.signal(signal.SIGTERM, terminate) - signal.signal(signal.SIGINT, terminate) # catch ctrl-c as well - - -if __name__ == '__main__': - main() From e925ef4ebb7ee92232495b03702908865ef4614f Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 22:55:55 -0500 Subject: [PATCH 98/99] add back --- selfdrive/ui/uiview.py | 54 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 selfdrive/ui/uiview.py diff --git a/selfdrive/ui/uiview.py b/selfdrive/ui/uiview.py new file mode 100644 index 00000000000000..37be520362e5ad --- /dev/null +++ b/selfdrive/ui/uiview.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import os +import time +import signal +import subprocess +import multiprocessing +import cereal.messaging as messaging + +from common.basedir import BASEDIR + +KILL_TIMEOUT = 15 + + +def send_controls_packet(pm): + while True: + dat = messaging.new_message('controlsState') + dat.controlsState.rearViewCam = False + pm.send('controlsState', dat) + time.sleep(1 / 100.) + + +def send_thermal_packet(pm): + while True: + dat = messaging.new_message('thermal') + dat.thermal.started = True + pm.send('thermal', dat) + time.sleep(1 / 2.) # 2 hz + + +def main(): + pm = messaging.PubMaster(['controlsState', 'thermal']) + controls_sender = multiprocessing.Process(target=send_controls_packet, args=[pm]) + controls_sender.start() + thermal_sender = multiprocessing.Process(target=send_thermal_packet, args=[pm]) + thermal_sender.start() + + # TODO: refactor with manager start/kill + proc_cam = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/camerad/camerad"), cwd=os.path.join(BASEDIR, "selfdrive/camerad")) + proc_ui = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/ui/ui"), cwd=os.path.join(BASEDIR, "selfdrive/ui")) + + def terminate(signalNumber, frame): + print('got SIGTERM, exiting..') + proc_cam.send_signal(signal.SIGINT) + proc_ui.send_signal(signal.SIGINT) + thermal_sender.terminate() + controls_sender.terminate() + exit() + + signal.signal(signal.SIGTERM, terminate) + signal.signal(signal.SIGINT, terminate) # catch ctrl-c as well + + +if __name__ == '__main__': + main() From d1031531c479a64a88184bb9b3b11014a02418a5 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Fri, 24 Jul 2020 22:56:44 -0500 Subject: [PATCH 99/99] remove --- selfdrive/ui/uiview.py | 54 ------------------------------------------ 1 file changed, 54 deletions(-) delete mode 100644 selfdrive/ui/uiview.py diff --git a/selfdrive/ui/uiview.py b/selfdrive/ui/uiview.py deleted file mode 100644 index 37be520362e5ad..00000000000000 --- a/selfdrive/ui/uiview.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -import os -import time -import signal -import subprocess -import multiprocessing -import cereal.messaging as messaging - -from common.basedir import BASEDIR - -KILL_TIMEOUT = 15 - - -def send_controls_packet(pm): - while True: - dat = messaging.new_message('controlsState') - dat.controlsState.rearViewCam = False - pm.send('controlsState', dat) - time.sleep(1 / 100.) - - -def send_thermal_packet(pm): - while True: - dat = messaging.new_message('thermal') - dat.thermal.started = True - pm.send('thermal', dat) - time.sleep(1 / 2.) # 2 hz - - -def main(): - pm = messaging.PubMaster(['controlsState', 'thermal']) - controls_sender = multiprocessing.Process(target=send_controls_packet, args=[pm]) - controls_sender.start() - thermal_sender = multiprocessing.Process(target=send_thermal_packet, args=[pm]) - thermal_sender.start() - - # TODO: refactor with manager start/kill - proc_cam = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/camerad/camerad"), cwd=os.path.join(BASEDIR, "selfdrive/camerad")) - proc_ui = subprocess.Popen(os.path.join(BASEDIR, "selfdrive/ui/ui"), cwd=os.path.join(BASEDIR, "selfdrive/ui")) - - def terminate(signalNumber, frame): - print('got SIGTERM, exiting..') - proc_cam.send_signal(signal.SIGINT) - proc_ui.send_signal(signal.SIGINT) - thermal_sender.terminate() - controls_sender.terminate() - exit() - - signal.signal(signal.SIGTERM, terminate) - signal.signal(signal.SIGINT, terminate) # catch ctrl-c as well - - -if __name__ == '__main__': - main()