Robotics StackExchange | Archived questions

Sensors not working when both plugged in

I am using a Jetson Nano dev kit, and have a RPlidar A2, and LPMS IMU. They both use a UART bridge (cp210x converter). When I only have 1 of the devices plugged in, I have no problems, but when I have both, neither one works. In my launch file I have specified device paths and also tried to run both separately. Any ideas what could be causing this?

Asked by chased11 on 2022-12-12 16:10:48 UTC

Comments

Answers

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.

Asked by Mike Scheutzow on 2022-12-14 09:40:53 UTC

Comments

If you have an existing 99-rplidar.rules file, you probably need to modify it because the default one seems to assume it's the only cp210x usb device in the system.

Asked by Mike Scheutzow on 2022-12-14 10:16:44 UTC

I do have both ports hardcoded into the launch file. I checked the ports before running launch as well. Even if I don't try to start both at the same time, and only launch one of the two sensors, but both are plugged in, they won't run at all. It's a weird issue I haven't seen before. I'll checkout the .rules file, I assume it's in the rplidar src folder?.

Asked by chased11 on 2022-12-14 13:02:55 UTC

Source is in rplidar_ros repo. On our robots it's installed to /etc/udev/rules.d/99-rplidar.rules

Asked by Mike Scheutzow on 2022-12-14 13:46:45 UTC

Hi Mike, I am just getting around to checking out the 99-rplidar.rules file. It appears there are bash scripts that both add and delete the rules from the /rules.d folder. I checked and the rplidar.rules is not in the rules.d folder. Should I run the script to add the 99-rplidar.rules file to /rules.d folder or is that how it's supposed to be?

I am looking to add a custom symlink as well as I will have to do that eventually regardless but understanding that will clear some things up.

Asked by chased11 on 2022-12-21 00:22:54 UTC

My first comment informed you that their rules file doesn't work correctly when there are multiple cp210x devices, but you want to install it anyway? Sure, fine with me. /s

Asked by Mike Scheutzow on 2022-12-21 07:54:19 UTC

Understood. Thanks for the help again.

Asked by chased11 on 2022-12-22 12:01:33 UTC