-
Notifications
You must be signed in to change notification settings - Fork 128
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
Type hash in interface codegen (rep2011) #722
Type hash in interface codegen (rep2011) #722
Conversation
af252c7
to
118dfa9
Compare
@clalancette @wjwwood This still needs testing but I feel good about it functionally - feedback, especially on high level approach and architecture would be very valuable now |
rosidl_generator_type_hash/rosidl_generator_type_hash/__init__.py
Outdated
Show resolved
Hide resolved
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.
Some small comments
rosidl_generator_type_hash/cmake/rosidl_generator_type_hash_generate_interfaces.cmake
Outdated
Show resolved
Hide resolved
rosidl_generator_type_hash/rosidl_generator_type_hash/__init__.py
Outdated
Show resolved
Hide resolved
Also additional note: The hashes aren't getting populated/generated for rosidl_generator_py, but I don't think we need it to at the moment |
@methylDragon see ros2/rosidl_python#191 for |
Converting back to draft while I do the CLI and figure out a couple other bits I'm discovering that I need downstream for RMW implementations to distribute the type hash during discovery. Didn't hear any major architectural concerns, so I am thinking the main thing needed here is documentation and tests, not overhaul. |
6433ecd
to
9035b23
Compare
The |
@clalancette @wjwwood @methylDragon @james-rms I have prototypes working donwstream of this passing type hashes in FastDDS and CycloneDDS via user_data, which validates to me that this PR is now providing all required interfaces to enable Type Hash Distribution. |
@methylDragon yes that is true - referenced type descriptions are sorted alphabetically (rather than, for example, some topological ordering), but fields are added in the order they are specified in each individual type definition |
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've done a first review pass here. I generally understand what you are doing in here, and I don't see any major flaws. I've left a few things to fix up, and I also need to go back and look at the empy things more carefully, but we can at least start with this stuff.
rosidl_generator_type_hash/resource/HashedTypeDescription.schema.json
Outdated
Show resolved
Hide resolved
rosidl_generator_type_hash/rosidl_generator_type_hash/__init__.py
Outdated
Show resolved
Hide resolved
rosidl_generator_type_hash/rosidl_generator_type_hash/__init__.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
fb5af8d
to
1ff7937
Compare
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
1ff7937
to
3fce7b5
Compare
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
…ts for them Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
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.
OK, I did a more thorough review and also looked at the generated output.
Despite the fact that I left quite a few comments, they are almost all minor or questions. Overall, this looks really fantastic. I think once we get these things solved and also get Windows happy, we can proceed with this.
rosidl_generator_type_description/resource/HashedTypeDescription.schema.json
Outdated
Show resolved
Hide resolved
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Gist: https://gist.githubusercontent.com/emersonknapp/190b20823a334c72086b26bd139e29d6/raw/adb81acaee0b780fc260e3461ca5f8efba166a46/ros2.repos |
OK - I think I've pushed an update to all the actionable comments and answered all the questions. Green CI! |
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
OK, I went back through, and there is one minor renaming thing left. After that, this is good to merge. |
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
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.
Thanks for all of the back-and-forth here!
This now looks good to me. I'll suggest we run CI with just this PR in place, since we'll only be merging this one right away.
Once that CI is green, I'm going to wait until after our weekly meeting to merge this in.
Gist: https://gist.githubusercontent.com/emersonknapp/54b2023bfdc0fc52f06b54c83afd1d59/raw/adb81acaee0b780fc260e3461ca5f8efba166a46/ros2.repos |
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 skimmed the C code part and it lgtm, with some nitpick/comments, but nothing blocking.
|
||
uint8_t nibble = 0; | ||
char * dest = NULL; | ||
for (size_t i = 0; i < ROSIDL_TYPE_HASH_SIZE; i++) { |
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.
nitpick:
for (size_t i = 0; i < ROSIDL_TYPE_HASH_SIZE; i++) { | |
for (size_t i = 0; i < ROSIDL_TYPE_HASH_SIZE; ++i) { |
https://google.github.io/styleguide/cppguide.html#Preincrement_and_Predecrement
Related to ros-infrastructure/rep#358
Part of ros2/ros2#1159
Related to ros2/rcl#1027
No dependencies.
Feature addition: New generator package
rosidl_generator_type_hash
that creates JSON representations and their corresponding SHA256 hashes for ROS 2 interfaces during code generation. A new typerosidl_type_hash_t
that contains these versioned hash values and can be used to store them in generated code and be used in RMW discovery.Change brief by repository:
rosidl_cmake
- Add new argument to generatorrosidl_generator_c
- depend on new typehash generator, embed hashes in generated C code using the new rosidl_runtime_c structrosidl_generator_cpp
- depend on typehash generator, embed hashes in generated C++ code using the new rosidl_runtime_c structrosidl_generator_tests
- new tests for the typehash generatorrosidl_generator_type_hash
- new generator, reads ROS IDL representations, serializes to hashable JSON format, and produces SHA256 hashes for all interface types, according to REP-2011. SeeREADME.md
for more detailsrosidl_pycommon
- utility for loading and embedding hashes in code generatorsrosidl_runtime_c
- structrosidl_type_hash_t
for representing type hashes, with string utilities for encodingrosidl_typesupport_introspection_c
- add the type hash to introspection alongside type name for use by RMW implementationrosidl_typesupport_introspection_cpp
- add the type hash to introspection alongside type name for use by RMW implementationThe hashes are provided to the install tree, and so are available to language code generators (C, C++, Python) to be embedded in generated code for calculation-free use at runtime.
For Messages, a simple hash is output. For Services and Actions, all generated subinterfaces are also represented and hashed, so that every Service and Message in the resulting installation has its own unique hash. See the
rosidl_generator_type_hash/resource/HashedTypeDescription.schema.json
file, as mentioned in the README for a strict description of the structure.Attached are archives containing the output tree of
build/example_interfaces/rosidl_generator_type_hash
/rosidl_generator_c
for representative output.rosidl_generator_c.tar.gz