Deterministic startup of hardware interfaces
Is your feature request related to a problem? Please describe.
Currently the setup order of hardware interfaces is non deterministic in the way that when we have multiple hardware interfaces the order of: init, configure,activate is not staged.
By staged I mean that all hardware interfaces have to finish a specific stage before any hardware interface can go into the next stage
Example with two hardware interfaces
Interface A -> on_init Interface B -> on_init
Interface A -> on_configure Interface B -> on_configure
Interface A -> on_activate Interface B -> on_activate
-> When all interfaces are done -> start read/write
This would help a lot in our case with sharing common hardware resources (ethercat bus master) between hardware interfaces.
Describe the solution you'd like
I suggest adding an additional flag to the configuration of the controller manager (e.g. deterministic_startup)
which enforces in the resource manager the staging procedure described above.
Describe alternatives you've considered
I currently see for our case only two alternatives:
a) Introduce a separate process which handles the setup and have the hardware interfaces communicate with that process -> But then I do not have to use ros2control at all b) Basically introduce our own state machine in all related hardware interfaces which the startup procedure
Additional context
Questions:
- Would a PR with such a feature be appreciated ?
- Is there any big show stopper I am not aware of that prohibits implementing such a feature ?
This sounds reasonable, but I'd like to see the opinion of @saikishor @destogl or @bmagyar on this.
How do you share the resources across different hardware plugins? Can you provide a solution for #1956?
We implemented a singleton for our ethercat bus master which is shared between the different instances. It is actually open source: https://github.com/Duatic/ethercat_sdk_master/blob/master/include/ethercat_sdk_master/EthercatMasterSingleton.hpp
Basically the idea is that every hardware interface registers the devices to the bus master instance and obtains a handle. When the hardware interface is in the configuration step we call markAsReady and if all handles have been marked as ready we start the bus.
In addition we currently need code which checks in read/write if the master has been started yet.
But in general this approach is hard to properly handle in detail especially because with ethercat we also need to worry about timing.
Hello @firesurfer
We can discuss about that parameter, but let's brainstorm a bit because you might want n of the m components to start synchronized but the others not? Let's try to find a common ground?
What's the reason behind the Singleton EtherCAT master? Why not a System component directly?.
For now, you might be able to achieve the same with the hardware component services atleast
Hey @saikishor
We can discuss about that parameter, but let's brainstorm a bit because you might want n of the m components to start synchronized but the others not? Let's try to find a common ground?
Do I understand you correctly that you suggest only synchronizing selected components ? Sound like a nice addition but makes implementation of course more difficult
What's the reason behind the Singleton EtherCAT master? Why not a System component directly?.
Its been quite some time since I actually did the initial implementation and also checked there for better options. As far as I am aware there is not really a better option for sharing common resources between hardware interfaces ? Its basically the same issue as in https://github.com/ros-controls/ros2_control/issues/1956
@saikishor just as friendly ping - I would really like to hear your input before starting to work on this feature
@firesurfer I already got a nice idea, I forgot to write it here. Sorry about that
The current hardware components XML support an argument call group, basically we use to make sure that if one of the group actuator is in error, we take down the whole group. You could use that information to be able to group the components together and then start them in the order as you wanted?. Will that work for you