diff -r 8a10a975cb92 CMakeLists.txt
--- a/CMakeLists.txt	Mon Mar 12 15:56:49 2012 -0700
+++ b/CMakeLists.txt	Wed Dec 12 01:19:01 2012 +0900
@@ -6,6 +6,6 @@
 
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 
-include_directories(/usr/include/openni /usr/include/nite)
+include_directories(/usr/include/openni /usr/include/ni /usr/include/nite)
 rosbuild_add_executable(openni_tracker src/openni_tracker.cpp)
 target_link_libraries(openni_tracker OpenNI)
diff --git a/manifest.xml b/manifest.xml
index 1bb6fc1..d6e07f0 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -10,12 +10,12 @@
   <url>http://ros.org/wiki/openni_tracker</url>
 
   <depend package="geometry_msgs"/>
-  <depend package="kdl"/>
+  <depend package="orocos_kdl"/>
   <depend package="roscpp"/>
   <depend package="roslib"/>
   <depend package="tf"/>
-
+<!--
   <rosdep name="openni-dev"/>
   <rosdep name="nite-dev"/>
-  <rosdep name="ps-engine"/>
+  <rosdep name="ps-engine"/> -->
 </package>
diff -r 8a10a975cb92 src/openni_tracker.cpp
--- a/src/openni_tracker.cpp	Mon Mar 12 15:56:49 2012 -0700
+++ b/src/openni_tracker.cpp	Wed Dec 12 01:19:01 2012 +0900
@@ -8,10 +8,12 @@
 #include <XnOpenNI.h>
 #include <XnCodecIDs.h>
 #include <XnCppWrapper.h>
+#include <XnPropNames.h>
 
 using std::string;
 
 xn::Context        g_Context;
+xn::ScriptNode     g_scriptNode;
 xn::DepthGenerator g_DepthGenerator;
 xn::UserGenerator  g_UserGenerator;
 
@@ -20,7 +22,6 @@
 
 void XN_CALLBACK_TYPE User_NewUser(xn::UserGenerator& generator, XnUserID nId, void* pCookie) {
 	ROS_INFO("New User %d", nId);
-
 	if (g_bNeedPose)
 		g_UserGenerator.GetPoseDetectionCap().StartPoseDetection(g_strPose, nId);
 	else
@@ -49,6 +50,35 @@
 	}
 }
 
+// Callback: Finished calibration
+void XN_CALLBACK_TYPE UserCalibration_CalibrationComplete(xn::SkeletonCapability& capability, XnUserID nId, XnCalibrationStatus eStatus, void* pCookie)
+{
+	if (eStatus == XN_CALIBRATION_STATUS_OK)
+	{
+		// Calibration succeeded
+		ROS_INFO("Calibration complete, start tracking user %d\n", nId);
+		g_UserGenerator.GetSkeletonCap().StartTracking(nId);
+	}
+	else
+	{
+		// Calibration failed
+		ROS_INFO("Calibration failed for user %d\n", nId);
+        if(eStatus==XN_CALIBRATION_STATUS_MANUAL_ABORT)
+        {
+            ROS_INFO("Manual abort occured, stop attempting to calibrate!");
+            return;
+        }
+		if (g_bNeedPose)
+		{
+			g_UserGenerator.GetPoseDetectionCap().StartPoseDetection(g_strPose, nId);
+		}
+		else
+		{
+			g_UserGenerator.GetSkeletonCap().RequestCalibration(nId, TRUE);
+		}
+	}
+}
+
 void XN_CALLBACK_TYPE UserPose_PoseDetected(xn::PoseDetectionCapability& capability, XnChar const* strPose, XnUserID nId, void* pCookie) {
     ROS_INFO("Pose %s detected for user %d", strPose, nId);
     g_UserGenerator.GetPoseDetectionCap().StopPoseDetection(nId);
@@ -136,10 +166,26 @@
 int main(int argc, char **argv) {
     ros::init(argc, argv, "openni_tracker");
     ros::NodeHandle nh;
+    ros::NodeHandle pnh("~");
+    string frame_id("camera_depth_frame");
+    pnh.getParam("camera_frame_id", frame_id);
 
+    xn::EnumerationErrors errors;
     string configFilename = ros::package::getPath("openni_tracker") + "/openni_tracker.xml";
-    XnStatus nRetVal = g_Context.InitFromXmlFile(configFilename.c_str());
-    CHECK_RC(nRetVal, "InitFromXml");
+    XnStatus nRetVal = g_Context.InitFromXmlFile(configFilename.c_str(),
+                                                 g_scriptNode, &errors);
+    if (nRetVal == XN_STATUS_NO_NODE_PRESENT)
+      {
+        XnChar strError[1024];
+        errors.ToString(strError, 1024);
+        ROS_ERROR("%s\n", strError);
+        return (nRetVal);
+      }
+    else if (nRetVal != XN_STATUS_OK)
+      {
+        ROS_ERROR("Open failed: %s\n", xnGetStatusString(nRetVal));
+        return (nRetVal);
+      }
 
     nRetVal = g_Context.FindExistingNode(XN_NODE_TYPE_DEPTH, g_DepthGenerator);
     CHECK_RC(nRetVal, "Find depth generator");
@@ -150,27 +196,29 @@
 		CHECK_RC(nRetVal, "Find user generator");
 	}
 
-	if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON)) {
-		ROS_INFO("Supplied user generator doesn't support skeleton");
+	XnCallbackHandle hUserCallbacks, hCalibrationStart, hCalibrationComplete, hPoseDetected, hCalibrationInProgress, hPoseInProgress;
+	if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_SKELETON))
+	{
+		ROS_ERROR("Supplied user generator doesn't support skeleton\n");
 		return 1;
 	}
