Consistent USB sensor device naming

Popular robotics sensors such as the Hokuyo laser range finder have a USB interface. Plugging in the sensor will normally cause Ubuntu to set up USB communication via the /dev/ttyACM0 port which allows the sensor to interface with the OS, provided the correct permissions are set.

The official hokuyo_node ROS package recommends using the following  udev rule to ensure that the Hokuyo sensor maintains a consistent device name regardless of the order in which sensors are plugged in:

KERNEL=="ttyACM[0-9]*", ACTION=="add", ATTRS{idVendor}=="15d1", MODE="0666", GROUP="dialout", PROGRAM="/opt/ros/kinetic/ rosrun hokuyo_node getID %N q", SYMLINK+="sensors/hokuyo_%c"

A general solution to this problem is to simply use the unique USB device ID to reference the sensor:

  1. List unique USB device ID: ls -l /dev/serial/by-id/ . For the Hokuyo sensor this command will return something similar to: usb-Hokuyo_Data_Flex_for_USB_URG-Series_USB_Driver-if00
  2. The port can now be set to: /dev/serial/by-id/usb-Hokuyo_Data_Flex_for_USB_URG-Series_USB_Driver-if00
  3. Set up permissions: sudo usermod -a -G dialout $USER

That’s it. The sensor will now be recognised by its unique ID with permissions set and can be plugged into any port.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s