rcl_yaml_param_parser: add support for binary tag to load byte array parameter #1256
+264
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
When a parameter is declared as an array of bytes (
std::vector<uint8_t>), passing an array of integers in the command line or in a YAML file is interpreted by the YAML parser as an array of integers and produces an error.To workaround this, I have used a base64 encoded string with the the
!!binarytag as shown in the YAML specification.Example:
Note that this implementation adds a dependency on OpenSSL which might not be acceptable (and the ugly global variable hack to use the custom allocator).
We might implement the base64 decoding directly in C or use another lib like libb64.
Until this question is resolved, I put this PR as a Draft.
The sequence handling is not very clear in
parse.cand might need some improvements.Fixes ros2/ros2#1436
Can be seen as part of #1026
Is this user-facing behavior change?
Yes, the byte array parameters are now supported as ros arguments or in yaml parameters files.
Until now, it was not supported at all, has decribed in ros2/ros2#1436.
Did you use Generative AI?
Yes, the
base64_decode()function has been written with the help of Mistral Le Chat.