From beae7b60091660447a13e1efb527d60c9db46232 Mon Sep 17 00:00:00 2001 From: Vehicle Researcher Date: Mon, 22 May 2017 22:26:12 -0700 Subject: [PATCH] openpilot v0.3.2 release old-commit-hash: 7fe46f1e1df5dec08a940451ba0feefd5c039165 --- .gitignore | 1 + RELEASES.md | 13 ++++++++- apk/com.baseui.apk | 4 +-- cereal/log.capnp | 12 ++++++++ common/params.py | 4 +++ selfdrive/car/honda/carcontroller.py | 4 +++ selfdrive/car/honda/hondacan.py | 2 +- selfdrive/common/params.c | 5 ++++ selfdrive/common/version.h | 2 +- selfdrive/controls/controlsd.py | 12 ++++---- selfdrive/controls/plannerd.py | 1 + selfdrive/loggerd/config.py | 2 +- selfdrive/loggerd/loggerd | 4 +-- selfdrive/loggerd/uploader.py | 4 +-- selfdrive/manager.py | 41 +++++++++++++++++++++++----- selfdrive/service_list.yaml | 1 + selfdrive/tombstoned.py | 1 + selfdrive/ui/ui.c | 41 ++++++++++++++++++++++------ selfdrive/visiond/visiond | 4 +-- 19 files changed, 125 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index aad9fecc55..726686a4e2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ model2.png *.a *.clb *.class +*.pyxbldc config.json clcache diff --git a/RELEASES.md b/RELEASES.md index 6b636e0591..bed69aaf30 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,4 +1,15 @@ -Version 0.3.0 (2017-03-xx) +Version 0.3.2 (2017-05-22) +=========================== + * Minor stability bugfixes + * Added metrics and rear view mirror disable to settings + * Update model with more crowdsourced data + +Version 0.3.1 (2017-05-17) +=========================== + * visiond stability bugfix + * Add logging for angle and flashing + +Version 0.3.0 (2017-05-12) =========================== * Add CarParams struct to improve the abstraction layer * Refactor visiond IPC to support multiple clients diff --git a/apk/com.baseui.apk b/apk/com.baseui.apk index dc34734b92..fa9a37627a 100644 --- a/apk/com.baseui.apk +++ b/apk/com.baseui.apk @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:84da6150714d2069367c3cc9591b795cd33b218635000e79e1c031e9c0232039 -size 8987577 +oid sha256:a18e2a4e7077cd7fa082a0617a433283dde9acd2ec1ee5c6f00bf57679c8bf05 +size 8994047 diff --git a/cereal/log.capnp b/cereal/log.capnp index bc7a0f03ed..9f50317e35 100644 --- a/cereal/log.capnp +++ b/cereal/log.capnp @@ -31,6 +31,10 @@ struct InitData { androidSensors @6 :List(AndroidSensor); chffrAndroidExtra @7 :ChffrAndroidExtra; + pandaInfo @8 :PandaInfo; + + dirty @9 :Bool; + enum DeviceType { unknown @0; neo @1; @@ -84,6 +88,13 @@ struct InitData { struct ChffrAndroidExtra { allCameraCharacteristics @0 :Map(Text, Text); } + + struct PandaInfo { + hasPanda @0: Bool; + dongleId @1: Text; + stVersion @2: Text; + espVersion @3: Text; + } } struct FrameData { @@ -411,6 +422,7 @@ struct Plan { aTargetMin @4 :Float32; aTargetMax @5 :Float32; jerkFactor @6 :Float32; + hasLead @7 :Bool; } struct LiveLocationData { diff --git a/common/params.py b/common/params.py index 6f58901f65..b889d7193a 100755 --- a/common/params.py +++ b/common/params.py @@ -52,6 +52,10 @@ keys = { "Version": TxType.PERSISTANT, "GitCommit": TxType.PERSISTANT, "GitBranch": TxType.PERSISTANT, +# written: baseui +# read: ui, controls + "IsMetric": TxType.PERSISTANT, + "IsRearViewMirror": TxType.PERSISTANT, # written: visiond # read: visiond "CalibrationParams": TxType.PERSISTANT, diff --git a/selfdrive/car/honda/carcontroller.py b/selfdrive/car/honda/carcontroller.py index 21fd6c6509..d394574e26 100644 --- a/selfdrive/car/honda/carcontroller.py +++ b/selfdrive/car/honda/carcontroller.py @@ -87,6 +87,10 @@ class CarController(object): snd_beep, snd_chime): """ Controls thread """ + # TODO: Make the accord work. + if CS.accord: + return + # *** apply brake hysteresis *** final_brake, self.braking, self.brake_steady = actuator_hystereses(final_brake, self.braking, self.brake_steady, CS.v_ego, CS.civic) diff --git a/selfdrive/car/honda/hondacan.py b/selfdrive/car/honda/hondacan.py index 3af33de929..f0c9d3347a 100644 --- a/selfdrive/car/honda/hondacan.py +++ b/selfdrive/car/honda/hondacan.py @@ -50,7 +50,7 @@ def create_accord_steering_control(apply_steer, idx): dat = [0, 0, 0x40, 0] else: dat = [0,0,0,0] - rp = clip(apply_steer/0xF, -0xFF, 0xFF) + rp = np.clip(apply_steer/0xF, -0xFF, 0xFF) if rp < 0: rp += 512 dat[0] |= (rp >> 5) & 0xf diff --git a/selfdrive/common/params.c b/selfdrive/common/params.c index 0fc8cc53f6..f90b171fca 100644 --- a/selfdrive/common/params.c +++ b/selfdrive/common/params.c @@ -49,7 +49,12 @@ int write_db_value(const char* params_path, const char* key, const char* value, // Move temp into place. result = rename(tmp_path, path); + if (result < 0) { + goto cleanup; + } + // fsync to force persist the changes. + result = fsync(tmp_fd); cleanup: // Release lock. if (lock_fd >= 0) { diff --git a/selfdrive/common/version.h b/selfdrive/common/version.h index 5176e9eca5..bcb84bcacc 100644 --- a/selfdrive/common/version.h +++ b/selfdrive/common/version.h @@ -1 +1 @@ -const char *openpilot_version = "0.3.1"; +const char *openpilot_version = "0.3.2"; diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 464e231d0a..bebc2037dc 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -52,7 +52,8 @@ def controlsd_thread(gctx, rate=100): #rate in Hz CI = CarInterface(CP, logcan, sendcan) # write CarParams - Params().put("CarParams", CP.to_bytes()) + params = Params() + params.put("CarParams", CP.to_bytes()) AM = AlertManager() @@ -74,6 +75,7 @@ def controlsd_thread(gctx, rate=100): #rate in Hz # rear view camera state rear_view_toggle = False + rear_view_allowed = bool(params.get("IsRearViewMirror")) v_cruise_kph = 255 @@ -127,7 +129,7 @@ def controlsd_thread(gctx, rate=100): #rate in Hz # button presses for rear view if b.type == "leftBlinker" or b.type == "rightBlinker": - if b.pressed: + if b.pressed and rear_view_allowed: rear_view_toggle = True else: rear_view_toggle = False @@ -318,9 +320,7 @@ def controlsd_thread(gctx, rate=100): #rate in Hz CC.hudControl.setSpeed = float(v_cruise_kph * CV.KPH_TO_MS) CC.hudControl.speedVisible = enabled CC.hudControl.lanesVisible = enabled - #CC.hudControl.leadVisible = bool(AC.has_lead) - # TODO: fix this - CC.hudControl.leadVisible = False + CC.hudControl.leadVisible = plan.hasLead CC.hudControl.visualAlert = visual_alert CC.hudControl.audibleAlert = audible_alert @@ -344,7 +344,7 @@ def controlsd_thread(gctx, rate=100): #rate in Hz dat.init('live100') # show rear view camera on phone if in reverse gear or when button is pressed - dat.live100.rearViewCam = ('reverseGear' in CS.errors) or rear_view_toggle + dat.live100.rearViewCam = ('reverseGear' in CS.errors and rear_view_allowed) or rear_view_toggle dat.live100.alertText1 = alert_text_1 dat.live100.alertText2 = alert_text_2 dat.live100.awarenessStatus = max(awareness_status, 0.0) if enabled else 0.0 diff --git a/selfdrive/controls/plannerd.py b/selfdrive/controls/plannerd.py index 34594309e1..692a770636 100755 --- a/selfdrive/controls/plannerd.py +++ b/selfdrive/controls/plannerd.py @@ -68,6 +68,7 @@ def plannerd_thread(gctx): plan_send.plan.aTargetMin = float(AC.a_target[0]) plan_send.plan.aTargetMax = float(AC.a_target[1]) plan_send.plan.jerkFactor = float(AC.jerk_factor) + plan_send.plan.hasLead = AC.has_lead plan.send(plan_send.to_bytes()) diff --git a/selfdrive/loggerd/config.py b/selfdrive/loggerd/config.py index be22c2057b..0759ae2663 100644 --- a/selfdrive/loggerd/config.py +++ b/selfdrive/loggerd/config.py @@ -1,4 +1,4 @@ import os -ROOT = '/sdcard/realdata/' +ROOT = '/data/media/0/realdata/' SEGMENT_LENGTH = 60 diff --git a/selfdrive/loggerd/loggerd b/selfdrive/loggerd/loggerd index ecd70bd49c..f6458ffb0f 100755 --- a/selfdrive/loggerd/loggerd +++ b/selfdrive/loggerd/loggerd @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:11b28827b7523063614eb82cc2ecd10f015b832eceadf6eaad968bedae9c443e -size 1357136 +oid sha256:c74d6aaf1167f0820dc6b7949870bae14ae1b5ebb9fd70e24dfdcea369475ee5 +size 1357296 diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index ccaf632528..1eafa40912 100755 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -208,7 +208,7 @@ class Uploader(object): cloudlog.info("uploading %r", fn) # stat = self.killable_upload(key, fn) stat = self.normal_upload(key, fn) - if stat is not None and stat.status_code == 200: + if stat is not None and stat.status_code in (200, 201): cloudlog.event("upload_success", key=key, fn=fn, sz=sz) os.unlink(fn) # delete the file success = True @@ -254,7 +254,7 @@ def uploader_fn(exit_event): else: cloudlog.info("backoff %r", backoff) time.sleep(backoff + random.uniform(0, backoff)) - backoff *= 2 + backoff = min(backoff*2, 120) cloudlog.info("upload done, success=%r", success) time.sleep(5) diff --git a/selfdrive/manager.py b/selfdrive/manager.py index bc3dbb2d54..cc29dfd7c6 100755 --- a/selfdrive/manager.py +++ b/selfdrive/manager.py @@ -3,7 +3,9 @@ import os # check if NEOS update is required while 1: - if (not os.path.isfile("/VERSION") or int(open("/VERSION").read()) < 3) and not os.path.isfile("/sdcard/noupdate"): + if ((not os.path.isfile("/VERSION") + or int(open("/VERSION").read()) < 3) + and not os.path.isfile("/data/media/0/noupdate")): os.system("curl -o /tmp/updater https://openpilot.comma.ai/updater && chmod +x /tmp/updater && /tmp/updater") else: break @@ -183,15 +185,34 @@ def manager_init(): cloudlog.info("dongle id is " + dongle_id) os.environ['DONGLE_ID'] = dongle_id + dirty = subprocess.call(["git", "diff-index", "--quiet", "origin/release", "--"]) != 0 + cloudlog.info("dirty is %d" % dirty) + if not dirty: + os.environ['CLEAN'] = '1' + cloudlog.bind_global(dongle_id=dongle_id, version=version) crash.bind_user(id=dongle_id) - crash.bind_extra(version=version) + crash.bind_extra(version=version, dirty=dirty) - os.system("mkdir -p "+ROOT) + os.umask(0) + try: + os.mkdir(ROOT, 0777) + except OSError: + pass # set gctx gctx = {} +def system(cmd): + try: + cloudlog.info("running %s" % cmd) + subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) + except subprocess.CalledProcessError, e: + cloudlog.event("running failed", + cmd=e.cmd, + output=e.output, + returncode=e.returncode) + def manager_thread(): global baseui_running @@ -219,14 +240,13 @@ def manager_thread(): if os.getenv("NOPROG") is None: # checkout the matching panda repo rootdir = os.path.dirname(os.path.abspath(__file__)) - ret = os.system("cd %s && git submodule init && git submodule update" % rootdir) - cloudlog.info("git submodule update panda returned %d" % ret) + system("cd %s && git submodule init" % rootdir) + system("cd %s && git submodule update" % rootdir) # flash the board boarddir = os.path.dirname(os.path.abspath(__file__))+"/../panda/board/" mkfile = "Makefile" if panda else "Makefile.legacy" print "using", mkfile - ret = os.system("cd %s && make -f %s" % (boarddir, mkfile)) - cloudlog.info("flash board returned %d" % ret) + system("cd %s && make -f %s" % (boarddir, mkfile)) start_managed_process("boardd") @@ -421,6 +441,13 @@ def main(): params = Params() params.manager_start() + + # set unset params + if params.get("IsMetric") is None: + params.put("IsMetric", "0") + if params.get("IsRearViewMirror") is None: + params.put("IsRearViewMirror", "1") + manager_init() manager_prepare() diff --git a/selfdrive/service_list.yaml b/selfdrive/service_list.yaml index d8293d06ab..b0adabad8d 100644 --- a/selfdrive/service_list.yaml +++ b/selfdrive/service_list.yaml @@ -41,6 +41,7 @@ navUpdate: [8028, true] qcomGnss: [8029, true] lidarPts: [8030, true] procLog: [8031, true] +testModel: [8040, false] # manager -- base process to manage starting and stopping of all others # subscribes: health diff --git a/selfdrive/tombstoned.py b/selfdrive/tombstoned.py index 9c69517502..ec56f9c69a 100644 --- a/selfdrive/tombstoned.py +++ b/selfdrive/tombstoned.py @@ -56,6 +56,7 @@ def report_tombstone(fn, client): 'backtrace': parsedict.get('backtrace'), 'logtail': logtail, 'version': version, + 'dirty': not bool(os.environ.get('CLEAN')), }, user={'id': os.environ.get('DONGLE_ID')}, message=message, diff --git a/selfdrive/ui/ui.c b/selfdrive/ui/ui.c index c8b2cc0c6f..63459de4a4 100644 --- a/selfdrive/ui/ui.c +++ b/selfdrive/ui/ui.c @@ -122,6 +122,8 @@ typedef struct UIState { bool awake; int awake_timeout; + + bool is_metric; } UIState; static void set_awake(UIState *s, bool awake) { @@ -342,6 +344,13 @@ static void ui_init_vision(UIState *s, const VisionStreamBufs back_bufs, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, }}; + + char *value; + const int result = read_db_value("/data/params", "IsMetric", &value, NULL); + if (result == 0) { + s->is_metric = value[0] == '1'; + free(value); + } } static void ui_update_frame(UIState *s) { @@ -621,9 +630,15 @@ static void ui_draw_world(UIState *s) { if (scene->lead_status) { char radar_str[16]; - int lead_v_rel = (int)(2.236 * scene->lead_v_rel); - snprintf(radar_str, sizeof(radar_str), "%3d m %+d mph", - (int)(scene->lead_d_rel), lead_v_rel); + if (s->is_metric) { + int lead_v_rel = (int)(3.6 * scene->lead_v_rel); + snprintf(radar_str, sizeof(radar_str), "%3d m %+d kph", + (int)(scene->lead_d_rel), lead_v_rel); + } else { + int lead_v_rel = (int)(2.236 * scene->lead_v_rel); + snprintf(radar_str, sizeof(radar_str), "%3d m %+d mph", + (int)(scene->lead_d_rel), lead_v_rel); + } nvgFontSize(s->vg, 96.0f); nvgFillColor(s->vg, nvgRGBA(128, 128, 0, 192)); nvgTextAlign(s->vg, NVG_ALIGN_CENTER | NVG_ALIGN_TOP); @@ -670,16 +685,26 @@ static void ui_draw_vision(UIState *s) { } if (scene->v_cruise != 255 && scene->v_cruise != 0) { - // Convert KPH to MPH. - snprintf(speed_str, sizeof(speed_str), "%3d MPH", - (int)(scene->v_cruise * 0.621371 + 0.5)); + if (s->is_metric) { + snprintf(speed_str, sizeof(speed_str), "%3d KPH", + (int)(scene->v_cruise + 0.5)); + } else { + // Convert KPH to MPH. + snprintf(speed_str, sizeof(speed_str), "%3d MPH", + (int)(scene->v_cruise * 0.621371 + 0.5)); + } nvgTextAlign(s->vg, NVG_ALIGN_RIGHT | NVG_ALIGN_BASELINE); nvgText(s->vg, 500, 150, speed_str, NULL); } nvgFillColor(s->vg, nvgRGBA(255, 255, 255, 192)); - snprintf(speed_str, sizeof(speed_str), "%3d MPH", - (int)(scene->v_ego * 2.237 + 0.5)); + if (s->is_metric) { + snprintf(speed_str, sizeof(speed_str), "%3d KPH", + (int)(scene->v_ego * 3.6 + 0.5)); + } else { + snprintf(speed_str, sizeof(speed_str), "%3d MPH", + (int)(scene->v_ego * 2.237 + 0.5)); + } nvgTextAlign(s->vg, NVG_ALIGN_LEFT | NVG_ALIGN_BASELINE); nvgText(s->vg, 1920 - 500, 150, speed_str, NULL); diff --git a/selfdrive/visiond/visiond b/selfdrive/visiond/visiond index 8f8b7785f8..89c4e9e240 100755 --- a/selfdrive/visiond/visiond +++ b/selfdrive/visiond/visiond @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9fd4388fc4387cc933d415d8e5c1e09de966b41b6666234f88ee6f10eb51c840 -size 16373480 +oid sha256:479641365cc5b1a4acb72f57aa82bcd029b596ec98027a920fda0092009d6178 +size 16374520