Skip to content
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

Calculate type hash from TypeDescription (rep2011) #1027

Merged
merged 8 commits into from Mar 29, 2023

Conversation

emersonknapp
Copy link
Collaborator

@emersonknapp emersonknapp commented Jan 17, 2023

Related to ros-infrastructure/rep#358
Part of ros2/ros2#1159
Depends on ros2/rosidl#729

This PR introduces a utility function to provide a stable reproducible hash for type_description_interfaces/msg/TypeDescription for use in type comparison/advertising in REP-2011

@emersonknapp emersonknapp changed the title [WIP] REP-2011 Type Version Hash Calculator [WIP] REP-2011 Type Version Hash at runtime Jan 24, 2023
@emersonknapp emersonknapp changed the title [WIP] REP-2011 Type Version Hash at runtime Type Version Hash at runtime (rep-2011) Feb 1, 2023
@emersonknapp emersonknapp marked this pull request as ready for review February 1, 2023 00:50
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've left a few suggestions for improvement inline, along with some questions.

Besides that, this PR should be retargeted to rolling, which is our default branch. Also, this can't be merged until we merge in the type_description_interfaces package.

rcl/include/rcl/type_version_hash.h Outdated Show resolved Hide resolved
rcl/include/rcl/type_version_hash.h Outdated Show resolved Hide resolved
rcl/include/rcl/type_version_hash.h Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/include/rcl/type_version_hash.h Outdated Show resolved Hide resolved
rcl/include/rcl/type_version_hash.h Outdated Show resolved Hide resolved
@emersonknapp emersonknapp changed the base branch from master to rolling February 1, 2023 20:43
@emersonknapp
Copy link
Collaborator Author

Changed the base branch, Yes, I've marked the dependency in the description - though github doesn't understand that language, it has only the "closes" behavior semantic for cross-linking issues.

Addressing other comments shortly.

@clalancette
Copy link
Contributor

Changed the base branch, Yes, I've marked the dependency in the description - though github doesn't understand that language, it has only the "closes" behavior semantic for cross-linking issues.

Thanks. Yeah, it would be nice if we could express these dependencies in GitHub somehow. The good news is that this will totally fail to compile in CI until type_description_interfaces is available, so we should be OK.

@emersonknapp
Copy link
Collaborator Author

OK - I think I've addressed everything. I appreciate the feedback, round 2 welcome :)

@emersonknapp emersonknapp requested review from clalancette and removed request for wjwwood, audrow and ivanpauno February 1, 2023 22:49
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I love this new structure; so much better than the macros. Thanks for taking the time to investigate this!

I've left a couple of minor comments inline; otherwise, I think this is ready to go modulo getting the type_description_interface package in.

rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! We should discuss how to get ros2/rcl_interfaces#146 landed.

@emersonknapp emersonknapp changed the title Type Version Hash at runtime (rep-2011) Calculate type hash from TypeDescription (rep2011) Feb 21, 2023
@emersonknapp
Copy link
Collaborator Author

Moving this back to draft while working out the type hash struct - which this calculator should also provide

@emersonknapp emersonknapp marked this pull request as draft February 22, 2023 00:49
@emersonknapp emersonknapp force-pushed the emersonknapp/type-version-hash branch 3 times, most recently from 0ffcc0f to 96a8486 Compare March 13, 2023 06:24
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a few more nits to fix here, otherwise looks pretty good to me.

rcl/include/rcl/type_version_hash.h Outdated Show resolved Hide resolved
rcl/src/rcl/type_version_hash.c Outdated Show resolved Hide resolved
rcl/test/rcl/test_type_version_hash.cpp Outdated Show resolved Hide resolved
rcl/test/rcl/test_type_version_hash.cpp Outdated Show resolved Hide resolved
rcl/test/rcl/test_type_version_hash.cpp Outdated Show resolved Hide resolved
@emersonknapp emersonknapp force-pushed the emersonknapp/type-version-hash branch from 30144b6 to ade7055 Compare March 22, 2023 08:45
@emersonknapp emersonknapp marked this pull request as ready for review March 22, 2023 08:46
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than the implicit dependency on libyaml, this lgtm

