【问题标题】:Anonymous Types in IDL C++11 for OpenDDS用于 OpenDDS 的 IDL C++11 中的匿名类型
【发布时间】:2021-04-15 23:26:09
【问题描述】:

我正在使用 DDS,并且需要能够发送从各种设备接收到的数据。我有使用 RTI DDS 的 IDL 文件中的文件。但是,这些 IDL 似乎与使用 C++11 IDL 映射的 OpenDDS 不同。结构体

struct ddsServicerDynamicsData {
        ddsVector3_dbl rpos_eci;        //position relative to Earth in ECI coordinates (x, y, z) [m]
        ddsVector3_dbl rvel_eci;        //velocity relative to Earth in ECI coordinates (x_dot, y_dot, z_dot) [m/s]
        ddsVector3_dbl vrot_eci;        //rotation velocity around pricipal axes in ECI frame (phi_dot, theta_dot, psi_dot); TODO: units [rad/s] or [deg/s]
        ddsVector3_dbl arot_eci;        //angular orientation in ECI frame (phi, theta, psi); TODO: units [rad] or [deg]
        ddsVector3_dbl cgshift;         //vector from arbitrary reference point to S/C center of gravity (example: vector from base of robot arm to CG) in S/C coordinates
        float antennastate0[3];         //antenna position vector (azimuth, elevation, polarization); TODO: units [rad] or [deg]
        float antennastate1[3];
        float armstate0[7];             //7DOF robotic arm joint angles (epsilon 0 to 6); TODO: units [rad] or [deg]
        float armstate1[7];
        float armstate2[7];
        float armstate3[7];
};

抛出消息

Error - opendds_idl: "DataTypes.idl", line 53: field has an anonymous type.

我阅读了匿名类型,发现问题在于未声明数组值,但不知道如何使其不匿名,因为此数据类型将从设备接收三个值。在 IDL 到 C++ 语言映射的开发人员指南中,关于匿名类型的唯一信息是

"匿名 IDL 类型已被 IDL 规范弃用,并且在 IDL 到 C++11 语言中不受支持 映射规范。实现此映射的 IDL 编译器在检测到 匿名类型。”(https://www.omg.org/spec/CPP11/1.1/PDF)第 6.2 节

我不确定如何绕过此错误消息或如何修复它。

【问题讨论】:

    标签: c++ c++11 mapping idl


    【解决方案1】:

    使用 typedef 创建具有您想要的数组大小的类型,然后使用新类型声明您的变量。 示例:

    typedef float AntennaStateType[3];
    
    @topic
    struct ddsServicerDynamicsData
    {
       AntennaStateType armState0;
       AntennaStateType armState1;
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-13
      • 1970-01-01
      相关资源
      最近更新 更多