joystick_drivers icon indicating copy to clipboard operation
joystick_drivers copied to clipboard

ROS 2 joy_linux: better dev_name handling

Open rayferric opened this issue 10 months ago • 0 comments

Addresses various problems with the dev_name parameter, which does not work as flexibly and reliably as we would like.

Originally, if dev_name was specified, the node looked for a device with this identifier during initialization. If it could not be found, the node fell back to the device specified in joy_dev.

With my changes:

  1. dev_name will be matched against device identifiers as a substring, which is more flexible.
  2. In case the dev_name is not found during initialization, the node won't connect to the default device, but rather will keep waiting for the name to match, retrying every second.
  3. Setting the joy_dev parameter practically won't have any effect if joy_name is specified. The node will keep searching for the name.

This makes it possible to specify a gamepad model that you expect to be connected to the PC. The node will then only connect to this type of gamepad and keep reconnecting if the connection is dropped. It is resilient to faulty USB connectors, since during reconnection we have no guarantee that the same /dev/input/jsN will be allocated.

Unrelated change: publish zeros to /joy in the moment the device is disconnected.

rayferric avatar Feb 22 '25 14:02 rayferric