Ejemplo n.º 1
0
        public Exercise(SharedContent.Commands name, string description, Pose[] exercisePoses, ExerciseStep[] exerciseSteps)
        {
            this.currentStepIndex = 0;
            this.name = name;
            this.description = description;
            this.exercisePoses = exercisePoses;
            this.exerciseSteps = exerciseSteps;

            this.exerciseStatus = ExerciseStatus.NotStarted;
            this.statusMessage = "Waiting for user to assume the starting pose of the first exercise step";
        }
Ejemplo n.º 2
0
        private static Exercise CreateRightBicepCurlExercise()
        {
            Pose armAtSide = new Pose(new Dictionary<SharedContent.BodyPartID, BodyPartOrientation>()
            {
                {SharedContent.BodyPartID.RightArm, new LimbOrientation(SharedContent.BodyPartID.RightArm, new Vector3D(0,-1,0), new Vector3D(0,-1,0))}
            });
            Pose armCurledUp = new Pose(new Dictionary<SharedContent.BodyPartID, BodyPartOrientation>()
            {
                {SharedContent.BodyPartID.RightArm, new LimbOrientation(SharedContent.BodyPartID.RightArm, new Vector3D(0,-1,0), new Vector3D(0,0,-1))}
            });

            ExerciseStep curlArm = new ExerciseStep(armAtSide, armCurledUp, TimeSpan.FromSeconds(2), ExerciseStepType.Movement, "Curling arm");
            ExerciseStep uncurlArm = new ExerciseStep(armCurledUp, armAtSide, TimeSpan.FromSeconds(2), ExerciseStepType.Movement, "Uncurling arm");

            return new Exercise(SharedContent.Commands.RightBicepCurl,
                "From a neutral pose with your right arm at your side, bend your right forearm up directly in front of you until it is parallel with the floor, then lower your forearm back into neutral position",
                new Pose[] { armAtSide, armCurledUp }, new ExerciseStep[] { curlArm, uncurlArm });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Right Shoulder abduction - from shoulder at neutral position (at side), lift outwards (in plane of body) to approximately 90 degrees
        /// </summary>
        /// <returns></returns>
        private static Exercise CreateRightShoulderAbductionExercise()
        {
            Pose armAtSide = new Pose(new Dictionary<SharedContent.BodyPartID, BodyPartOrientation>()
            {
                {SharedContent.BodyPartID.RightArm, new LimbOrientation(SharedContent.BodyPartID.RightArm, new Vector3D(0,-1,0), new Vector3D(0,-1,0))}
            });
            Pose armOutstretched = new Pose(new Dictionary<SharedContent.BodyPartID, BodyPartOrientation>()
            {
                {SharedContent.BodyPartID.RightArm, new LimbOrientation(SharedContent.BodyPartID.RightArm, new Vector3D(1,0,0), new Vector3D(1,0,0))}
            });

            ExerciseStep raiseArm = new ExerciseStep(armAtSide, armOutstretched, TimeSpan.FromSeconds(3), ExerciseStepType.Movement, "Raising arm");
            ExerciseStep holdArmOutstretched = new ExerciseStep(armOutstretched, armOutstretched, TimeSpan.FromSeconds(2), ExerciseStepType.Hold, "Holding position");
            ExerciseStep lowerArm = new ExerciseStep(armOutstretched, armAtSide, TimeSpan.FromSeconds(3), ExerciseStepType.Movement, "Lowering arm");

            return new Exercise(SharedContent.Commands.RightShoulderAbduction,
                "From a neutral position with your right arm at your side, raise your right arm to shoulder height directly out from your body, then lower your arm back into neutral position",
                new Pose[] { armAtSide, armOutstretched }, new ExerciseStep[] { raiseArm, holdArmOutstretched, lowerArm });
        }
Ejemplo n.º 4
0
        public ExerciseStep(Pose initialPose, Pose finalPose, TimeSpan expectedDuration, ExerciseStepType stepType, string stepName)
        {
            this.initialPose = initialPose;
            this.finalPose = finalPose;
            this.expectedDuration = expectedDuration;
            this.stepType = stepType;
            this.stepName = stepName;

            stepStatus = ExerciseStepStatus.NotInInitialPose;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Determines whether the user is performing the exercise correctly. Returns -1 if the user has failed to maintain proper form, else returns the approximate percentage
        /// of the exercise step that the user has completed
        /// </summary>
        /// <param name="userData"></param>
        /// <returns></returns>
        public UserPerformanceAnalysisInfo IsUserPerformingStepCorrectly(SkeletonData userData)
        {
            Pose currentPose = new Pose(userData, initialPose.bodyPartsOfInterest);

            return currentPose.IsInBetweenPoses(initialPose, finalPose);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Determines whether this those is in between the initial and final poses provided, where it is assumed that a pose is in between two poses if and only if it occurs if
        /// the pose will occur while linearly transitioning from the first pose to the second pose (linearly = along the shortest path). Returns the average percent of the
        /// displacement between the initial and final poses that this pose has traveled
        /// </summary>
        /// <param name="initialPose"></param>
        /// <param name="finalPose"></param>
        /// <returns></returns>
        public UserPerformanceAnalysisInfo IsInBetweenPoses(Pose initialPose, Pose finalPose)
        {
            int maxChange = int.MinValue, minChange = int.MaxValue, percentSum = 0, numPercents = 0;
            SharedContent.BodyPartID maxChangeID = SharedContent.BodyPartID.Head, minChangeID = SharedContent.BodyPartID.Head;
            UserPerformanceAnalysisInfo result;

            foreach (SharedContent.BodyPartID bodyPartID in initialPose.bodyPartsOfInterest)
            {
                BodyPartOrientation bodyPartToCheck;
                this.poseBodyPartOrientations.TryGetValue(bodyPartID, out bodyPartToCheck);

                BodyPartOrientation initialBodyPart, finalBodyPart;
                initialPose.poseBodyPartOrientations.TryGetValue(bodyPartID, out initialBodyPart);
                finalPose.poseBodyPartOrientations.TryGetValue(bodyPartID, out finalBodyPart);

                result = bodyPartToCheck.IsInBetweenOrientations(initialBodyPart, finalBodyPart);
                if (result.failed)
                {
                    return result;
                }
                else if (!result.negligableAction)
                {
                    if (result.percentComplete < minChange)
                    {
                        minChange = result.percentComplete;
                        minChangeID = bodyPartID;
                    }
                    if (result.percentComplete > maxChange)
                    {
                        maxChange = result.percentComplete;
                        maxChangeID = bodyPartID;
                    }
                    percentSum += result.percentComplete;
                    numPercents++;
                }
            }

            if (numPercents == 0)
            {
                throw new Exception("In determining if pose is between two others, found that no non-negligable changes exist between the starting and ending poses");
            }

            if (maxChange - minChange > SharedContent.GetAllowableDeviationInPercent())
            {
                result = new UserPerformanceAnalysisInfo(true, String.Format("The difference in the percentage completion of the movement for {0} and {1} exceeded the maximum allowable deviation of {2}",
                    Enum.GetName(typeof(SharedContent.BodyPartID), maxChangeID), Enum.GetName(typeof(SharedContent.BodyPartID), minChangeID), SharedContent.GetAllowableDeviationInPercent()));
                return result;
            }
            else
            {
                result = new UserPerformanceAnalysisInfo(percentSum / numPercents);
                return result;
            }
        }