Jarvis Schultz October 19, 2011 skeletontracker_nu ROS package
Source Repository: https://github.com/jakeware/skeletontracker_nu
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% BASIC INFO %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% This ROS package essentially provides wrapper functions and launch files that facilitate easy skeleton tracking and recording using the Kinect and the NITE SDK. To run it you must have ROS installed (currently this package works with electric, but diamondback should work as well.) This package additionally depends on the skeletonmsgs_nu package available at https://github.com/jakeware/skeletonmsgs_nu and the motion_planning_common ROS stack available at www.ros.org
The main source code contained in ./src/skeletontracker_nu.cpp essentially implements the skeleton tracking functions of NITE, and publishes the tracking data as both tf topics and as a topic called /skeletons and /skeletonpmaps. The tf topic contains transformation data from the Kinect's coordinate systems out to the coordinate system located at each joint of a user being tracked. The /skeleton topic contains the x,y,z position of each joint of each user as a custom message type defined in the skeletonmsgs_nu package. The /skeletonpmaps topic publishes the skeleton tracking data in the form of a "polygonal map" defined in the mapping_msgs ROS package (part of the motion_planning_common stack). This topic is simply for viewing the wireframe skeleton representation in rviz.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%% OPERATION INFORMATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This launch file does several important things; first it starts the Kinect driver and sets its output to print to its own xterm window, then it starts the skeleton tracker and sets its output to a new xterm window. Both of these nodes are set to respawn, so if you close one of the xterm windows they will automatically restart. To shutdown the entire system, press "CTRL+c" in the terminal that executed the launch file. The launch file also starts up the ROS visualizing tool rviz with settings that should be fairly appropriate for viewing the skeleton tracking data. These settings are stored in ./launch/skeletonrecord.vcg Note that the launch file or the vcg file can be modified to change the way rviz starts. In other words, you can create new settings in rviz and then export them as a new vcg file, and either overwrite the current vcg so that launch file starts rviz with your new settings, or change the launch file to refer to the new vcg. rviz is not a respawning process, so if the launch file is used to start the system, and rviz is no longer needed, it can simply be closed. If you wanted to restart rviz alone, simply run "rosrun rviz rviz" in a terminal.
Note that both included shell scripts (record_skeletons.sh and start_system.sh) must be executable, if they are not on your system, simply run "chmod a+x record_skeletons.sh start_system.sh" in the main directory of the package.
The record_skeletons.sh script provides a convenient way of recording data. Once the system is started up, get the system tracking the desired user, and then to begin recording, in a terminal execute "./record_skeletons.sh [filename]"
If no filename is provided, all recording will be done under the name "default". On-screen directions will guide you through the rest of the recording process.
Let's say we execute "./record_skeletons.sh temp" then this script will check for .bag and .txt files with the name temp. So that they don't get overwritten, they are automatically moved to new files called "temp_backup_1.*". The script then "subscribes" waits for the user to press a button before beginning to record. Once recording is started script "subscribes" to the /skeletons topic and begins saving it in a special encrypted and compressed filetype called a "bag" file. The script then waits for the user to press another button to end recording. Once recording is done, the bag file "temp.bag" is closed, and the data is exported to a csv file called "temp.txt". This file is then easily read in MATLAB or whatever you wish. NOTE: the times that are recorded in this text file are in nanoseconds.
The translation and rotation data associated with each joint also follows ROS convention. Thus the XYZ location of a given joint coordinate system provides a vector from the "openni_depth_optical_frame" to the joint expressed in the "openni_depth_optical_frame". The rotation information is represented as a quaternion and its direction is such that it will transform the "openni_depth_optical_frame" into the joint frame. This is the same transformation that would transform data expressed in the joint coordinate system into the "openni_depth_optical_frame" coordinate system. More information can be found at http://www.ros.org/wiki/geometry/CoordinateFrameConventions
Another useful command line tool is rxbag. rxbag is a gui that provides a very quick and easy way to plot and view data stored in a bag file. It can play back saved camera data as a movie, plot individual parameters, save plots, and more. More info at http://www.ros.org/wiki/rxbag and http://www.ros.org/wiki/rosbag
in a terminal to reload the USB dynamic device management module within the linux kernel. Then plug the Kinect back in and see if things are any better.
More info at www.ros.org/wiki/rostopic