Skip to content

ROS 2 joy_linux: better dev_name handling#301

Open
rayferric wants to merge 3 commits intoros-drivers:ros2from
rayferric:ros2-joy-linux-better-dev-name
Open

ROS 2 joy_linux: better dev_name handling#301
rayferric wants to merge 3 commits intoros-drivers:ros2from
rayferric:ros2-joy-linux-better-dev-name

Conversation

@rayferric
Copy link
Copy Markdown

@rayferric rayferric commented Feb 22, 2025

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.

@peci1
Copy link
Copy Markdown
Contributor

peci1 commented Feb 15, 2026

Changing the default behavior is an unwanted change in general, unless the behavior is really wrong. In this case, I think dev_name should block using dev only in case dev is explicitly set to empty string. That way, the original behavior would be kept while still allowing the behavior you want.

Also, please remove the unrelated change with publishing all zeros. This is a topic we should treat separately because it has some gotchas (i.e. triggers usually do have value 1 in the neutral pose (not sure if this is also true with SDL, but with linux joystick this is true)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants