Exemple #1
0
def test_process(cfg,
                 lr,
                 ref_log_path,
                 new_log_path,
                 ignore_fields=None,
                 ignore_msgs=None):
    if ignore_fields is None:
        ignore_fields = []
    if ignore_msgs is None:
        ignore_msgs = []

    ref_log_msgs = list(LogReader(ref_log_path))

    log_msgs = replay_process(cfg, lr)

    # check to make sure openpilot is engaged in the route
    if cfg.proc_name == "controlsd":
        if not check_enabled(log_msgs):
            return f"Route did not enable at all or for long enough: {new_log_path}", log_msgs

    try:
        return compare_logs(ref_log_msgs, log_msgs, ignore_fields + cfg.ignore,
                            ignore_msgs, cfg.tolerance,
                            cfg.field_tolerances), log_msgs
    except Exception as e:
        return str(e), log_msgs
Exemple #2
0
def test_process(cfg, lr, ref_log_path, ignore_fields=None, ignore_msgs=None):
  if ignore_fields is None:
    ignore_fields = []
  if ignore_msgs is None:
    ignore_msgs = []

  ref_log_msgs = list(LogReader(ref_log_path))

  log_msgs = replay_process(cfg, lr)

  # check to make sure openpilot is engaged in the route
  if cfg.proc_name == "controlsd":
    if not check_enabled(log_msgs):
      raise Exception(f"Route never enabled: {ref_log_path}")

  try:
    return compare_logs(ref_log_msgs, log_msgs, ignore_fields + cfg.ignore, ignore_msgs, cfg.tolerance), log_msgs
  except Exception as e:
    return str(e), log_msgs
Exemple #3
0
def test_process(cfg, lr, cmp_log_fn, ignore_fields=None, ignore_msgs=None):
  if ignore_fields is None:
    ignore_fields = []
  if ignore_msgs is None:
    ignore_msgs = []

  cmp_log_path = cmp_log_fn if os.path.exists(cmp_log_fn) else BASE_URL + os.path.basename(cmp_log_fn)
  cmp_log_msgs = list(LogReader(cmp_log_path))

  log_msgs = replay_process(cfg, lr)

  # check to make sure openpilot is engaged in the route
  if cfg.proc_name == "controlsd":
    if not check_enabled(log_msgs):
      segment = cmp_log_fn.split("/")[-1].split("_")[0]
      raise Exception(f"Route never enabled: {segment}")

  try:
    return compare_logs(cmp_log_msgs, log_msgs, ignore_fields+cfg.ignore, ignore_msgs, cfg.tolerance)
  except Exception as e:
    return str(e)
Exemple #4
0
def regen_segment(lr, frs=None, outdir=FAKEDATA):
  lr = list(lr)
  if frs is None:
    frs = dict()

  setup_env()
  params = Params()

  os.environ["LOG_ROOT"] = outdir
  os.environ['SKIP_FW_QUERY'] = ""
  os.environ['FINGERPRINT'] = ""

  # TODO: remove after getting new route for mazda
  migration = {
    "Mazda CX-9 2021": "MAZDA CX-9 2021",
  }

  for msg in lr:
    if msg.which() == 'carParams':
      car_fingerprint = migration.get(msg.carParams.carFingerprint, msg.carParams.carFingerprint)
      if len(msg.carParams.carFw) and (car_fingerprint in FW_VERSIONS):
        params.put("CarParamsCache", msg.carParams.as_builder().to_bytes())
      else:
        os.environ['SKIP_FW_QUERY'] = "1"
        os.environ['FINGERPRINT'] = car_fingerprint
    elif msg.which() == 'liveCalibration':
      params.put("CalibrationParams", msg.as_builder().to_bytes())

  vs, cam_procs = replay_cameras(lr, frs)

  fake_daemons = {
    'sensord': [
      multiprocessing.Process(target=replay_sensor_events, args=('sensorEvents', lr)),
    ],
    'pandad': [
      multiprocessing.Process(target=replay_service, args=('can', lr)),
      multiprocessing.Process(target=replay_service, args=('ubloxRaw', lr)),
      multiprocessing.Process(target=replay_panda_states, args=('pandaStates', lr)),
    ],
    'managerState': [
     multiprocessing.Process(target=replay_manager_state, args=('managerState', lr)),
    ],
    'thermald': [
      multiprocessing.Process(target=replay_device_state, args=('deviceState', lr)),
    ],
    'camerad': [
      *cam_procs,
    ],
  }

  try:
    # start procs up
    ignore = list(fake_daemons.keys()) + ['ui', 'manage_athenad', 'uploader']
    ensure_running(managed_processes.values(), started=True, not_run=ignore)
    for procs in fake_daemons.values():
      for p in procs:
        p.start()

    for _ in tqdm(range(60)):
      # ensure all procs are running
      for d, procs in fake_daemons.items():
        for p in procs:
          if not p.is_alive():
            raise Exception(f"{d}'s {p.name} died")
      time.sleep(1)
  finally:
    # kill everything
    for p in managed_processes.values():
      p.stop()
    for procs in fake_daemons.values():
      for p in procs:
        p.terminate()

  del vs

  segment = params.get("CurrentRoute", encoding='utf-8') + "--0"
  seg_path = os.path.join(outdir, segment)
  # check to make sure openpilot is engaged in the route
  if not check_enabled(LogReader(os.path.join(seg_path, "rlog.bz2"))):
    raise Exception(f"Route never enabled: {segment}")

  return seg_path
