ros2_control icon indicating copy to clipboard operation
ros2_control copied to clipboard

How to pass additional information to the hardware interface

Open guidout opened this issue 2 years ago • 3 comments

Background

Hi, I have posted a question on Stack Exchange about CAN messages and hardware interfaces but I think the question can be generalized.

My issue (maybe it's already possible but I'm not aware of how) is how to pass additional information to the hardware interface besides commands and states. In my use case, I have to interface with an existing vehicle CAN bus (so I can't change the messages' definitions) and the hardware interface will send steering and throttle commands to the existing vehicle module. Each CAN message has more information than just the command and/or the sensor. So I need a way to get that information down to the hardware interface so that it can generate a complete CAN message. This additional information could come either from a node or from a controller.

Is there an already existing mechanism to accomplish this?

Thank you in advance

guidout avatar May 10 '23 14:05 guidout

This may be relevant. You can look at the Issue linked in the following PR https://github.com/ros-controls/ros2_control/pull/1012

Specifically, at least the way I intend to use that PR is as follows:

  • Specify some sort of unique string for 'command_data'.
  • In the ros2 control xacro file, have a bunch of params that have that unique string as a prefix. Then you can access that info in the hardware interface.

swiz23 avatar May 18 '23 17:05 swiz23

yes, please check how we have solved this in the ros2_canopen repository. There you can find ideas, the right amount of abstraction you have to do yourself.

@Xi-HHHM is just adding detailed docs about ros2_canopen, so this can also help you to understand the concepts - note that this description is subject to changes – we just want to structure this better.

Also note that I don't agree with @swiz23's solution as it can be solved much nicely.

destogl avatar May 30 '23 12:05 destogl

This is an old issue, but for new people who are looking for a solution, an alternative to ros2_canopen could be the feature proposed in the PR https://github.com/ros-controls/ros2_control/pull/1240

mateusmenezes95 avatar Feb 01 '24 00:02 mateusmenezes95