Skip to content

Conversation

@romainreignier
Copy link

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 !!binary tag as shown in the YAML specification.

Example:

ros2 run pkg_name exe_name --ros-args -p 'my_param:=!!binary AAECAw=='

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.c and 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.

… parameters

This allows to pass byte array parameters using the [binary tag](https://yaml.org/spec/1.2.2/#24-tags)

Example:
```
ros2 run pkg_name exe_name --ros-args -p 'calib:=!!binary AAECAw=='
```

Address ros2/ros2#1436

Can be seen as part of ros2#1026

Signed-off-by: Romain Reignier <[email protected]>
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.

No way to pass a byte array with ros2 run

1 participant