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;
    }
}
相关推荐
~kiss~22 分钟前
图像处理之膨胀
图像处理·人工智能·计算机视觉
fsnine6 小时前
YOLOv2原理介绍
人工智能·计算机视觉·目标跟踪
m0_650108248 小时前
【论文精读】FlowVid:驯服不完美的光流,实现一致的视频到视频合成
人工智能·计算机视觉·扩散模型·视频编辑·视频生成·论文精读·不完美光流
程序猿小D8 小时前
【完整源码+数据集+部署教程】【零售和消费品&存货】价格标签检测系统源码&数据集全套:改进yolo11-RFAConv
前端·yolo·计算机视觉·目标跟踪·数据集·yolo11·价格标签检测系统源码
滑水滑成滑头8 小时前
**点云处理:发散创新,探索前沿技术**随着科技的飞速发展,点云处理技术在计算机视觉、自动驾驶、虚拟现实等领域的应用愈发广
java·python·科技·计算机视觉·自动驾驶
CoovallyAIHub9 小时前
超越“识别”:下一代机器视觉如何破解具身智能落地难题?
深度学习·算法·计算机视觉
CoovallyAIHub10 小时前
全球OCR新标杆!百度0.9B小模型斩获四项SOTA,读懂复杂文档像人一样自然
深度学习·算法·计算机视觉
Francek Chen10 小时前
【深度学习计算机视觉】14:实战Kaggle比赛:狗的品种识别(ImageNet Dogs)
人工智能·pytorch·深度学习·计算机视觉·kaggle·imagenet dogs
茜茜西西CeCe11 小时前
数字图像处理-图像编码与压缩
人工智能·计算机视觉·matlab·数字图像处理·图像压缩·图像编码
WWZZ202521 小时前
快速上手大模型:机器学习2(一元线性回归、代价函数、梯度下降法)
人工智能·算法·机器学习·计算机视觉·机器人·大模型·slam