+	nRetVal = g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
+	CHECK_RC(nRetVal, "Register to user callbacks");
+	nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationStart(UserCalibration_CalibrationStart, NULL, hCalibrationStart);
+	CHECK_RC(nRetVal, "Register to calibration start");
+	nRetVal = g_UserGenerator.GetSkeletonCap().RegisterToCalibrationComplete(UserCalibration_CalibrationComplete, NULL, hCalibrationComplete);
+	CHECK_RC(nRetVal, "Register to calibration complete");
 
-    XnCallbackHandle hUserCallbacks;
-	g_UserGenerator.RegisterUserCallbacks(User_NewUser, User_LostUser, NULL, hUserCallbacks);
-
-	XnCallbackHandle hCalibrationCallbacks;
-	g_UserGenerator.GetSkeletonCap().RegisterCalibrationCallbacks(UserCalibration_CalibrationStart, UserCalibration_CalibrationEnd, NULL, hCalibrationCallbacks);
-
-	if (g_UserGenerator.GetSkeletonCap().NeedPoseForCalibration()) {
+	if (g_UserGenerator.GetSkeletonCap().NeedPoseForCalibration())
+	{
 		g_bNeedPose = TRUE;
-		if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION)) {
-			ROS_INFO("Pose required, but not supported");
+		if (!g_UserGenerator.IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION))
+		{
+			ROS_ERROR("Pose required, but not supported\n");
 			return 1;
 		}
-
-		XnCallbackHandle hPoseCallbacks;
-		g_UserGenerator.GetPoseDetectionCap().RegisterToPoseCallbacks(UserPose_PoseDetected, NULL, NULL, hPoseCallbacks);
-
+		nRetVal = g_UserGenerator.GetPoseDetectionCap().RegisterToPoseDetected(UserPose_PoseDetected, NULL, hPoseDetected);
+		CHECK_RC(nRetVal, "Register to Pose Detected");
 		g_UserGenerator.GetSkeletonCap().GetCalibrationPose(g_strPose);
 	}
 
@@ -181,11 +229,6 @@
 
 	ros::Rate r(30);
 
-        
-        ros::NodeHandle pnh("~");
-        string frame_id("openni_depth_frame");
-        pnh.getParam("camera_frame_id", frame_id);
-                
 	while (ros::ok()) {
 		g_Context.WaitAndUpdateAll();
 		publishTransforms(frame_id);
