micro-ROS / micro_ros_utilities

General utilities for easing the usage of micro-ROS on different platforms
Apache License 2.0
8 stars 5 forks source link

Documentation/explanation for memory_rule_t/memory_conf_t? #37

Open gavanderhoorn opened 2 years ago

gavanderhoorn commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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