The issue is that the /dev/ttyUSB0 and 1
device names are not consistently assigned to a specific external usb device.
The ttyUSBx device names are dynamically assigned by the kernel as the devices are plugged in (or become visible to the kernel at boot time), so the number MAY change each time you boot the computer. This means you should not hard-code the path /dev/ttyUSB0
into your ros launch file if you expect more than one such USB device will be present.
If the manufacturer provides an API to probe the device to confirm it is an X, you can use that with a system udev
rule to create a custom device symlink e.g. /dev/rplidar
. You can then safely use this custom device name in your ros launch file. This approach works only if there is zero or one rplidar devices attached.
There is an uglier approach where you use the physical USB port to identify a type of device. Look at the path in the links in /sys/bus/usb-serial/devices/
directory. The parent path does not change across reboots. This approach requires that you create a custom script, and run it from system udev
when it detects that a generic cp201x usb device is plugged into the computer.