0
$\begingroup$

Rosanswers logo

Hi,

I am transferring my robot hardware interface to ROS2. In my ROS1 hardware interface, I used a publisher to publish additional information like the current controller temperature, limit switches status etc. However, in ROS2, I could not find a way to access the node from the hardware interface plugin, so creating a publisher is not possible anymore.

Is it possible to get access to the node in a hardware interface plugin? Or, if not, what is the preferred way to communicating additional hardware state information in ROS2?

Thanks!


Originally posted by rick95 on ROS Answers with karma: 3 on 2023-04-04

Post score: 0

$\endgroup$

1 Answer 1

1
$\begingroup$

Rosanswers logo

Afaik, "nothing has changed" wrt the best / accepted practices in ros2_control vs ros_control. See #q375296 for a previous Q&A which discussed a similar topic (related: ros-controls/ros2_control#740, although that issue asks whether using pub-sub for interaction with the actual hw would be acceptable/ok -- it links to the ROS Answers Q&A though).

Summarising: the cleanest way to publish the kinds of information you mention would be from ros2_control broadcasters (used to be called controllers, but they only published information, so the name was (finally) changed).

You could take a look at UniversalRobots/Universal_Robots_ROS2_Driver which follows that recommendation for things like GPIO and some other status information.


Originally posted by gvdhoorn with karma: 86574 on 2023-04-05

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by rick95 on 2023-04-05:
Thanks for your answer! So, if I understand it right, I need to add additional state interfaces (hardware_interface::StateInterface) for the additional state information. Then the joint_state_broadcaster publishes the additional state information on a topic.

Comment by gvdhoorn on 2023-04-05:
Almost.

You'd add your own custom hardware interfaces, for which you then would need to implement your own custom broadcasters.

The default joint_state_broadcaster would only "know" how to publish JointState messages. It can't do anything with your custom state information.

I used a publisher to publish additional information like the current controller temperature, limit switches status etc.

for limit switches specifically, you might be able to reuse the GPIO infrastructure in ros2_control. That is, if you don't necessarily need any higher level semantics for that (ie: instead of "pin 3 is high", you'd want "limit switch of motor/joint 'elbow' is high").

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.