Ejemplo n.º 1
0
        internal void initializeGesture()
        {
            // Initiation successful, we can signal the beginning of rotation angle reading:
            left_arm_rotation.rot_tracking_state  = ArmRotationTrackingState.Initialized;
            right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.Initialized;

            // Initialing the rotation state:
            left_arm_rotation.previous_rot_state  = ArmRotationalState.NotRotating;
            right_arm_rotation.previous_rot_state = ArmRotationalState.NotRotating;

            // Passing this shoulder to elbow vector so that on the next event we can compare:
            left_arm_rotation.previous_frame_vector = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderLeft,
                                                                                               JointType.ElbowLeft);
            right_arm_rotation.previous_frame_vector = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderRight,
                                                                                                JointType.ElbowRight);
        }
Ejemplo n.º 2
0
        // This method returns 0 if everything went well, -1 if reading of the gesture is stopped:
        internal int readArmRotation(JointGeneralState left_elbow_general_state, JointGeneralState right_elbow_general_state)
        {
            // Moved these two lines out of the if statement:
            shoulder_to_elbow_left  = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderLeft, JointType.ElbowLeft);
            shoulder_to_elbow_right = GestureAuxilaryMethods.updateLimbVectors(JointType.ShoulderRight, JointType.ElbowRight);

            // Checking the boundary conditions to see if we can actually do the reading:
            if (boundaryConditions(left_elbow_general_state, right_elbow_general_state) == true &&
                (left_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking ||
                 left_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Initialized) &&
                (right_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking ||
                 right_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Initialized))
            {
                left_arm_rotation.rot_tracking_state  = ArmRotationTrackingState.Tracking;
                right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.Tracking;
            }
            else
            {
                left_arm_rotation.rot_tracking_state  = ArmRotationTrackingState.NotTracking;
                right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.NotTracking;
            }

            if (left_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking &&
                right_arm_rotation.rot_tracking_state == ArmRotationTrackingState.Tracking)
            {
                updateRotationStatus();
                updateArmStatus();

                //TextInformation.insert_main_text_block("Left Arm: " + left_arm_rotation.previous_angles[0].ToString(), 2);
                //TextInformation.insert_main_text_block("Right Arm: " + right_arm_rotation.previous_angles[0].ToString(), 2);

                // Lets stabialize the angle:
                left_arm_rotation.stabializeAngle();
                right_arm_rotation.stabializeAngle();

                TextInformation.insert_main_text_block("Angle Left Arm: " + left_arm_rotation.angle.ToString("n4"), 1);
                TextInformation.insert_main_text_block("Angle Right Arm: " + right_arm_rotation.angle.ToString("n4"), 1);

                if (left_arm_rotation.enough_time_at_angle == true && right_arm_rotation.enough_time_at_angle == true)
                {
                    TextInformation.insert_main_text_block("Sending Signal", 1);

                    // Terminating the gesture reading. This might be changed later on:
                    //left_arm_rotation.rot_tracking_state = ArmRotationTrackingState.NotTracking;
                    //right_arm_rotation.rot_tracking_state = ArmRotationTrackingState.NotTracking;
                }
                else
                {
                    TextInformation.insert_main_text_block("NOT Sending Signal", 1);
                }

                left_arm_rotation.frame_counter++;
                right_arm_rotation.frame_counter++;

                // Updating previous vectors:
                left_arm_rotation.previous_frame_vector  = shoulder_to_elbow_left;
                right_arm_rotation.previous_frame_vector = shoulder_to_elbow_right;

                return(0);
            }
            else
            {
                left_arm_rotation.previous_rot_state  = ArmRotationalState.NotRotating;
                right_arm_rotation.previous_rot_state = ArmRotationalState.NotRotating;
                return(-1);
            }
        }