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

Documentation/explanation for memory_rule_t/memory_conf_t? #37

Open
gavanderhoorn opened this issue May 24, 2022 · 6 comments
Open

Documentation/explanation for memory_rule_t/memory_conf_t? #37

gavanderhoorn opened this issue May 24, 2022 · 6 comments

Comments

@gavanderhoorn
Copy link
Contributor

Especially with more complex messages, the convenience of being able to use a set of micro_ros_utilities_memory_rule_t in a micro_ros_utilities_memory_conf_t and pass that to micro_ros_utilities_create_message_memory(..) is very nice.

I've not been able to locate any documentation for this feature though, other than Handling messages memory in micro-ROS - micro-ROS Galactic and beyond. That section shows a very terse example of specifying a set of rules for the example message, but doesn't go into very much detail.

Would you have any additional documentation available for this feature, specifically the structure of the rules and how they should match fields?

@gavanderhoorn
Copy link
Contributor Author

gavanderhoorn commented May 24, 2022

One question I'd have fi would be: for messages containing other (nested) messages, like a.b.c.d, where b and c are both sequences, but a and d are not, would the rules simply be:

micro_ros_utilities_memory_rule_t rules[] = {
  {"a.b", 4},
  {"a.b.c", 5},
}

to allocate for 4 instances of whatever type b is, and 5 instances for c?


And how would (max) string lengths be specified for a string[] in a message, such as:

string[] my_strs

Both my_strs should get a max length, but the individual strings as well.

@pablogs9
Copy link
Member

No, we do not have any more documentation on that, it would great to improve this part.

Regarding your second question, I should check in the codebase because I did it a long time ago, but as far as I remember sequences are not handled. So

micro_ros_utilities_memory_rule_t rules[] = {
  {"a.b", 4},
  {"a.b.c", 5},
}

This means that each a member will have a sequence of 4 bs and each b will have a sequence of 5 cs, if I'm not wrong.

Also, we should take a look at the sequences of string configuration.

I will keep this open so we can do it after the micro-ROS Humble release (it is being time consuming).
In any case, this feature is a naive implementation, so feel free to take a look and contribute if you have more specific ideas.

@gavanderhoorn
Copy link
Contributor Author

gavanderhoorn commented May 24, 2022

as far as I remember sequences are not handled

I'm confused.

Isn't one of the main advantages of the rule-system the fact it makes setting up a msg structure with sequences much more convenient?

Or are only strings currently really supported?

So

micro_ros_utilities_memory_rule_t rules[] = {
  {"a.b", 4},
  {"a.b.c", 5},
}

This means that each a member will have a sequence of 4 bs and each b will have a sequence of 5 cs, if I'm not wrong.

yes, that's what I wrote, isn't it (just making sure)?

@pablogs9
Copy link
Member

I'm confused.

Sequence members individually. I mean you cannot specify that b[0] as c of size 5 and b[1] as c of size 3.

yes, that's what I wrote, isn't it (just making sure)?

That's right

@gavanderhoorn
Copy link
Contributor Author

gavanderhoorn commented May 24, 2022

Sequence members individually. I mean you cannot specify that b[0] as c of size 5 and b[1] as c of size 3.

Yes, ok. Clear.

It's always going to spec the same sizes for all members of a field, if that field is a sequence.

yes, that's what I wrote, isn't it (just making sure)?

That's right

So contrary to how you'd access the data itself (by field_name->data[i]), you never actually add .data to the names in the rule(s). Correct?

@pablogs9
Copy link
Member

So contrary to how you'd access the data itself (by field_name->data[i]), you never actually add .data to the names in the rule(s). Correct?

That's it

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

No branches or pull requests

2 participants