Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS 2 joy_linux: better dev_name handling #301

Open
wants to merge 3 commits into
base: ros2
Choose a base branch
from

Conversation

rayferric
Copy link

@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.

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.

1 participant