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;
    }
}
相关推荐
深度学习lover2 小时前
<数据集>yolo微藻识别<目标检测>
人工智能·python·yolo·目标检测·计算机视觉·微藻识别
格林威2 小时前
Windows 实时性补丁(RTX / WSL2)
linux·运维·人工智能·windows·数码相机·计算机视觉·工业相机
星光技术人3 小时前
怎么理解任务接口不是文本
人工智能·深度学习·计算机视觉·语言模型·自动驾驶
sali-tec4 小时前
C# 基于OpenCv的视觉工作流-章49-人脸检测
图像处理·人工智能·opencv·算法·计算机视觉
大江东去浪淘尽千古风流人物4 小时前
【Basalt】nfr_mapper 中的“小 SfM/BA 后端”
c++·人工智能·计算机视觉·oracle·augmented reality
gorgeous(๑>؂<๑)4 小时前
【CVPR26-韩国高丽大学】基于能量分离的开放世界目标检测未知目标方法
人工智能·目标检测·机器学习·计算机视觉·目标跟踪
大写-凌祁4 小时前
基于LLM智能体框架的城市遥感图像变化分析
人工智能·深度学习·计算机视觉·语言模型·aigc
ylatin4 小时前
常用的计算机视觉模型
人工智能·计算机视觉
碑 一14 小时前
视频分割Video K-Net
人工智能·计算机视觉
宇擎智脑科技16 小时前
基于 SAM3 + FastAPI 搭建智能图像标注工具实战
人工智能·计算机视觉