Ejemplo n.º 1
0
    /// <summary>
    /// Checks whether the subject is ready to start performing the task.
    /// </summary>
    /// <returns>True if ready to start.</returns>
    public override bool IsReadyToStart()
    {
        // Check that upper and lower arms are within the tolerated start position.
        float qShoulder = leftySign * Mathf.Rad2Deg * (upperArmTracker.GetProcessedData(5) + Mathf.PI); // Offsetting to horizontal position being 0.
        float qElbow    = 0;

        if (experimentType == ExperimentType.TypeOne)
        {
            qElbow = Mathf.Rad2Deg * (lowerArmTracker.GetProcessedData(5)) - qShoulder; // Offsetting to horizontal position being 0.
        }
        else if (experimentType == ExperimentType.TypeTwo)
        {
            qElbow = -Mathf.Rad2Deg * elbowManager.GetElbowAngle();
        }

        // The difference to the start position
        float qSDiff = qShoulder - startShoulderAngle;
        float qEDiff = qElbow - startElbowAngle;

        //
        // Update information displayed for debugging purposes
        //
        if (debug)
        {
            debugText.text = experimentState.ToString() + "\n";
            if (experimentState == ExperimentState.WaitingForStart)
            {
                debugText.text += waitState.ToString() + "\n";
            }
            debugText.text += qShoulder.ToString() + "\n";
            debugText.text += qElbow.ToString() + "\n";
        }

        // Make sure the user knows the elbow is not enabled.
        if (experimentType == ExperimentType.TypeTwo)
        {
            if (!elbowManager.IsEnabled)
            {
                HudManager.centreColour = HUDManager.HUDCentreColour.Yellow;
            }
            else
            {
                HudManager.centreColour = HUDManager.HUDCentreColour.None;
            }
        }

        if (Mathf.Abs(qSDiff) < startTolerance && Mathf.Abs(qEDiff) < startTolerance)
        {
            HudManager.colour = HUDManager.HUDColour.Orange;
            return(true);
        }
        // Provide instructions when not there yet
        else
        {
            string helpText = "";
            if (qSDiff < 0 && Mathf.Abs(qSDiff) > startTolerance)
            {
                helpText += "UA: ++.\n";
            }
            else if (qSDiff > 0 && Mathf.Abs(qSDiff) > startTolerance)
            {
                helpText += "UA: --.\n";
            }

            if (qEDiff < 0 && Mathf.Abs(qEDiff) > startTolerance)
            {
                helpText += "LA: ++.\n";
            }
            else if (qEDiff > 0 && Mathf.Abs(qEDiff) > startTolerance)
            {
                helpText += "LA: --.\n";
            }

            HudManager.DisplayText(helpText);
            HudManager.colour = HUDManager.HUDColour.Red;
            return(false);
        }
    }