      sm.update(0);
      int desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire());
      frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId();
  
      float vec_desire[DESIRE_LEN] = {0};
      if (desire >= 0 && desire < DESIRE_LEN) {
        vec_desire[desire] = 1.0;
 
</s> remove     transform_lock.lock();
    mat3 model_transform = cur_transform;
    bool valid = live_calib_seen;
    transform_lock.unlock();

 </s> add  </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   SubMaster sm({"lateralPlan", "roadCameraState"});
 </s> add   SubMaster sm({"lateralPlan", "roadCameraState", "liveCalibration"}); </s> remove                   kj::ArrayPtr<const float>(model.output.data(), model.output.size()), valid);
    posenet_publish(pm, extra.frame_id, vipc_dropped_frames, *model_output, extra.timestamp_eof, valid);
 </s> add                   kj::ArrayPtr<const float>(model.output.data(), model.output.size()), live_calib_seen);
    posenet_publish(pm, extra.frame_id, vipc_dropped_frames, *model_output, extra.timestamp_eof, live_calib_seen);
    if (sm.updated("liveCalibration")) {
      model_transform = update_calibration(sm["liveCalibration"].getLiveCalibration(), wide_camera);
      live_calib_seen = true;
    }
      sm.update(0);
      int desire = ((int)sm["lateralPlan"].getLateralPlan().getDesire());
      frame_id = sm["roadCameraState"].getRoadCameraState().getFrameId();
    if (sm.updated("liveCalibration")) {
      model_transform = update_calibration(sm["liveCalibration"].getLiveCalibration(), wide_camera);
      live_calib_seen = true;
    }
  
      float vec_desire[DESIRE_LEN] = {0};
      if (desire >= 0 && desire < DESIRE_LEN) {
        vec_desire[desire] = 1.0;
keep keep add 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