示例#1
0
 public StdVecb(StdVecb other) : this(eogmaneoPINVOKE.new_StdVecb__SWIG_1(StdVecb.getCPtr(other)), true)
 {
     if (eogmaneoPINVOKE.SWIGPendingException.Pending)
     {
         throw eogmaneoPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#2
0
 public StdVecbEnumerator(StdVecb collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
示例#3
0
 public void SetRange(int index, StdVecb values)
 {
     eogmaneoPINVOKE.StdVecb_SetRange(swigCPtr, index, StdVecb.getCPtr(values));
     if (eogmaneoPINVOKE.SWIGPendingException.Pending)
     {
         throw eogmaneoPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#4
0
 public void AddRange(StdVecb values)
 {
     eogmaneoPINVOKE.StdVecb_AddRange(swigCPtr, StdVecb.getCPtr(values));
     if (eogmaneoPINVOKE.SWIGPendingException.Pending)
     {
         throw eogmaneoPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#5
0
 public void create(StdVecPairi inputSizes, StdVeci inputChunkSizes, StdVecb predictInputs, StdVecLayerDesc layerDescs, uint seed)
 {
     eogmaneoPINVOKE.Hierarchy_create(swigCPtr, StdVecPairi.getCPtr(inputSizes), StdVeci.getCPtr(inputChunkSizes), StdVecb.getCPtr(predictInputs), StdVecLayerDesc.getCPtr(layerDescs), seed);
     if (eogmaneoPINVOKE.SWIGPendingException.Pending)
     {
         throw eogmaneoPINVOKE.SWIGPendingException.Retrieve();
     }
 }
示例#6
0
        public static StdVecb Repeat(bool value, int count)
        {
            global::System.IntPtr cPtr = eogmaneoPINVOKE.StdVecb_Repeat(value, count);
            StdVecb ret = (cPtr == global::System.IntPtr.Zero) ? null : new StdVecb(cPtr, true);

            if (eogmaneoPINVOKE.SWIGPendingException.Pending)
            {
                throw eogmaneoPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#7
0
        public StdVecb GetRange(int index, int count)
        {
            global::System.IntPtr cPtr = eogmaneoPINVOKE.StdVecb_GetRange(swigCPtr, index, count);
            StdVecb ret = (cPtr == global::System.IntPtr.Zero) ? null : new StdVecb(cPtr, true);

            if (eogmaneoPINVOKE.SWIGPendingException.Pending)
            {
                throw eogmaneoPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#8
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(StdVecb obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
示例#9
0
    // Use this for initialization
    void Start()
    {
        _time = 0.0f;

        LapCount = 0;

        if (carController == null)
        {
            return;
        }

        print("Initializing EOgmaNeo");

        _system = new eogmaneo.ComputeSystem(4, 1111);

        _inputWidth  = cameraTexture.width;
        _inputHeight = cameraTexture.height;

        print("Capture image size: " + _inputWidth + "x" + _inputHeight);

        _hiddenWidth  = _inputWidth;
        _hiddenHeight = _inputHeight / 2;

        // Y' input field
        _inputField = new eogmaneo.StdVecf(_hiddenWidth * _hiddenHeight);

        for (int i = 0; i < _hiddenWidth * _hiddenHeight; i++)
        {
            _inputField.Add(0.0f);
        }

        // Scalar values input field
        _inputValues = new eogmaneo.StdVeci(1);
        _inputValues.Add(0);

        print("Constructing hierarchy");

        // Hierarchy layer descriptions
        const int layerSize = 36;
        const int numLayers = 3;

        StdVecLayerDesc lds = new StdVecLayerDesc(numLayers);

        for (int l = 0; l < numLayers; l++)
        {
            lds.Add(new LayerDesc());
            lds[l]._width           = layerSize;
            lds[l]._height          = layerSize;
            lds[l]._chunkSize       = 6;
            lds[l]._forwardRadius   = 9;
            lds[l]._backwardRadius  = 9;
            lds[l]._ticksPerUpdate  = 2;
            lds[l]._temporalHorizon = 2;
            lds[l]._alpha           = 0.065f;
            lds[l]._beta            = 0.1f;

            // Disable reinforcement learning
            lds[l]._delta = 0.0f;
        }

        // Encoder output sizes, as input sizes to hierarchy
        StdVecPairi inputSizes = new eogmaneo.StdVecPairi();

        inputSizes.Add(new StdPairi(_hiddenWidth, _hiddenHeight));
        inputSizes.Add(new StdPairi(6, 6));

        StdVeci inputChunkSizes = new StdVeci();

        inputChunkSizes.Add(6);
        inputChunkSizes.Add(6);

        // Whether to predict an input
        StdVecb predictInputs = new StdVecb();

        predictInputs.Add(true);
        predictInputs.Add(true);

        print("Generating hierarchy");

        // Generate the hierarchy
        _hierarchy = new eogmaneo.Hierarchy();
        _hierarchy.create(inputSizes, inputChunkSizes, predictInputs, lds, 41);

        if (reloadHierarchy && hierarchyFileName.Length > 0)
        {
            _hierarchy.load(hierarchyFileName);
            print("Reloaded OgmaNeo hierarchy from " + hierarchyFileName);
        }

        if (connectToNeoVis)
        {
            _neoVis = new eogmaneo.VisAdapter();
            _neoVis.create(_hierarchy, neoVisPort);
        }

        _openCV = new eogmaneo.OpenCVInterop();

        int numSDRbits = (_hiddenWidth / inputChunkSizes[0]) * (_hiddenHeight / inputChunkSizes[1]);

        _rotationSDR  = new StdVeci(numSDRbits);
        _predictedSDR = new StdVeci(numSDRbits);
        for (int i = 0; i < numSDRbits; i++)
        {
            _rotationSDR.Add(0);
            _predictedSDR.Add(0);
        }

        // For calculating the normalized cross-corrolation
        _ccStates = new List <int>();
        _onStates = new List <int>();
        NCC       = 0.0f;

        _trainingCount    = 0;
        _predictingCount  = 0;
        TrainingPercent   = 1.0f;
        PredictionPercent = 0.0f;

        Training            = false;
        ForcePredictionMode = false;

        if (splineList != null && splineList[SplineIndex] != null)
        {
            Vector3 position        = splineList[SplineIndex].GetPoint(0.0f);
            Vector3 splineDirection = splineList[SplineIndex].GetDirection(0.0f);

            carController.gameObject.transform.localPosition = position;
            carController.gameObject.transform.LookAt(position - splineDirection);

            Training = true;
        }

        if (enableDebugLines)
        {
            debugLine              = gameObject.AddComponent <LineRenderer>();
            debugLine.startWidth   = 0.1f;
            debugLine.endWidth     = 0.1f;
            debugLinePositions     = new Vector3[4];
            debugLine.numPositions = debugLinePositions.Length;
        }

        PredictedSteer = 0.0f;
        PredictedAccel = 0.0f;
        PredictedBrake = -1.0f;
        HandBrake      = 1.0f;

        carSteer = PredictedSteer;
        carAccel = PredictedAccel;
        carBrake = PredictedBrake;
    }