In addition to its cliff sensors and bumpers, Kinect is one of the ways TurtleBot “sees” its environment. We’ve already installed the drivers for Kinect so now we’ll test it to make sure it works.

Test Driver and USB Connection (TurtleBot Only)

Before doing anything, check the default 3D sensor of TurtleBot by printing an environment variable and confirm the output:

echo $TURTLEBOT_3D_SENSOR
# Output: kinect

If you see another 3D sensor, for example asus_xtion_pro, you will need to set the default value of the environment variable in .bashrc and restart your terminal:

echo "export TURTLEBOT_3D_SENSOR=kinect" >> .bashrc

On TurtleBot, close all terminals, then open a new window and run:

roslaunch turtlebot_bringup minimal.launch

Then open another terminal window and run:

roslaunch openni_launch openni.launch

If you get a collection of lines that start with process[camera... everything is perfect and you can skip the troubleshooting section below and move on to the “View Image Data” section. Leave the two terminal windows open.

TurtleBot Bringup & Openni for Kinect

Troubleshooting

If you repeatedly receive:

[INFO][#]: No devices connected.... waiting for devices to be connected

this is probably because the Kinect driver wasn’t installed. See Install Kinect Driver in our previous post.

If you receive:

terminate called after throwing an instance of 'openni_wrapper::OpenNIException'

or

Image: PrimeSense/SensorV2/5.1.2.1: Failed to set USB interface!

these have occurred because Kinect isn’t compatible with USB 3.0. Plug it into a USB 2.0 port. (Problems can also occur with USB 2.0 ports that are 3.0 compatible.).

Troubleshooting: I don’t have a USB 2.0 port or it’s still giving the above errors

We’re going to disable USB 3.0 in the BIOS.

  1. Boot into BIOS by rebooting your computer and holding down the F2 key (it could be a different key on your computer).
  2. Go to the advanced tab.
  3. This part varies depending on your computer. If you have a USB option go there first.
  4. If your BIOS lists xHCI, disable it.
  5. If your BIOS lists USB Debugging, enable it.
  6. Save and exit BIOS.

Troubleshooting: Kinect’s USB connection is dropping randomly

On some GNU/Linux systems, specific power settings may drop the USB connection of Kinect. In order to prevent this, run this command, plug Kinect out and in:

sudo bash -c 'echo -1 > /sys/module/usbcore/parameters/autosuspend'

If you still have trouble, check that the Kinect has power by running:

lsusb

and verify that there are three lines about Microsoft Corp., two of which are regarding XBox NUI. If you only have one line or none, Kinect may not be plugged in or is lacking power.

View Image Data (Workstation)

Close all terminal windows, open a new one, and run:

rosrun image_view image_view image:=/camera/rgb/image_color

You should see a live video stream from the Kinect. Press ‘q’ to quit.

This is not much more exciting than a webcam, so let’s see a visual representation of distance by running:

rosrun image_view image_view image:=/camera/depth/image

You should see a grayscale video stream where objects closer to the Kinect appear darker.

TIP: If you see only solid gray, check that you are still running openni.launch on TurtleBot.

Press ‘q’ to quit the depth image.

Kinect RGB & Depth Images

Stop Openni (TurtleBot)

Go to the terminal on TurtleBot where openni is running. Press ctrl + C to stop it. Leave minimal.launch running. Now run:

roslaunch turtlebot_bringup 3dsensor.launch

3dsensor.launch

RViz (Workstation)

Close all terminal windows, then open a new one and run:

roslaunch turtlebot_rviz_launchers view_robot.launch

Under “Displays” check “Registered DepthCloud” and “Image”. Hold down the left mouse button to rotate or the middle mouse button to move the camera.

NOTE: If you don’t see the display panel, scroll your mouse to the top of the screen and click “Panels”. Check the box next to “Display Panel” to enable it.

If you have trouble, here’s a YouTube walkthrough:

RVIZ Display Panel

Learn more at wiki.ros.org

TIP: To complete the follower demo you may need to install libfreenect as mentioned on ROS Answers.

Troubleshooting

If you get a warning about “no image available”, try closing everything on both TurtleBot and workstation and then re-opening.