コード例 #1
0
 private CrispOutput ValidateOutput(CrispOutput output)
 {
     if (!FuzzyUtility.ValidInstruction(output[CrispOutput.Outputs.LeftRight]))
     {
         output[CrispOutput.Outputs.LeftRight] = 0;
     }
     return(output);
 }
コード例 #2
0
    private float NormaliseDistance(float?unNormalisedDistance, float neutralDistance, float largeDistance)
    {
        float normalisedForwardDistance;

        if (unNormalisedDistance.HasValue)
        {
            normalisedForwardDistance = FuzzyUtility.NormaliseValueUneven(-1, neutralDistance, largeDistance, unNormalisedDistance.Value);
        }
        else
        {
            normalisedForwardDistance = -1;
        }

        return(normalisedForwardDistance);
    }
コード例 #3
0
    private float NormaliseSurfaceAngle(Vector3?surfaceNormalInpt, float minAngle, float maxAngle)
    {
        float normalisedForwardSurfaceNormal;

        if (surfaceNormalInpt.HasValue)
        {
            Vector2 ourNormal     = -(new Vector2(sensor.KartForward.x, sensor.KartForward.z));
            Vector2 surfaceNormal = new Vector2(surfaceNormalInpt.Value.x, surfaceNormalInpt.Value.z);

            var angle = Vector2.SignedAngle(surfaceNormal, ourNormal); // positive is to the right, negative is to the left
            //var angleMag = Mathf.Abs(angle);

            angle *= -1; // reflect angle difference round, positive right negative left from cart's perspective now

            normalisedForwardSurfaceNormal = FuzzyUtility.NormaliseValue(minAngle, maxAngle, angle);
        }
        else
        {
            normalisedForwardSurfaceNormal = 0; // if no collision is detected return 0 as sentinel value. not ideal but safest option
        }

        return(normalisedForwardSurfaceNormal);
    }
コード例 #4
0
 private float NormaliseSpeed(float speed) => FuzzyUtility.NormaliseValueUneven(-1, neutralSpeed, hightSpeed, speed);