* the JSON representation of type_description. Note that output_repr will have a
* terminating null character, which should be omitted from hashing. To do so, use
* (output_repr.buffer_length - 1) or strlen(output_repr.buffer) for the size of data to hash.
* \return RCL_RET_OK on success, RCL_RET_ERROR if any problems occur in translation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: you might want to have a look at how the other rcl functions document return types, I think they use one per \return and wrap the return types in `RCL_RET_...` for a reason, but I can't remember them off-hand. Thought I do think it's best to just emulate them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (they use

\return #RCL_RET_... for reason, or
\return #RCL_RET_... for a final reason, period.

so I did that


#include <stdio.h>

#include <yaml.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This concerns me, I think it's coming in implicitly through rcl_yaml_param_parser. I actually don't love depending on libyaml from rcl proper like this, though the effect is the same as the current situation, since we hard depend on the yaml stuff in rcl_yaml_param_parser.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do something different, I think we should use libyaml, but I do think we need to explicitly depend on libyaml, via package.xml and CMake.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

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>
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp force-pushed the emersonknapp/type-version-hash branch from 9245a40 to febd2ff Compare March 24, 2023 17:27
Copy link
Contributor

@clalancette clalancette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small comment updates, then this looks good to me.

rcl/include/rcl/type_hash.h Outdated Show resolved Hide resolved
rcl/include/rcl/type_hash.h Outdated Show resolved Hide resolved
Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp emersonknapp requested review from clalancette and wjwwood and removed request for clalancette and wjwwood March 27, 2023 21:35
@emersonknapp
Copy link
Collaborator Author

Gist: https://gist.githubusercontent.com/emersonknapp/ff276a843492f27fd1afac2806fdb849/raw/e273147f65788680698e21401ce10184f120cdfd/ros2.repos
BUILD args: --packages-above-and-dependencies rcl
TEST args: --packages-above rcl
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/11684

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Mar 28, 2023

Gist: https://gist.githubusercontent.com/emersonknapp/e163a4a54a5fa58279b131748d54a31b/raw/e273147f65788680698e21401ce10184f120cdfd/ros2.repos
BUILD args: --packages-above-and-dependencies rcl
TEST args: --packages-above rcl
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/11688

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette
Copy link
Contributor

FYI, windows build is failing with:

LINK : fatal error LNK1181: cannot open input file 'yaml.lib' [C:\ci\ws\build\rcl_lifecycle\rcl_lifecycle.vcxproj]

We might need an extra export or something? Not sure.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Mar 28, 2023

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

I noticed that the other project using this dependency, rcl_yaml_param_parser, switched over to using target_link_libraries away from ament_target_dependencies. That allowed it to hide yaml behind a PRIVATE dependency. I was hesitant to try that conversion and confuse the rest of this review, though

@clalancette
Copy link
Contributor

I noticed that the other project using this dependency, rcl_yaml_param_parser, switched over to using target_link_libraries away from ament_target_dependencies. That allowed it to hide yaml behind a PRIVATE dependency. I was hesitant to try that conversion and confuse the rest of this review, though

I almost think it is worth it, but there is enough going on here that we can punt it. Assuming what you did already fixes the problem for now, I'll do a follow-up where we switch to target_link_libraries, since it makes it a lot nicer.

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
@emersonknapp
Copy link
Collaborator Author

emersonknapp commented Mar 29, 2023

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Windows Build Status

@clalancette clalancette merged commit 973951d into ros2:rolling Mar 29, 2023
2 of 3 checks passed
achim-k pushed a commit to achim-k/rcl that referenced this pull request Apr 5, 2023
* Convert TypeDescription to YAML and hash

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Signed-off-by: Hans-Joachim Krauch <achim.krauch@gmail.com>
danthony06 pushed a commit to danthony06/rcl that referenced this pull request Jun 14, 2023
* Convert TypeDescription to YAML and hash

Signed-off-by: Emerson Knapp <emerson.b.knapp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants