Ask Your Question
0

ros2_control publish/subscribe topic & action? good or bad?

asked 2021-04-02 17:32:28 -0600

RandyD gravatar image

updated 2021-04-02 17:33:24 -0600

Situation:

I implemented a ros2_control hardware interface and custom controller for my mecanum wheeled robot. This all works fine for driving the wheeled robot, but what would be best practice for implementing "actions" like emergency brake or sending sensor information like bumpers state? In case the robot hit something, the read() method will get the information from the board and can have internal state to make the robot stop. Still i want this information available in other nodes as well. Also other nodes might have a reason as well to make sure the robot stops imideatly.

Is it a good or bad idea to publish & subscribe directly inside the hardware interface or should i try to get this information trough joints and handle it in the custom controller?

Kind regards,

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2021-04-03 01:49:10 -0600

gvdhoorn gravatar image

Is it a good or bad idea to publish & subscribe directly inside the hardware interface

A "bad" one, as it violates separation of concerns.

hardware_interface implementations should be responsible for interacting with the hw only, not providing ROS interfaces. hardware_interfaces expose a number of resources, manage data conversion from whatever the hw needs to more generic representations and vice-versa and some related activities. Layering a ROS interface on-top of that is the responsibility of other entities in a ros_control stack.

This was already not really a "good idea" in ros_control (ie: the ROS 1 version), but many hardware_interface implementations did do it (the realtime_tools package made this too easy).

or should i try to get this information trough joints and handle it in the custom controller?

No need to "get this information trough joints": there is work underway to allow for arbitrary resources to be exposed, which could then be claimed by broadcasters (new name for something which does not actually control anything) or controllers. Those two would then expose services and actions and publish to topics.

edit flag offensive delete link more

Comments

Could you please mark the question as answered by ticking the checkmark (✓) to the left of the answer if you feel it has been answered? Thanks.

gvdhoorn gravatar image gvdhoorn  ( 2021-04-04 11:11:45 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-04-02 17:32:28 -0600

Seen: 104 times

Last updated: Apr 03