How to use 'enum' in (OMG) IDL

asked 2019-06-21 09:58:38 -0500

cgrage gravatar image

Using ROS2 Dashing: When writing messages in IDL (the supported subset of 4.2 of OMG IDL), how to you make use of enums?

In my understanding (and in the lack of examples) the following MsgWithEnum.idl should work, but doesn't - resulting in the error described below:

module domain_model_idl
{
    module idl
    {
        typedef unsigned short HappyUInt16;

        enum TypeOfWeather
        {
            Good,
            Perfect
        };

        struct MsgWithEnum 
        {
            HappyUInt16 some_int;
            TypeOfWeather weather_tomorrow;
        };
    };
};

Always generates: AssertionError: Unknown named type: TypeOfWeather

Details:

Unknown named type: TypeOfWeather /[...]/ros2-playground/domain_model_idl/idl/MsgWithEnum.idl
Error processing idl file: /[...]/ros2-playground/domain_model_idl/idl/MsgWithEnum.idl
Traceback (most recent call last):
[...]
  File "/opt/ros/dashing/lib/python3.6/site-packages/rosidl_parser/parser.py", line 145, in extract_content_from_ast
    resolve_typedefed_names(msg.structure, typedefs)
  File "/opt/ros/dashing/lib/python3.6/site-packages/rosidl_parser/parser.py", line 267, in resolve_typedefed_names
    assert type_.name in typedefs, 'Unknown named type: ' + type_.name
AssertionError: Unknown named type: TypeOfWeather
gmake[2]: *** [rosidl_generator_c/domain_model_idl/idl/msg_with_enum.h] Error 1

This is not development environment dependent.

edit retag flag offensive close merge delete

Comments

Enums are currently not support by our parser and the language specific code generators. I tried to capture this in an update of the design article: https://github.com/ros2/design/pull/248 There is already a feature ticket for this (https://github.com/ros2/rosidl/issues...) but it isn't planned to be worked on in the near future.

Dirk Thomas gravatar imageDirk Thomas ( 2019-07-29 17:59:06 -0500 )edit