private void DebugOutLight(CrispOutput outputVals)
 {
     foreach (var output in CrispOutput.OutputEnumvalues)
     {
         Debug.Log($"Output: {output.ToString()} -> {outputVals[output]}");
     }
 }
Пример #2
0
    private void RunFuzzy()
    {
        float[] minValues = new float[CrispInput.NumberOfVariables] {
            Input1Min, Input2Min, -1
        };
        float[] neutralValues = new float[CrispInput.NumberOfVariables] {
            0, 0, 0
        };
        float[] maxValues = new float[CrispInput.NumberOfVariables] {
            Input1Max, Input2Max, 1
        };



        CrispInput crispInput = fuzzySystem.BuildInputNormalisedUneven(new float[] { crispInput1, crispInput2, crispInput3 }, minValues, neutralValues, maxValues);

        Debug.Log($"In log {crispInput1} -> {crispInput[CrispInput.Inputs.Input1]}");

        CrispOutput normalisedCrispOutput = fuzzySystem.FuzzyCompute(crispInput);

        CrispOutput unNormalisedOutput = fuzzySystem.UnNormaliseOutputUneven(normalisedCrispOutput, minValues, neutralValues, maxValues);


        Debug.Log($"Out log {normalisedCrispOutput[CrispOutput.Outputs.Output1]} -> {unNormalisedOutput[CrispOutput.Outputs.Output1]}");
    }
 private CrispOutput ValidateOutput(CrispOutput output)
 {
     if (!FuzzyUtility.ValidInstruction(output[CrispOutput.Outputs.LeftRight]))
     {
         output[CrispOutput.Outputs.LeftRight] = 0;
     }
     return(output);
 }
 private void DebugOutLots(CrispInput inputVals, CrispOutput outputVals)
 {
     Debug.Log("=====Case=====");
     foreach (var input in CrispInput.InputEnumvalues)
     {
         Debug.Log($"Input: {input.ToString()} -> {inputVals[input]}");
     }
     Debug.Log("=====Ouputs=====");
     foreach (var output in CrispOutput.OutputEnumvalues)
     {
         Debug.Log($"Output: {output.ToString()} -> {outputVals[output]}");
     }
     Debug.Log("=====End-Case=====");
 }
    /// <summary>
    /// Returns <c>(float, float)</c> tuple representing <see cref="FuzzyCartController.fuzzySystem"/>'s confidence that actions (drive, turn) should be taken, and the polarity of those actions.
    /// Based off the current values from <see cref="FuzzyCartController.sensor"/>
    /// </summary>
    /// <returns>A <c>(float, float)</c> tuple representing the actions (drive, turn)</returns>
    public (float, float) GetInstructions()
    {
        CrispInput  input  = GenerateInputFromSensors();
        CrispOutput output = fuzzySystem.EvaluateFuzzyLogic(input);


        if (!Input.GetKey(KeyCode.Space))
        {
            DebugOutLight(output);
        }
        else if (debug)
        {
            DebugOutLots(input, output);
        }

        output = ValidateOutput(output);

        return(output[CrispOutput.Outputs.ForwardBackwards], output[CrispOutput.Outputs.LeftRight]);
    }