a method to dump all elements of a parameter as yaml#91
Conversation
|
+1, very useful! |
|
Out of curiosity why the flat structure and not the key-value structure like this: |
|
That's probably a better structure. It started as a cout and became 3, then migrated to yaml like syntax. |
|
It's not clear to me that one way is better than the other, since one is useful in dicts, but the other is useful as an element in a list. I'm just trying to imagine how you expect this to be used by users, by the system, or to recursively to build a tree of parameters. |
|
Instead of providing this functionality through a member function I would suggest to provide it either in a free function or through an yaml-specific entity. May be then also variations of this can be provided to match the different use cases @wjwwood mentioned. |
da9fd71 to
9c98522
Compare
|
Updated to be free functions and support both list and dict entry elements as well as turning a vector of params into a dict. There are unit tests added to ros2/system_tests#14 as well. It's ready for review but not necessary for the demos, so I'll hold off on triggering tests and it can be reviewed later. |
|
+1 again |
|
The functions can't be used to built nested output as-is. I think they should allow to use variable indentation to support that use case. Depending on what the future might bring (xml output, string output, yaml output for other classes) it might be better to move these cross cutting aspects into a separate file. |
|
lgtm, is this being used somewhere? I'd feel better about these functions being added if we had an actual example of them being used. |
|
@dirk-thomas There is no indentation they are one line json elements. Why can't they be nested? Each output is a valid block of json. It can be embedded in a list or dropped as a value in a dict. Except the intermediate helper function which produces a dict entry for use in building a multi parameter dict as used in the vector section. Separating them to another file makes sense. I'll do that. @wjwwood I used them for printf debugging, they got removed once I finished debugging. This is mostly a convenient way to print all three values quickly. |
|
Well, if it's just for debugging and printing, then a stream operator and or specialization of |
9c98522 to
92ba2a7
Compare
|
Refactored with @wjwwood 's suggestions. It's failing due to https://github.com/bengardner/uncrustify/issues/379 CI:
I will work around the above error and squash. |
…ant> to json encoded strings.
92ba2a7 to
b2e4b2a
Compare
|
lgtm. I'm not crazy about the |
|
Comments resolved new CI passing: |
There was a problem hiding this comment.
This method seems to only operate on the ParameterValue. Why is it provided in the ParameterVariant class?
There was a problem hiding this comment.
This provides the string for the value of a ParameterVariant. The ParameterValue is a private member of the ParameterVariant an inaccessible to the user. The method could be moved into ParameterValue except that it's a message. It could be a free function. But then we'd want to have a method on the ParameterVariant to expose it. We can refactor it to use a free function, but I just renamed it to disambiguate it from the new functions which print all the info of the ParameterVariant to string not just the value.
There was a problem hiding this comment.
From the meeting @dirk-thomas will make a more general ticket about this design issue for us to have a standard approach.
a method to dump all elements of a parameter as yaml
|
I have created ros2/ros2#130 to track that. |
Restore clear callback on QOSEventHandler destruction
This is a helper function I wrote when debugging the parameters I found it very useful to be able to print all 3 pieces of info to the screen quickly. I think it would be helpful to have similar functionality. Maybe a single line json style encoding would be more reuseable than this current one with newlines.
I know it's an expansion of the API but I think this will save people time down the line.
The current one isn't polished but I wanted people's feedback.
Thoughts?