  
    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();
  
    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;
      }
    }
  }
  
  void run_model(ModelState &model, VisionIpcClient &vipc_client) {
    // messaging
 
</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     -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> ground_from_medmodel_frame;
  ground_from_medmodel_frame <<
 </s> add   static const auto ground_from_medmodel_frame = (Eigen::Matrix<float, 3, 3>() << 
  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];
  
    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();
  
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
  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];
    }
  }
  
  void run_model(ModelState &model, VisionIpcClient &vipc_client) {
    // messaging
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace 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