Exemple #5
0
def regen_segment(lr, frs=None, outdir=FAKEDATA, disable_tqdm=False):
    lr = list(lr)
    if frs is None:
        frs = dict()

    params = Params()
    os.environ["LOG_ROOT"] = outdir

    for msg in lr:
        if msg.which() == 'carParams':
            setup_env(CP=msg.carParams)
        elif msg.which() == 'liveCalibration':
            params.put("CalibrationParams", msg.as_builder().to_bytes())

    vs, cam_procs = replay_cameras(lr, frs, disable_tqdm=disable_tqdm)

    fake_daemons = {
        'sensord': [
            multiprocessing.Process(target=replay_sensor_events,
                                    args=('sensorEvents', lr)),
        ],
        'pandad': [
            multiprocessing.Process(target=replay_service, args=('can', lr)),
            multiprocessing.Process(target=replay_service,
                                    args=('ubloxRaw', lr)),
            multiprocessing.Process(target=replay_panda_states,
                                    args=('pandaStates', lr)),
        ],
        'managerState': [
            multiprocessing.Process(target=replay_manager_state,
                                    args=('managerState', lr)),
        ],
        'thermald': [
            multiprocessing.Process(target=replay_device_state,
                                    args=('deviceState', lr)),
        ],
        'camerad': [
            *cam_procs,
        ],
    }

    try:
        # TODO: make first run of onnxruntime CUDA provider fast
        managed_processes["modeld"].start()
        managed_processes["dmonitoringmodeld"].start()
        time.sleep(5)

        # start procs up
        ignore = list(fake_daemons.keys()) + [
            'ui', 'manage_athenad', 'uploader', 'soundd'
        ]
        ensure_running(managed_processes.values(),
                       started=True,
                       params=Params(),
                       CP=car.CarParams(),
                       not_run=ignore)
        for procs in fake_daemons.values():
            for p in procs:
                p.start()

        for _ in tqdm(range(60), disable=disable_tqdm):
            # ensure all procs are running
            for d, procs in fake_daemons.items():
                for p in procs:
                    if not p.is_alive():
                        raise Exception(f"{d}'s {p.name} died")
            time.sleep(1)
    finally:
        # kill everything
        for p in managed_processes.values():
            p.stop()
        for procs in fake_daemons.values():
            for p in procs:
                p.terminate()

    del vs

    segment = params.get("CurrentRoute", encoding='utf-8') + "--0"
    seg_path = os.path.join(outdir, segment)
    # check to make sure openpilot is engaged in the route
    if not check_enabled(LogReader(os.path.join(seg_path, "rlog"))):
        raise Exception(f"Route never enabled: {segment}")

    return seg_path