[WIP] restructure rosidl to work with IDL files#298
[WIP] restructure rosidl to work with IDL files#298dirk-thomas wants to merge 39 commits intomasterfrom
Conversation
… type specific keyword
|
I gave this a shot, it seems that it fails to build on Xenial / Python 3.5: |
I didn't try with Python 3.5 but it should be fixed by 9b0e9d0. |
…an object representation
|
With the latest commit the pipeline works and the
While this can't be merged until all message generators have been updated to process This new structure avoids any repetition in the templates (e.g. between messages and services) and allows easy integration of action and other interface definitions in the future. Also generators unable to handle new types like actions would automatically gracefully fall back to do nothing. |
sloretz
left a comment
There was a problem hiding this comment.
Partial review. The changes in test_interfaces.c looks good to me. I didn't look as closely as I would like at rosidl_generator_c/__init__.py, but the templates themselves look fine.
|
|
||
| from rosidl_adapter.main import main | ||
|
|
||
| sys.exit(main()) |
There was a problem hiding this comment.
Does this need to be an entry point to work on windows?
There was a problem hiding this comment.
It doesn't since it is invoked with python -m rosidl_adapter.
| locator, png_file=os.path.join( | ||
| args['output_dir'], str(idl_rel_path.parent), | ||
| idl_rel_path.stem) + '.png') | ||
| for template_file, generated_filename in mapping.items(): |
There was a problem hiding this comment.
Can multiple messages or service definitions live in the same IDL file? If so, can a generator generate code for messages and services in an IDL file while ignoring an IDL module or struct describing an action?
I'm wondering if it would be possible to add a step to the pipeline where an <action>.idl can be converted to an <action_plus_generated_messages_and_services>.idl. Some generators (including rmw specific ones) parse the idl, find messages and services, and generate code for messages and services. Other generators (not rmw specific ones) get the same file, parse it, find an action, and generate code for only the action.
There was a problem hiding this comment.
Nevermind, I see now that parse_idl_string() allows one message or one service per file.
Instead, would it be possible to add a step after rosidl_adapter but before calling the generators that parses an <action>.idl and creates a <send goal service>.idl, <get result service>.idl and <feedback message>.idl?
There was a problem hiding this comment.
Can multiple messages or service definitions live in the same IDL file? If so, can a generator generate code for messages and services in an IDL file while ignoring an IDL
moduleorstructdescribing anaction?
Nevermind, I see now that
parse_idl_string()allows one message or one service per file.
Yeah, to keep the complexity down it only accepts single definitions in the parse functions. The actual logic in the C generator though is capable of handling any number of definitions. So the parse functions can certainly be extended in the future to enable that.
There was a problem hiding this comment.
I'm wondering if it would be possible to add a step to the pipeline where an
<action>.idlcan be converted to an<action_plus_generated_messages_and_services>.idl.
Instead, would it be possible to add a step after
rosidl_adapterbut before calling the generators that parses an<action>.idland creates a<send goal service>.idl,<get result service>.idland<feedback message>.idl?
I don't think these files need to be generated explicitly. When an .action file is parsed (actually the equivalent .idl file) the object representation can provide these extended derived definitions. So each generator handling an action can feed these sub-parts to an existing message / service template. Similar to how a service objects contains two message objects and just invoked the message template twice - once for the request, once for the response - and optionally generates something service specific in addition. The action object would just contain not only plain messages / services which have 1-to-1 the same content as in the .action file but contain the "enriched" versions of the derived types.
| @{ | ||
| from rosidl_parser.definition import Service | ||
| }@ | ||
| @[for service in content.get_elements_of_type(Service)]@ |
There was a problem hiding this comment.
IIUC parse_idl_string() will only result in an IdlContent created with one service definition. Is this a hook for supporting multiple services in an IDL file in the future?
There was a problem hiding this comment.
Same as #298 (comment) In the future parse_idl_string should be extended to support multiple definitions in a single file. It is just more complex to do so I haven't done it in this round.
These changes modify the rosidl processing pipeline to use
.idlfiles (using a subset of OMG IDL 4.2). See https://github.com/ros2/ros2/blob/idl/README.rst#goals for a collection of bullets and references.A high level overview of this work (the patch has been split up into separated PRs - see referenced PRs at the bottom of this ticket):
.idlfiles). For backward compatibility.msg/.srvfiles can be passed as before (their extension already determines the interface type).rosidl_adapteris aded which handles all incoming interface files (arbitrary file types)..msg/.srvfiles. Currently support to convert.msg/,srvfiles to.idlis hard coded.msg/srvparser should support extracting comments and using them in the generated.idlfiles, see heuristic to extract comments from .msg files #316.msg2idl/srv2idlis available.The converters should be pluggable using Python entry points.rosidl_parsertorosidl_adapter..idlfiles using a grammar file forlarkis now inrosidl_parser(since that will be the main interface language)..idlfiles and needs to beextendedreplaced.The CMake files from all message generators which registered themselves under therosidl_generate_interfacesextension point must now handle IDL files - they never receive.msg/.srvfiles anymore.rosidl_generator_chas been updated.rosidl_generator_cpphas been updated.Currently this branch can be used to build some interface packages. For that all not yet changes message generators need to be skipped, e.g.:
Details