Showing posts with label Kinect. Show all posts
Showing posts with label Kinect. Show all posts

Wednesday, October 22, 2014

Openni2 error: No matching device found.... waiting for devices.

I use openni2 with ROS with the ASUS Xtion Pro live (new model with rectangular less instead of the oval one) for capturing data.

However, suddenly openni2_launch stopped working.

$roslaunch openni2_launch openni2.launch

kept giving the following error:

Warning: USB events thread - failed to set priority. This might cause loss of data...
[ INFO] [1414001657.842030853]: No matching device found.... waiting for devices. Reason: openni2_wrapper::OpenNI2Device::OpenNI2Device(const string&) @ /tmp/buildd/ros-hydro-openni2-camera-0.1.3-0precise-20140921-1219/src/openni2_device.cpp @ 74 : Initialize failed
    Could not open "1d27/0601@3/3": USB transfer timeout!

I found solutions for openni for the same problem, but not for openni2.

Although I could not figure out the exact reason for this sudden change in behaviour, trying to re-install the ros-hydro-openni drivers helped to resolve this issue (Thanks to Andreas :) ).

So if you get the same problem, try doing this:

$ sudo apt-get remove ros-hydro-openni2-*

$sudo apt-get install ros-hydro-openni2-camera

$sudo apt-get install ros-hydro-openni2-launch

Tuesday, October 7, 2014

Grab Pointclouds and save as pcd files using ROS and Openni

1) Install ROS Hydro Openni2 packages:

$sudo apt-get install ros-hydro-openni2-camera ros-hydro-openni2-launch

2) Run ROS

$roscore

3) Launch openni

$roslaunch openni2_launch openni2.launch

4) Launch RViz

$rosrun rviz rviz

5) Do settings in RViz to receive data from Kinect

6) Back in terminal, use the following command to save the point clouds


$rosrun pcl_ros pointcloud_to_pcd input:=<your target topic name>
 
For ex:
$ rosrun pcl_ros pointcloud_to_pcd input:=/camera/depth_registered/points
The output is :

[ INFO] [1412698428.630599815]: Listening for incoming data on topic /camera/depth_registered/points
[ INFO] [1412698428.870419685]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698428.870483694]: Data saved to 1412698428747359.pcd
[ INFO] [1412698429.421970793]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698429.422065179]: Data saved to 1412698429281241.pcd
[ INFO] [1412698429.979569838]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698429.979637397]: Data saved to 1412698429848510.pcd
[ INFO] [1412698430.495591052]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698430.495632948]: Data saved to 1412698430415787.pcd
[ INFO] [1412698430.974854796]: Received 307200 data points in frame /camera_rgb_optical_frame with the following fields: x y z rgb
[ INFO] [1412698430.974940083]: Data saved to 1412698430882933.pcd
 
(Ref: http://answers.ros.org/question/47345/kinect-point-cloud-to-pcd-files/ )
This will keep dumping the pointcloud files until you stop the process (ctrl + c).


Quick PCL commands to capture data using Kinect

$ pcl_openni_viewer
 press 'r' to visualize the point cloud. Pointcloud appears inverted manner. have to use mouse to see in correct orientation.

you can see 2 windows (PCL OpenNI cloud, PCL OpenNI Image)

$ pcl_openni_save_image  (saves depth and RGB image in .tiff format... You have to stop it if you want to save only 1 frame.)


View the depth image in octave:

$octave
octave:1> imshow('1_1_depth.tiff' , [])

$ pcl_openni_grabber_example
Warning: USB events thread - failed to set priority. This might cause loss of data...
<Esc>, 'q', 'Q': quit the program
' ': pause
's': save


$ pcl_viewer pcd_file.pcd
(press r to view, 5 to see color)