       from common.transformations.model import medmodel_frame_from_road_frame
       medmodel_frame_from_ground = medmodel_frame_from_road_frame[:, (0, 1, 3)]
       ground_from_medmodel_frame = np.linalg.inv(medmodel_frame_from_ground)
    */
    Eigen::Matrix<float, 3, 3> ground_from_medmodel_frame;
    ground_from_medmodel_frame <<
      0.00000000e+00, 0.00000000e+00, 1.00000000e+00,
      -1.09890110e-03, 0.00000000e+00, 2.81318681e-01,
      -1.84808520e-20, 9.00738606e-04,-4.28751576e-02;
  
    Eigen::Matrix<float, 3, 3> cam_intrinsics = Eigen::Matrix<float, 3, 3, Eigen::RowMajor>(wide_camera ? ecam_intrinsic_matrix.v : fcam_intrinsic_matrix.v);
 
</s> remove     -1.84808520e-20, 9.00738606e-04,-4.28751576e-02;
 </s> add     -1.84808520e-20, 9.00738606e-04, -4.28751576e-02).finished(); </s> remove   Eigen::Matrix<float, 3, 3> cam_intrinsics = Eigen::Matrix<float, 3, 3, Eigen::RowMajor>(wide_camera ? ecam_intrinsic_matrix.v : fcam_intrinsic_matrix.v);
  const mat3 yuv_transform = get_model_yuv_transform();
 </s> add   static const auto cam_intrinsics = Eigen::Matrix<float, 3, 3, Eigen::RowMajor>(wide_camera ? ecam_intrinsic_matrix.v : fcam_intrinsic_matrix.v);
  static const mat3 yuv_transform = get_model_yuv_transform(); </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 
  static const auto ground_from_medmodel_frame = (Eigen::Matrix<float, 3, 3>() << 
       from common.transformations.model import medmodel_frame_from_road_frame
       medmodel_frame_from_ground = medmodel_frame_from_road_frame[:, (0, 1, 3)]
       ground_from_medmodel_frame = np.linalg.inv(medmodel_frame_from_ground)
    */
  static const auto ground_from_medmodel_frame = (Eigen::Matrix<float, 3, 3>() << 
  static const auto ground_from_medmodel_frame = (Eigen::Matrix<float, 3, 3>() << 
      0.00000000e+00, 0.00000000e+00, 1.00000000e+00,
      -1.09890110e-03, 0.00000000e+00, 2.81318681e-01,
      -1.84808520e-20, 9.00738606e-04,-4.28751576e-02;
  
    Eigen::Matrix<float, 3, 3> cam_intrinsics = Eigen::Matrix<float, 3, 3, Eigen::RowMajor>(wide_camera ? ecam_intrinsic_matrix.v : fcam_intrinsic_matrix.v);
keep keep keep keep replace 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