-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Feature request
- Allow users to define a static topology during rmw_init, such that the system will allocate only as many resources as specified by the user.
Motivation
- Currently, ROS2 does not support the use of a static topology: the user gets to specificy exactly how many publishers, subscribers, topics, etc. a node needs, and thus the system allocates for exactly that many -- no more, no less. While Fast-RTPS and RTI Connext Pro do not require this feature, since they allow for dynamic allocation, I foresee that with the introduction of DDS-XCRE and the use of ROS in embedded devices, we will eventually have the need to statically allocate resources during initialization.
- While it is possible to over-allocate resources, this solution is obviously not ideal (especially if you are working in a low-resource device).
Feature description
-
We see two ways to implement this: 1) creating rmw_pre_init() and rmw_post_init() functions or 2) Passing a parameter to rmw_init that would be used to specify the topology.
e.g,: -
Option 1
rmw_ret_t rmw_pre_init(rmw_init_options_t * context_ptr) //not necessarily void *
{
//pre-init stuff here
return RMW_RET_OK;
}
rmw_ret_t rmw_post_init(rmw_init_options_t * context_ptr) //not necessarily void *
{
// post-init stuff here
return RMW_RET_OK;
}
int main(void)
{
rmw_init_options_t * context_ptr = ...;
rmw_ret_t retval = rmw_pre_init(context_ptr);
// Check for and handle errors
retval = rmw_init();
if (ret == RMW_RET_OK) {
retval = rmw_post_init(context_ptr);
// Check for and handle errors
} else {
// error handling...
}
return 0;
}- Option 2
rmw_ret_t entry_callback(void * caller_context_ptr)
{
// do pre-init stuff
return RMW_RET_OK;
}
rmw_ret_t exit_callback(void * caller_context_ptr, rmw_ret_t current_rmw_init_status)
{
// do post-init stuff
return RMW_RET_OK;
}
int main(void)
{
struct rmw_init_callbacks_t init_callbacks {
.m_caller_context_ptr = NULL,
.m_callback_at_rmw_init_entry = &entry_callback,
.m_callback_at_rmw_init_exit = &exit_callback
};
rmw_ret_t ret = rmw_init(init_callbacks); // new rmw_init
// error handling...
return 0;
}
rmw_ret_t rmw_init(const rmw_init_callbacks_t * callback_ptr) // new rmw_init
{
rmw_ret_t retval = RMW_RET_ERROR;
retval = callback_ptr->m_callback_at_rmw_init_entry(callback_ptr->m_caller_context_ptr);
// check for and handle errors
retval = old_rmw_init(); //old rmw_init
// check for and handle errors
retval = callback_ptr->m_callback_at_rmw_init_exit(callback_ptr->m_caller_context_ptr, retval);
// check for and handle errors
return retval
}** Credit to @wjwwood @serge-nikulin for the original examples (which I may have bastardized when I elaborated on them)
Implementation considerations
-
Option 1
- Pros;
- Backwards-compatible (if you haven't needed to do any pre-init or post-init steps, your code won't have to change).
- Cons:
- User code written initially for a dynamic topology will require some changes before it is compatible with the static DDS implementation.
- Pros;
-
Option 2
- Pros:
- When switching from a dynamic to a static topology, the user code will not have to change since the rmw implementation will handle the static allocation of resources. If the users have an idea of what resources are needed, they will be able to specify this in a configuration file, and if they don't, then there can be a default over-allocating configuration that can later be tuned for the specific use-case.
- Cons:
- Not backwards-compatible.
- Pros:
-
At a high-level for the static topology, you would need to specify a graph of how your nodes are connected and what kind of resources they need to communicate (on an edge-by-edge basis). e.g., :
- Number of nodes
- Per node:
- Number of publishers
- Number of subscribers
- Topics
- Per publisher/subscriber:
- Number of Writers/Readers
- Number of samples
- Routes between nodes
- QoS settings?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request