ros2_control icon indicating copy to clipboard operation
ros2_control copied to clipboard

Public method to check if command interfaces are claimed using ControllerManager or SystemInterface?

Open shonigmann opened this issue 2 years ago • 4 comments

Is it possible to directly check whether a command interface is claimed through the ControllerManager?

I'd like to work on a fix to ros-simulation/gazebo_ros2_control#85, where the Gazebo ROS2 Control Plugin is unable to support more than one command interface type even when only one is claimed at a time.

The most direct approach feels like it would involve querying the ResourceManager's command_interface_is_claimed() method, but the resource_manager_ is private within the ControllerManager.

I was thinking of putting the check in the Gazebo plugin's Update() loop, so I was hoping to avoid using the service interface which feels like it would be too slow. I'm not aware of any events that I could subscribe to that would let me monitor for changes in claimed resources, but would be open to taking that route if its available.

And hopefully this isn't out of place on the issue tracker. I can move this over to ROS Answers if that would be more appropriate.

Edit - the gazebo_ros2_control GazeboSystem extends the SystemInterface class so this would be the most direct path if there is an option for the system interface to have a public method to expose claimed interfaces.

shonigmann avatar Mar 30 '22 02:03 shonigmann

For the time being I am using the ControllerManager's ListControllers service interface, which does provide the desired functionality... That said it takes ~1ms to call, so its definitely not ideal to run inline with the update loop. An event based approach would be wonderful if it exists.

shonigmann avatar Apr 01 '22 19:04 shonigmann

Hi,

This is a correct place for this, because it is a bug fix on the framework.

This should be managed by internal flags that are set in "prepare_command_mode_switch" and "perform_command_mode_switch". There you have exact information which interfaces are used in controller that will be activated or deactivated. This being said, you know exactly hoch interfaces are exactly used in any given moment of time.

Any other approach is mixing layers of the framework I And it is not guaranteed to work as intended.

destogl avatar Apr 03 '22 11:04 destogl

Hi @destogl - thank you for your response.

I agree that it would make sense for the perform_command_mode_switch() method to set a set/unset flags denoting that interfaces are claimed, and it would make sense for prepare_command_mode_switch() to check against those flags.

Just to clarify, are you suggesting that the aforementioned flags need be added to the base Actuator / System implementations?

shonigmann avatar Apr 06 '22 01:04 shonigmann

Just to clarify, are you suggesting that the aforementioned flags need be added to the base Actuator / System implementations?

I was also thinking about hat, but since flags are dependent on the hardware and its implementation, I am uncertain if we can make a sensible generic solution to it.

Let us know if you have some ideas about generalizing your implementation. You will for sure have more knowledge/experience about it.

destogl avatar Apr 06 '22 10:04 destogl