  
  void run_model(ModelState &model, VisionIpcClient &vipc_client) {
    // messaging
    PubMaster pm({"modelV2", "cameraOdometry"});
    SubMaster sm({"lateralPlan", "roadCameraState"});
  
    // setup filter to track dropped frames
    FirstOrderFilter frame_dropped_filter(0., 10., 1. / MODEL_FREQ);
  
    uint32_t frame_id = 0, last_vipc_frame_id = 0;
 
</s> remove void run_model(ModelState &model, VisionIpcClient &vipc_client) {
 </s> add void run_model(ModelState &model, VisionIpcClient &vipc_client, bool wide_camera) { </s> remove   while (!do_exit) {
    sm.update(100);
    if(sm.updated("liveCalibration")) {
      auto extrinsic_matrix = sm["liveCalibration"].getLiveCalibration().getExtrinsicMatrix();
      Eigen::Matrix<float, 3, 4> extrinsic_matrix_eigen;
      for (int i = 0; i < 4*3; i++) {
        extrinsic_matrix_eigen(i / 4, i % 4) = extrinsic_matrix[i];
      }

      auto camera_frame_from_road_frame = cam_intrinsics * extrinsic_matrix_eigen;
      Eigen::Matrix<float, 3, 3> camera_frame_from_ground;
      camera_frame_from_ground.col(0) = camera_frame_from_road_frame.col(0);
      camera_frame_from_ground.col(1) = camera_frame_from_road_frame.col(1);
      camera_frame_from_ground.col(2) = camera_frame_from_road_frame.col(3);

      auto warp_matrix = camera_frame_from_ground * ground_from_medmodel_frame;
      mat3 transform = {};
      for (int i=0; i<3*3; i++) {
        transform.v[i] = warp_matrix(i / 3, i % 3);
      }
      mat3 model_transform = matmul3(yuv_transform, transform);
      std::lock_guard lk(transform_lock);
      cur_transform = model_transform;
      live_calib_seen = true;
    }
 </s> add   auto extrinsic_matrix = live_calib.getExtrinsicMatrix();
  Eigen::Matrix<float, 3, 4> extrinsic_matrix_eigen;
  for (int i = 0; i < 4*3; i++) {
    extrinsic_matrix_eigen(i / 4, i % 4) = extrinsic_matrix[i]; </s> remove // globals
bool live_calib_seen;
mat3 cur_transform;
std::mutex transform_lock;

void calibration_thread(bool wide_camera) {
  util::set_thread_name("calibration");
  util::set_realtime_priority(50);

  SubMaster sm({"liveCalibration"});
 </s> add 
  SubMaster sm({"lateralPlan", "roadCameraState", "liveCalibration"});
  
  void run_model(ModelState &model, VisionIpcClient &vipc_client) {
    // messaging
    PubMaster pm({"modelV2", "cameraOdometry"});
  SubMaster sm({"lateralPlan", "roadCameraState", "liveCalibration"});
  
    // setup filter to track dropped frames
    FirstOrderFilter frame_dropped_filter(0., 10., 1. / MODEL_FREQ);
  
    uint32_t frame_id = 0, last_vipc_frame_id = 0;
keep keep keep keep replace keep keep keep keep keep
 modeld: update live calibration in main thread (#23235)

* update live calibration in main thread

* static ground_from_medmodel_frame

* more static

* cleanup

* no lambda

* trigger ci 
selfdrive/modeld/modeld.cc