How to use 'enum' in (OMG) IDL

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

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

        struct MsgWithEnum 
            HappyUInt16 some_int;
            TypeOfWeather weather_tomorrow;

Always generates: AssertionError: Unknown named type: TypeOfWeather


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/", line 145, in extract_content_from_ast
    resolve_typedefed_names(msg.structure, typedefs)
  File "/opt/ros/dashing/lib/python3.6/site-packages/rosidl_parser/", line 267, in resolve_typedefed_names
    assert in typedefs, 'Unknown named type: ' +
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


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: There is already a feature ticket for this ( but it isn't planned to be worked on in the near future.

Dirk Thomas gravatar image Dirk Thomas  ( 2019-07-29 17:59:06 -0600 )edit