Airsim仿真双目相机时间戳不同步的解决办法

settings.json

bash 复制代码
{
  "SeeDocsAt": "https://github.com/Microsoft/AirSim/blob/main/docs/settings.md",
  "SettingsVersion": 1.2,
  "SimMode": "Multirotor",
  "ViewMode": "NoDisplay",
  "ClockSpeed": 1.0,
  "LocalHostIp": "192.168.35.220",
  "ApiServerPort": 41451,
  "Vehicles": {
    "drone_1": {
      "VehicleType": "SimpleFlight",
      "DefaultVehicleState": "Armed",
      "EnableCollisionPassthrogh": false,
      "EnableCollisions": true,
      "AllowAPIAlways": true,
      "Cameras": {
        "front_left_custom": {
          "CaptureSettings": [
            {
              "PublishToRos": 1,
              "ImageType": 0,
              "Width": 672,
              "Height": 376,
              "FOV_Degrees": 120,
              "TargetGamma": 1.5
            }
          ],
          "X": 0.50, "Y": -0.06, "Z": 0.10,
          "Pitch": 0.0, "Roll": 0.0, "Yaw": 0.0
        },
        "front_right_custom": {
          "CaptureSettings": [
            {
              "PublishToRos": 1,
              "ImageType": 0,
              "Width": 672,
              "Height": 376,
              "FOV_Degrees": 120,
              "TargetGamma": 1.5
            }
          ],
          "X": 0.50, "Y": 0.16, "Z": 0.10,
          "Pitch": 0.0, "Roll": 0.0, "Yaw": 0.0
        }
      },
      "X": 0,
      "Y": 0,
      "Z": 0,
      "Pitch": 0,
      "Roll": 0,
      "Yaw": 0
    }
  }
}

airsim_ros_pkgs/src/airsim_ros_wrapper.cpp

cpp 复制代码
void AirsimROSWrapper::img_response_timer_cb(const ros::TimerEvent& event)
{
    try {
        int image_response_idx = 0;

        uint64_t kk;

        for (const auto& airsim_img_request_vehicle_name_pair : airsim_img_request_vehicle_name_pair_vec_) {
            const std::vector<ImageResponse>& img_response = airsim_client_images_.simGetImages(airsim_img_request_vehicle_name_pair.first, airsim_img_request_vehicle_name_pair.second);
            
            // 创建 img_response 的副本,修改副本的时间戳
            std::vector<ImageResponse> img_response_copy = img_response;

            if (image_response_idx == 0){
                kk = img_response_copy[0].time_stamp;  // 获取第一个元素的时间戳
            }
            else {
                img_response_copy[0].time_stamp = kk;  // 使用保存的时间戳
            }

            if (img_response_copy.size() == airsim_img_request_vehicle_name_pair.first.size()) {
                process_and_publish_img_response(img_response_copy, image_response_idx, airsim_img_request_vehicle_name_pair.second);
                image_response_idx += img_response_copy.size();
            }

            // if (img_response.size() == airsim_img_request_vehicle_name_pair.first.size()) {
            //     process_and_publish_img_response(img_response, image_response_idx, airsim_img_request_vehicle_name_pair.second);
            //     image_response_idx += img_response.size();
            // }
        }
    }

    catch (rpc::rpc_error& e) {
        std::string msg = e.get_error().as<std::string>();
        std::cout << "Exception raised by the API, didn't get image response." << std::endl
                  << msg << std::endl;
    }
}
相关推荐
这张生成的图像能检测吗1 小时前
(论文速读)Regor - 渐进式对应点再生实现鲁棒3D配准
人工智能·算法·计算机视觉·配准·3d点云
CoovallyAIHub3 小时前
外科医生离手术世界模型还有多远?首次提出SurgVeo基准,揭示AI生成手术视频的惊人差距
深度学习·算法·计算机视觉
abcd_zjq6 小时前
VS2026+QT6.9+ONNX+OPENCV+YOLO11(目标检测)(详细注释)(附测试模型和图像)
c++·人工智能·qt·目标检测·计算机视觉·visual studio
思通数科多模态大模型18 小时前
扑灭斗殴的火苗:AI智能守护如何为校园安全保驾护航
大数据·人工智能·深度学习·安全·目标检测·计算机视觉·数据挖掘
carver w19 小时前
彻底理解传统卷积,深度可分离卷积
人工智能·深度学习·计算机视觉
CoovallyAIHub1 天前
空间智能!李飞飞、LeCun&谢赛宁联手提出“空间超感知”,长文阐述世界模型蓝图
深度学习·算法·计算机视觉
学术小白人1 天前
最后一轮征稿!2025年能源互联网与电气工程国际学术会议
人工智能·科技·计算机视觉·能源
guygg881 天前
基于MATLAB的图像融合拼接GUI系统设计
opencv·计算机视觉·matlab
沉默媛1 天前
如何下载安装以及使用labelme,一个可以打标签的工具,实现数据集处理,详细教程
图像处理·人工智能·python·yolo·计算机视觉
nnn__nnn1 天前
哈尔特征:计算机视觉中的经典特征提取范式与现代延伸
人工智能·计算机视觉·目标跟踪