public void showRandHand()
    {
        AngleBasedHandModel result = createRandom();

        output.visualizeHand(result);
        Debug.Log("Comfort+Discomfort: " + (Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result)));
    }
Exemple #2
0
 void saveData()
 {
     UserStudyData.instance.targetHand = targethand;
     UserStudyData.instance.angleDis   = Comfort.getRRPComponent(targethand);
     UserStudyData.instance.hyperDis   = Discomfort.getHyperExtensionComponent(targethand);
     UserStudyData.instance.yaxisDis   = Discomfort.getAbductionComponent(targethand);
     UserStudyData.instance.interDis   = Discomfort.getInterFingerComponent(targethand);
     UserStudyData.instance.discomfort = Discomfort.getDiscomfortAngled(targethand);
     UserStudyData.instance.palmangle  = targethand.getAvgMCPAngle() * 0;
     Debug.Log(targethand.getAvgMCPAngle() * 0);
 }
    public AngleBasedHandModel createRandom(float disc_min, float disc_max)
    {
        AngleBasedHandModel result;

        do
        {
            result = createRandom();
        }while (Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result) < disc_min || Discomfort.getDiscomfortAngled(result) + Comfort.getRRPComponent(result) > disc_max);
        Debug.Log("Discomfort: " + Discomfort.getDiscomfortAngled(result) + ", Comfort: " + Comfort.getRRPComponent(result));
        return(result);
    }
    public void convertAll()
    {
        inputFileName  = PostureDataHandler.instance.filePath + "ComfortEvaluationData" + UserStudyData.instance.fileEnding;
        outputFileName = PostureDataHandler.instance.filePath + "ComfortEvaluationCompressed" + UserStudyData.instance.fileEnding;
        read           = new StreamReader(inputFileName);
        string oldHeader = read.ReadLine();

        string[] endlArr = { ", " };
        first  = System.Array.IndexOf(oldHeader.Split(endlArr, System.StringSplitOptions.RemoveEmptyEntries), "RandomHandThumbIP");
        rating = System.Array.IndexOf(oldHeader.Split(endlArr, System.StringSplitOptions.RemoveEmptyEntries), "Rating");
        int currentRating;

        if (File.Exists(outputFileName))
        {
            File.Delete(outputFileName);
        }

        string endl       = ", ";
        string fileHeader =
            "Rating" + endl +
            Discomfort.getInterFingerCSVHeader(endl) +
            Discomfort.getAbductionCSVHeader(endl) +
            Discomfort.getHyperExtensionCSVHeader(endl) +
            Comfort.getRRPCSVHeader(endl);

        File.AppendAllText(outputFileName, fileHeader + System.Environment.NewLine);


        while (!read.EndOfStream)
        {
            string   dataLine = read.ReadLine();
            string[] input    = dataLine.Split(endlArr, System.StringSplitOptions.RemoveEmptyEntries);
            currentRating = int.Parse(input[rating]);
            handNew.parseCSV(input, first);

            File.AppendAllText(
                outputFileName,
                currentRating + endl +
                Discomfort.getInterFingerCSV(handNew, endl) +
                Discomfort.getAbductionCSV(handNew, endl) +
                Discomfort.getHyperExtensionCSV(handNew, endl) +
                Comfort.getRRPCSV(handNew, endl) +
                System.Environment.NewLine
                );
        }
        Debug.Log("Done!");
        read.Close();
    }
    void saveResults()
    {
        File.AppendAllText(
            fileName,

            UserStudyData.instance.Name + endl +
            slider.value + endl +
            Discomfort.getDiscomfortAngled(targethand) + endl +
            Comfort.getRRPComponent(targethand) + endl +
            Discomfort.getInterFingerComponent(targethand) + endl +
            Discomfort.getAbductionComponent(targethand) + endl +
            Discomfort.getHyperExtensionComponent(targethand) + endl +
            Discomfort.getInterFingerCSV(targethand, endl) +
            Discomfort.getAbductionCSV(targethand, endl) +
            Discomfort.getHyperExtensionCSV(targethand, endl) +
            Comfort.getRRPCSV(targethand, endl) +
            targethand.ToCSVString(endl) + Environment.NewLine
            );
    }
    // Use this for initialization
    void Start()
    {
        remaining = UserStudyData.instance.evaluations;
        fileName  = PostureDataHandler.instance.filePath + "ComfortEvaluationData" + UserStudyData.instance.fileEnding;

        string fileHeader =
            "Name" + endl +
            "Rating" + endl +
            "Discomfort" + endl +
            "Comfort" + endl +
            "InterDis" + endl +
            "AbductionDis" + endl +
            "HyperDis" + endl +
            Discomfort.getInterFingerCSVHeader(endl) +
            Discomfort.getAbductionCSVHeader(endl) +
            Discomfort.getHyperExtensionCSVHeader(endl) +
            Comfort.getRRPCSVHeader(endl) +
            AngleBasedHandModel.getCSVHeader(endl, "RandomHand");

        if (!File.Exists(fileName))
        {
            File.AppendAllText(fileName, fileHeader + Environment.NewLine);
        }
        else
        {
            StreamReader read      = new StreamReader(fileName);
            string       oldHeader = read.ReadLine();
            read.Close();
            if (!oldHeader.Equals(fileHeader))
            {
                Debug.Log("Fileheader not matching. Creating new file.");
                File.Delete(fileName);
                File.AppendAllText(fileName, fileHeader + Environment.NewLine);
            }
        }
        reset();
        if (UserStudyData.instance.right)
        {
            outputHand.transform.localScale = new Vector3(-outputHand.transform.localScale.x, outputHand.transform.localScale.y, outputHand.transform.localScale.z);
        }
    }
    void saveResults()
    {
        File.AppendAllText(
            fileNameEnd,

            UserStudyData.instance.Name + endl +
            UserStudyData.instance.ComfortEvaluation + endl +
            timer + endl +
            timerTracking + endl +
            Discomfort.getDiscomfortAngled(UserStudyData.instance.targetHand) + endl +
            Comfort.getRRPComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getInterFingerComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getAbductionComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getHyperExtensionComponent(UserStudyData.instance.targetHand) + endl +
            Discomfort.getInterFingerCSV(UserStudyData.instance.targetHand, endl) +
            Discomfort.getAbductionCSV(UserStudyData.instance.targetHand, endl) +
            Discomfort.getHyperExtensionCSV(UserStudyData.instance.targetHand, endl) +
            Comfort.getRRPCSV(UserStudyData.instance.targetHand, endl) +
            UserStudyData.instance.targetHand.ToCSVString(endl) + Environment.NewLine
            );
    }
