Rosanswers logo

Hi folks,

I'm using openni_camera and kinect_aux (for tilting function) stacks at the same time and they work well together. The problem came in when I used two kinects connected (they are not used together they are just connected!) and I want to choose one of them at a time. This is straight forward for openni_camera stack where u only need to change launch file to launch the camera with a specified serial number. But for kinect_aux there is no way to choose a specific NUI motor since kinect NUI motor does not have any serial number assigned to it! so when I run "lsusb -v" I see two completely equal NUI motor descriptions with no serial number on different device addresses.

How can I make sure that this motor on bus address e.g. 15 belongs to the kinect camera on bus 17 and not camera on bus 20!? The arrangement of the devices in the list changes randomly every time I unplug and plug or replace the kinects. So I could not find any specific relation between cameras and motors and their bus address numbers!

I only have one bus with three ports. I also should mention that setting "device_index" parameter in kinect_aux does not help since the order of kinects changes on unplugging/plugging.

I copied lsusb -v of one of the motors (the other one looks exactly the same)

Bus 002 Device 016: ID 045e:02b0 Microsoft Corp.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x045e Microsoft Corp.
  idProduct          0x02b0
  bcdDevice            1.07
  iManufacturer           1 Microsoft
  iProduct                2 Xbox NUI Motor
  iSerial                 0 ---------------------->(no serial provided!)
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           18
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           0
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              0
Device Status:     0x0000
  (Bus Powered)

Originally posted by Amin on ROS Answers with karma: 93 on 2012-05-21

Post score: 1


1 Answer 1


Rosanswers logo

Alright. It solved. You need to identify the device you need through its physical address. In other words, you need to know the topology of your USB ports. What I did was to modify the function openAuxDevice in kinect_aux.cpp to:

void openAuxDevice(int dev_number) {

libusb_device **devs; //pointer to pointer of device, used to retrieve a list of devices
ssize_t cnt = libusb_get_device_list(0, &devs); //get the list of devices
if (cnt < 0) {
    ROS_ERROR("No device on USB");

for (int i = 0; i < cnt; ++i) {

    const int r = libusb_get_device_descriptor(devs[i], &desc);
    if (r < 0)

    if ((int) libusb_get_device_address(devs[i]) == dev_number
            && desc.idProduct == MS_MAGIC_MOTOR_PRODUCT && desc.idVendor
            == MS_MAGIC_VENDOR) {
        std::cout << "Kinect with dev no. " << dev_number << " opened."
                << std::endl;
        libusb_open(devs[i], &dev);
        libusb_claim_interface(dev, 0);
libusb_free_device_list(devs, 1); // free the list, unref the devices in it

Then in the my script I added,

d=$(cat /sys/bus/usb/devices/2-1.1.2/devnum &)
rosparam set device_index $d &
rosrun kinect_aux kinect_aux_node &

Note that, 2-1.1.2 means the second bus, 1st hub, again 1st hub and then port number 2. This is where i connected one of the kinects. The other one is connected to 2-1.2.2.

FYI, you can check these out: http://www.linux-usb.org/FAQ.html#i6 http://reactivated.net/writing_udev_rules.html

Originally posted by Amin with karma: 93 on 2012-05-24

This answer was ACCEPTED on the original site

Post score: 1


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.