ROS 2 joy_linux: better dev_name handling
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:
dev_namewill be matched against device identifiers as a substring, which is more flexible.- In case the
dev_nameis 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. - Setting the
joy_devparameter practically won't have any effect ifjoy_nameis 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.