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

DDS Generator #322

Open
jalexcole opened this issue Feb 9, 2024 · 4 comments
Open

DDS Generator #322

jalexcole opened this issue Feb 9, 2024 · 4 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@jalexcole
Copy link

Is there going to be a DDSGen for this library that can read a idl, xml and produce a rust crate from it? If this would be included it looks like dust-dds has there own and that code might be able to be lifted in order to facilitate this. Workspaces should also likely be used.

https://github.com/s2e-systems/dust-dds

@jhelovuo
Copy link
Owner

Such a code generator is not on the roadmap, as you seem to be the first one to ask for it. So far most of our use cases have used fairly few and simple message types, so coding by hand has been easy enough.

However, the idea is good, and a generator should be fairly straightforward to implement. If you decide to do it, please submit a PR.

There is already a similar generator in ros2-client, but it uses ROS2 .msg definitions as source.

@jhelovuo jhelovuo added enhancement New feature or request question Further information is requested labels Feb 14, 2024
@jalexcole
Copy link
Author

I can work on it. How does RustDDS handle sequences. For example http://community.rti.com/rti-doc/500/ndds/doc/html/api_cpp/group__DDSBuiltinSequenceModule.html

@jhelovuo
Copy link
Owner

CDR Sequence type maps to Vec in Rust.
CDR Array maps to a fixed-length array in Rust.
CDR String maps to Rust String, although this is slightly wrong. Rust Strings must be valid UTF-8, whereas CDR Strings may not be. This could be circumvented by mapping to e.g. Vec<u8> instead.

RustDDS does this via Serde , so the actual mapping is there. Please see the serialization module for details.

@jalexcole
Copy link
Author

jalexcole commented Feb 23, 2024

For sequences I am thinking of something like type BoundedSequence<T, const N: usize> = Vec<T>;
This would allow for a Sequence<T> trait to be built and a BoundedSequence<T, N> struct made so that the std version can have a internal Vec, and the no:std version can have an internal array.

Regarding strings there is a FixedStr library that can be used, however something belonging to RustDDS may be preferred that can handle the u8's internally. https://docs.rs/fixedstr/0.5.5/fixedstr/index.html

The hard part in code generation would be handling Value type inheritance. This will likely have to be done with a proc macro.

This may be an ongoing discussion of how to implement idl features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants