c++c++11mappingidl

Anonymous Types in IDL C++11 for OpenDDS


I am using a DDS and need to be able to send data received from various devices. I have files from an IDL file using RTI DDS. However, it seems like these IDLs are different as OpenDDS using C++11 IDL mapping. The struct

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];
};

throws the message

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

I read up on anonymous types and see that the problem is that the array values are not declared but do not know how to make it not anonymous as this datatype would receive three values from the device. In the Developer's Guide of IDL to C++ Language Mapping the only information about anonymous types is

"Anonymous IDL types are deprecated by the IDL specification and are not supported in the IDL to C++11 language mapping specification. The IDL compiler that implements this mapping must throw an error when it detects an anonymous type." (https://www.omg.org/spec/CPP11/1.1/PDF) Section 6.2

I'm not really sure how to go around this error message or how to fix it.


Solution

  • Use a typedef to create a type with the array size you would like, then declare your variable with the new type. Example:

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