From 85171c28fcec50e8dd358f86d15693688c228013 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Sun, 18 Mar 2018 10:36:29 -0700 Subject: [PATCH] openpilot v0.4.3 release old-commit-hash: 51fad4a6c6b275bee269b0e76b6c0c29d9136847 --- apk/ai.comma.plus.offroad.apk | 4 +- selfdrive/controls/controlsd.py | 13 ++-- selfdrive/controls/lib/alertmanager.py | 2 +- selfdrive/loggerd/uploader.py | 0 selfdrive/ui/ui.c | 94 +++++++++++++------------- 5 files changed, 57 insertions(+), 56 deletions(-) mode change 100755 => 100644 selfdrive/loggerd/uploader.py diff --git a/apk/ai.comma.plus.offroad.apk b/apk/ai.comma.plus.offroad.apk index 6003b14fa6..b9f3e40c75 100644 --- a/apk/ai.comma.plus.offroad.apk +++ b/apk/ai.comma.plus.offroad.apk @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ee3fcae5727530b008d40adf962bb5fac2f7c2b42745408b65f316c112905a6 -size 15385883 +oid sha256:d994ff54de0a618538a9ada328dc6196604f22a3a25051fe8e477390be29d28a +size 15407210 diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 89703f9bfd..a66d4871b0 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -211,7 +211,8 @@ def state_transition(CS, CP, state, events, soft_disable_timer, v_cruise_kph, AM def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, AM, rk, - awareness_status, PL, LaC, LoC, VM, angle_offset, rear_view_allowed, rear_view_toggle): + awareness_status, PL, LaC, LoC, VM, angle_offset, rear_view_allowed, + rear_view_toggle, passive): # Given the state, this function returns the actuators # reset actuators to zero @@ -228,7 +229,7 @@ def state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, else: rear_view_toggle = False - if b.type == "altButton1" and b.pressed: + if (b.type == "altButton1" and b.pressed) and not passive: rear_view_toggle = not rear_view_toggle @@ -454,14 +455,14 @@ def controlsd_thread(gctx, rate=100): CI, CP = get_car(logcan, sendcan, 1.0 if passive else None) + if CI is None: + raise Exception("unsupported car") + # if stock camera is connected, then force passive behavior if not CP.enableCamera: passive = True sendcan = None - if CI is None: - raise Exception("unsupported car") - if passive: CP.safetyModel = car.CarParams.SafetyModels.noOutput @@ -528,7 +529,7 @@ def controlsd_thread(gctx, rate=100): # compute actuators actuators, v_cruise_kph, awareness_status, angle_offset, rear_view_toggle = state_control(plan, CS, CP, state, events, v_cruise_kph, v_cruise_kph_last, AM, rk, awareness_status, PL, LaC, LoC, VM, - angle_offset, rear_view_allowed, rear_view_toggle) + angle_offset, rear_view_allowed, rear_view_toggle, passive) prof.checkpoint("State Control") # publish data diff --git a/selfdrive/controls/lib/alertmanager.py b/selfdrive/controls/lib/alertmanager.py index 5c82c240c9..8c22a6166a 100644 --- a/selfdrive/controls/lib/alertmanager.py +++ b/selfdrive/controls/lib/alertmanager.py @@ -121,7 +121,7 @@ class AlertManager(object): "manualRestart": Alert( "TAKE CONTROL", "Resume driving manually", - AlertStatus.userPrompt, AlertSize.full, + AlertStatus.userPrompt, AlertSize.mid, Priority.LOW, None, None, 0., 0., .2), # Non-entry only alerts diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py old mode 100755 new mode 100644 diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index b6d1c26107..4c19308723 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -309,7 +309,7 @@ static const mat4 device_transform = {{ // frame from 4/3 to box size with a 2x zoon static const mat4 frame_transform = {{ - 2*(4./3.)/((float)(box_w+sbr_w-(bdr_s*2))/viz_h), 0.0, 0.0, 0.0, + 2*(4./3.)/((float)box_w/viz_h), 0.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, @@ -1310,10 +1310,10 @@ static void ui_draw_vision(UIState *s) { glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + // scissor for EON UI glEnable(GL_SCISSOR_TEST); - const int viewport_rw = (box_w+sbr_w-(bdr_s*2)); - glViewport(ui_viz_rx + scene->ui_frame_offset, s->fb_h-(viz_y+viz_h), viewport_rw - scene->ui_frame_offset, viz_h); glScissor(ui_viz_rx, s->fb_h-(viz_y+viz_h), ui_viz_rw, viz_h); + glViewport(ui_viz_rx, s->fb_h-(viz_y+viz_h), ui_viz_rw, viz_h); draw_frame(s); glViewport(0, 0, s->fb_w, s->fb_h); glDisable(GL_SCISSOR_TEST); @@ -1326,10 +1326,10 @@ static void ui_draw_vision(UIState *s) { nvgSave(s->vg); // hack for eon - const int inner_height = viewport_rw*9/16; + const int inner_height = ui_viz_rw*9/16; nvgScissor(s->vg, ui_viz_rx, viz_y, ui_viz_rw, viz_h); - nvgTranslate(s->vg, ui_viz_rx + scene->ui_world_offset, viz_y + (viz_h-inner_height)/2.0); - nvgScale(s->vg, (float)viewport_rw / s->fb_w, (float)inner_height / s->fb_h); + nvgTranslate(s->vg, ui_viz_rx, viz_y + (viz_h-inner_height)/2.0); + nvgScale(s->vg, (float)ui_viz_rw / s->fb_w, (float)inner_height / s->fb_h); if (!scene->frontview) { ui_draw_world(s); @@ -1342,14 +1342,11 @@ static void ui_draw_vision(UIState *s) { nvgRestore(s->vg); - // draw vision elements ui_draw_vision_header(s); - ui_draw_vision_alert(s); - - // Draw calibration progress (if needed) if (scene->cal_status == CALIBRATION_UNCALIBRATED) { ui_draw_calibration_status(s); } + ui_draw_vision_alert(s); nvgEndFrame(s->vg); glDisable(GL_BLEND); @@ -1828,6 +1825,43 @@ static void ui_update(UIState *s) { } +static int vision_subscribe(int fd, VisionPacket *rp, int type) { + int err; + LOGW("vision_subscribe type:%d", type); + + VisionPacket p1 = { + .type = VIPC_STREAM_SUBSCRIBE, + .d = { .stream_sub = { .type = type, .tbuffer = true, }, }, + }; + err = vipc_send(fd, &p1); + if (err < 0) { + close(fd); + return 0; + } + + do { + err = vipc_recv(fd, rp); + if (err <= 0) { + close(fd); + return 0; + } + + // release what we aren't ready for yet + if (rp->type == VIPC_STREAM_ACQUIRE) { + VisionPacket rep = { + .type = VIPC_STREAM_RELEASE, + .d = { .stream_rel = { + .type = rp->d.stream_acq.type, + .idx = rp->d.stream_acq.idx, + }}, + }; + vipc_send(fd, &rep); + } + } while (rp->type != VIPC_STREAM_BUFS || rp->d.stream_bufs.type != type); + + return 1; +} + static void* vision_connect_thread(void *args) { int err; @@ -1842,43 +1876,9 @@ static void* vision_connect_thread(void *args) { int fd = vipc_connect(); if (fd < 0) continue; - - - VisionPacket p1 = { - .type = VIPC_STREAM_SUBSCRIBE, - .d = { .stream_sub = { .type = VISION_STREAM_UI_BACK, .tbuffer = true, }, }, - }; - err = vipc_send(fd, &p1); - if (err < 0) { - close(fd); - continue; - } - VisionPacket p2 = { - .type = VIPC_STREAM_SUBSCRIBE, - .d = { .stream_sub = { .type = VISION_STREAM_UI_FRONT, .tbuffer = true, }, }, - }; - err = vipc_send(fd, &p2); - if (err < 0) { - close(fd); - continue; - } - - // printf("init recv\n"); - VisionPacket back_rp; - err = vipc_recv(fd, &back_rp); - if (err <= 0) { - close(fd); - continue; - } - assert(back_rp.type == VIPC_STREAM_BUFS); - VisionPacket front_rp; - err = vipc_recv(fd, &front_rp); - if (err <= 0) { - close(fd); - continue; - } - assert(front_rp.type == VIPC_STREAM_BUFS); - + VisionPacket back_rp, front_rp; + if (!vision_subscribe(fd, &back_rp, VISION_STREAM_UI_BACK)) continue; + if (!vision_subscribe(fd, &front_rp, VISION_STREAM_UI_FRONT)) continue; pthread_mutex_lock(&s->lock); assert(!s->vision_connected);