public boolean isRightHandRaised() { // instance variables (that we don't use) double leftAxis = 0; double rightAxis = 0; double leftAngle, rightAngle, headAngle, rightLegAngle, leftLegAngle, rightLegYZ, leftLegYZ; boolean dataWithinExpectedRange; boolean[] buttons = new boolean[8]; if (kinect.getSkeleton().GetTrackState() == Skeleton.tTrackState.kTracked) { if (kinect.getSkeleton().GetWristRight().getY() > kinect.getSkeleton().GetHead().getY()) { return true; } else { return false; } // Other important stuff (that's not important) // /* Determine angle of each arm and map to range -1,1 */ // leftAngle = AngleXY(kinect.getSkeleton().GetShoulderLeft(), // kinect.getSkeleton().GetWristLeft(), true); // rightAngle = AngleXY(kinect.getSkeleton().GetShoulderRight(), // kinect.getSkeleton().GetWristRight(), false); // leftAxis = CoerceToRange(leftAngle, -70, 70, -1, 1); // rightAxis = CoerceToRange(rightAngle, -70, 70, -1, 1); // // /* Check if arms are within valid range and at approximately the same // z-value */ // dataWithinExpectedRange = leftAngle < ARM_MAX_ANGLE && leftAngle > // ARM_MIN_ANGLE && // rightAngle < ARM_MAX_ANGLE && rightAngle > // ARM_MIN_ANGLE; // dataWithinExpectedRange = dataWithinExpectedRange && // InSameZPlane(kinect.getSkeleton().GetShoulderLeft(), // kinect.getSkeleton().GetWristLeft(), // Z_PLANE_TOLERANCE) && // InSameZPlane(kinect.getSkeleton().GetShoulderRight(), // kinect.getSkeleton().GetWristRight(), // Z_PLANE_TOLERANCE); // // /* Determine the head angle and use it to set the Head buttons */ // headAngle = AngleXY(kinect.getSkeleton().GetShoulderCenter(), // kinect.getSkeleton().GetHead(), false); // buttons[0] = headAngle > HEAD_LEFT; // buttons[1] = headAngle < HEAD_RIGHT; // // /* Calculate the leg angles in the XY plane and use them to set the Leg Out // buttons */ // leftLegAngle = AngleXY(kinect.getSkeleton().GetHipLeft(), // kinect.getSkeleton().GetAnkleLeft(), true); // rightLegAngle = AngleXY(kinect.getSkeleton().GetHipRight(), // kinect.getSkeleton().GetAnkleRight(), false); // buttons[2] = leftLegAngle > LEG_OUT; // buttons[3] = rightLegAngle > LEG_OUT; // // /* Calculate the leg angle in the YZ plane and use them to set the Leg // Forward and Leg Back buttons */ // leftLegYZ = AngleYZ(kinect.getSkeleton().GetHipLeft(), // kinect.getSkeleton().GetAnkleLeft(), false); // rightLegYZ = AngleYZ(kinect.getSkeleton().GetHipRight(), // kinect.getSkeleton().GetAnkleRight(), false); // buttons[4] = rightLegYZ < LEG_FORWARD; // buttons[5] = rightLegYZ > LEG_BACKWARD; // buttons[6] = leftLegYZ < LEG_FORWARD; // buttons[7] = leftLegYZ > LEG_BACKWARD; } return false; }
public KinectSubsystem() { kinect = Kinect.getInstance(); }