-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] restructure rosidl to work with IDL files #298
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be an entry point to work on windows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
orstruct
describing 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
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
?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.idl
files (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):
.idl
files). For backward compatibility.msg
/.srv
files can be passed as before (their extension already determines the interface type).rosidl_adapter
is aded which handles all incoming interface files (arbitrary file types)..msg
/.srv
files. Currently support to convert.msg
/,srv
files to.idl
is hard coded.msg
/srv
parser should support extracting comments and using them in the generated.idl
files, see heuristic to extract comments from .msg files #316.msg2idl
/srv2idl
is available.The converters should be pluggable using Python entry points.rosidl_parser
torosidl_adapter
..idl
files using a grammar file forlark
is now inrosidl_parser
(since that will be the main interface language)..idl
files and needs to beextendedreplaced.The CMake files from all message generators which registered themselves under therosidl_generate_interfaces
extension point must now handle IDL files - they never receive.msg
/.srv
files anymore.rosidl_generator_c
has been updated.rosidl_generator_cpp
has 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.: