示例#1
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
示例#2
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