示例#1
0
 public Experiment(PossibleFingerStimulations finger, PossibleLightEffectSide effect_side, PossibleStimulationStart start, PossibleObjectColor color)
 {
     this.finger_stimulation = finger;
     this.light_effect_side  = effect_side;
     this.stimulation_start  = start;
     this.object_color       = color;
     this.SuccessfulFinished = false;
     this.ReactionTime       = -1;
     this.SpokenWord         = "-";
     this.HandPositions      = new List <Vector3>();
     this.ErrorCode          = "-";
 }
示例#2
0
 //Visualize Changes in Unity
 //Change these Methods to send the data to an arduino for example
 private void ChangeStimulationState(PossibleFingerStimulations finger, bool state)
 {
     if (state)
     {
         hand.GetComponent <MeshRenderer>().material.color = Color.yellow;
     }
     else
     {
         hand.GetComponent <MeshRenderer>().material.color = Color.gray;
     }
     return;
 }
示例#3
0
    // Handling the countdown (duration):
    // When the countdown is over, prepare the transitition to the exit method
    public IEnumerator CheckPositionOverTime(int object_in_position)
    {
        coroutine_running = true;
        for (int i = object_in_position; i > 0; i--)
        {
            text.text = "Super! Warten..." + i; // inform user about countdown
            yield return(new WaitForSeconds(1));
        }
        text.text = "Fertig";

        Debug.Log("You said the word: " + response);

        // calculate rotation of cylinder
        obj_rotation = Mathf.Abs(180 - cylinder.transform.rotation.eulerAngles.z) <= epsilon ? PossibleObjectColor.YELLOW : PossibleObjectColor.GREEN;

        // parsing response into enum type
        PossibleFingerStimulations pfs = (response == "daumen") ? PossibleFingerStimulations.THUMB : PossibleFingerStimulations.INDEX;

        // trial valid if reaction time valid, object rotation and response correct
        if (wordRecordedInTime && obj_rotation == InformationManager.actual_experiment.object_color && pfs == InformationManager.actual_experiment.finger_stimulation)
        {
            InformationManager.actual_experiment.SuccessfulFinished = true;
        }
        else
        {
            String errors = "";
            if (!wordRecordedInTime)
            {
                errors += "Reactiontime too slow.";
            }
            if (obj_rotation != InformationManager.actual_experiment.object_color)
            {
                errors += "Wrong rotation.";
            }
            if (pfs != InformationManager.actual_experiment.finger_stimulation)
            {
                errors += "Response wrong.";
            }
            InformationManager.actual_experiment.ErrorCode = errors;
        }

        // reset:
        has_responded      = false;
        wordRecordedInTime = false;
        response           = "";
        speech_receiver.Reset();

        next_state = next_state_go.GetComponent <IState>();
        finished   = true;
    }
示例#4
0
    private IEnumerator InstantStimulation(PossibleLightEffectSide effect_side, PossibleFingerStimulations finger)
    {
        yield return(new WaitForSeconds(instantStimulationDelay));

        ChangeFingerLightState(effect_side, true);
        ChangeStimulationState(finger, true);
        speech_receiver.recognizedWord = "";

        InformationManager.sw = new Stopwatch();
        InformationManager.sw.Start();
        speech_receiver.record = true;

        yield return(new WaitForSeconds(stimulationTime));

        ChangeStimulationState(finger, false);
        yield return(new WaitForSeconds(1f));

        ChangeFingerLightState(effect_side, false);
    }