Exemple #8
0
    IEnumerator getNewRandomHand()
    {
        generating = true;
        int counter = 0;

        Debug.Log(targetdiscomfort);
        do
        {
            uncomfortable = randHand.createRandom();
            yield return(new WaitForEndOfFrame());

            counter++;
            if (counter > 200)
            {
                counter           = 0;
                targetdiscomfort -= 25;
                Debug.Log(targetdiscomfort);
            }
        }while (Discomfort.getDiscomfortAngled(uncomfortable) + Comfort.getRRPComponent(uncomfortable) < targetdiscomfort || Discomfort.getDiscomfortAngled(uncomfortable) + Comfort.getRRPComponent(uncomfortable) > targetdiscomfort + 100);
        generating = false;
    }
    IEnumerator getNewRandomHand()
    {
        generating       = true;
        targetdiscomfort = UnityEngine.Random.Range(50, 1000);
        int counter = 0;

        Debug.Log(targetdiscomfort);
        do
        {
            targethand = randHand.createRandom();
            outputHand.visualizeHand(targethand);
            yield return(new WaitForEndOfFrame());

            counter++;
            if (counter > 200)
            {
                counter          = 0;
                targetdiscomfort = UnityEngine.Random.Range(50, 1000);
                Debug.Log(targetdiscomfort);
            }
        }while (Discomfort.getDiscomfortAngled(targethand) + Comfort.getRRPComponent(targethand) < targetdiscomfort || Discomfort.getDiscomfortAngled(targethand) + Comfort.getRRPComponent(targethand) > targetdiscomfort + 100);
        generating = false;
    }
    // Use this for initialization
    void Start()
    {
        HandPostureUtils.reload();
        if (UserStudyData.instance.right)
        {
            hand = rightHand;
            palm = palmRight;
        }
        else
        {
            hand = leftHand;
            palm = palmLeft;
        }
        string fileHeader    = "Name" + endl + "UserEvaluation" + endl + "Discomfort" + endl + "Time" + endl + "Precision" + endl + "Postureholdtime" + endl + "TargetIndex" + endl + "Posture" + endl + "AngleDis" + endl + "InterDis" + endl + "YAxisDis" + endl + "HyperDis" + endl + AngleBasedHandModel.getCSVHeader(endl, "ActualHand") + endl + AngleBasedHandModel.getCSVHeader(endl, "GivenHand");
        string fileHeaderEnd =
            "Name" + endl +
            "Rating" + endl +
            "Time" + endl +
            "TrackingTime" + endl +
            "Discomfort" + endl +
            "Comfort" + endl +
            "InterDis" + endl +
            "AbductionDis" + endl +
            "HyperDis" + endl +
            Discomfort.getInterFingerCSVHeader(endl) +
            Discomfort.getAbductionCSVHeader(endl) +
            Discomfort.getHyperExtensionCSVHeader(endl) +
            Comfort.getRRPCSVHeader(endl) +
            AngleBasedHandModel.getCSVHeader(endl, "RandomHand");

        fileName    = PostureDataHandler.instance.filePath + "TargetShootingData" + UserStudyData.instance.fileEnding;
        fileNameEnd = PostureDataHandler.instance.filePath + "TargetShootingDataEnd" + UserStudyData.instance.fileEnding;

        if (!File.Exists(fileName))
        {
            File.AppendAllText(fileName, fileHeader + Environment.NewLine);
        }
        else
        {
            StreamReader read      = new StreamReader(fileName);
            string       oldHeader = read.ReadLine();
            read.Close();
            if (!oldHeader.Equals(fileHeader))
            {
                Debug.Log("Fileheader not matching. Creating new file.");
                File.Delete(fileName);
                File.AppendAllText(fileName, fileHeader + Environment.NewLine);
            }
        }

        if (!File.Exists(fileNameEnd))
        {
            File.AppendAllText(fileNameEnd, fileHeaderEnd + Environment.NewLine);
        }
        else
        {
            StreamReader read      = new StreamReader(fileNameEnd);
            string       oldHeader = read.ReadLine();
            read.Close();
            if (!oldHeader.Equals(fileHeaderEnd))
            {
                Debug.Log("Fileheader not matching. Creating new file.");
                File.Delete(fileNameEnd);
                File.AppendAllText(fileNameEnd, fileHeaderEnd + Environment.NewLine);
            }
        }


        remainingTargets = numTargets;
        if (UserStudyData.instance.right)
        {
            outputHand.transform.localScale = new Vector3(-outputHand.transform.localScale.x, outputHand.transform.localScale.y, outputHand.transform.localScale.z);
        }
        if (UserStudyData.instance.targetHand != null)
        {
            outputHand.visualizeHand(UserStudyData.instance.targetHand);
        }
        else
        {
            outputHand.gameObject.SetActive(false);
        }
    }
 public float getDiscomfort()
 {
     return(Discomfort.getDiscomfortAngled(hand));
 }