Setting up UDEV rules

Template for clopema UDEV rules file

The serial number are based on the CVUT hardware so please change them accordingly. How to do this is described below. For more information about UDEV rules please refer to [3].


# CloPeMa UDEV rules
ACTION!="add|change", GOTO="clopema_end" 

# Robot Head cameras
SUBSYSTEM=="usb", ATTR{idVendor}=="04b0", ATTRS{idProduct}=="0429", ATTR{serial}=="000006372504", GROUP="plugdev", MODE="0660", SYMLINK="nikon_left" 
SUBSYSTEM=="usb", ATTR{idVendor}=="04b0", ATTRS{idProduct}=="0429", ATTR{serial}=="000006623780", GROUP="plugdev", MODE="0660", SYMLINK="nikon_right" 

# Gripper rubbing arduinos 
KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="13JP0077", GROUP="plugdev", MODE="0660", SYMLINK+="r1_arduino" 
KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="14P03264", GROUP="plugdev", MODE="0660", SYMLINK+="r2_arduino" 

# Photometric stereo
KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6015", ATTRS{serial}=="DN002WY5", GROUP="plugdev", MODE="0660", SYMLINK="ps_arduino" 
KERNEL=="video*", ATTRS{idVendor}=="045e", ATTRS{idProduct}=="076f", GROUP="plugdev", MODE="0660", SYMLINK+="ps_video" 

LABEL="clopema_end" 

Rules for Nikon cameras

To find the bus, device id, vendor I have issued the following command:

$ lsusb
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 003 Device 002: ID 04b0:0429 Nikon Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 014: ID 1d27:0600
Bus 001 Device 004: ID 1a40:0101 Terminus Technology Inc. 4-Port HUB
Bus 002 Device 003: ID 1d27:0601
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 006: ID 1b67:0010
Bus 001 Device 007: ID 04b0:0429 Nikon Corp.

We can see that the Nikons and on bus 1 and 3, device 7 and 2 respectively. Now
we can found out the full path of the device on bus 1 by issuing the following
command:

$ sudo udevadm info -q path -n /dev/bus/usb/001/007
/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4

The the full specification of the device by issuing the following command:

$ sudo udevadm info -a -p /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2.4
...
ATTR{serial}=="000006372504"
...

Did the same with the second camera:

$ sudo udevadm info -a -p /devices/pci0000:00/0000:00:14.0/usb3/3-3
...
ATTR{serial}=="000006623780"
...

Now I can make the udev rules that will match each Nikon and make a simlink for
it in order to distinguis between them.

# udev rule for Nikon cameras
ACTION!="add|change", GOTO="nikons_end" 
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="0429", ATTR{serial}=="000006623780", GROUP="plugdev", MODE="0660", SYMLINK="nikon_left" 
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b0", ATTRS{idProduct}=="0429", ATTR{serial}=="000006372504", GROUP="plugdev", MODE="0660", SYMLINK="nikon_right" 
LABEL="nikons_end" 

[1]: http://buzzdavidson.com/?p=45
[2]: http://www.jpichon.net/blog/2011/12/debugging-udev-rules/
[3]: http://reactivated.net/writing_udev_rules.html#udevinfo

Rules for Xtions

Xtions can't be distinguished using the UDEV rules as they do not have serial number, so the bus is the only clue apart from that PrimesSense has different product id.