/*
     * Resets the RBF if we change the number of parameters
     */
    public void ResetRBF()
    {
        m_rbf.reset(m_numInputs, m_plugs.Length);
        m_rbf.setSigma(m_sigma);
        foreach (RBFTrainingAttachment point in m_childDockables)
        {
            int      index  = 0;
            double[] values = new double[point.plugValues.Count];
            foreach (KeyValuePair <RBFPlugAttachment, double> val in point.plugValues)
            {
                values[index++] = val.Value;
            }

            double[]   positionVals = new double[m_numInputs];
            Quaternion angle        = point.angle;
            positionVals[0] = angle.x;
            positionVals[1] = angle.y;
            positionVals[2] = angle.z;
            positionVals[3] = angle.w;
            positionVals[4] = point.distance;

            m_rbf.addTrainingPoint(positionVals, values);
        }

        if (m_childDockables.Count > 0)
        {
            m_rbf.calculateWeights();
        }
    }
    public override void Awake()
    {
        base.Awake();
        m_rbf = new RBFCore(1, 1);
        m_rbf.setSigma(m_sigma);

        //m_plugs = GetComponentsInChildren<RBFPlugAttachment>();

        SetAsDock(true);
        AddAcceptedDocktype(typeof(RBFTrainingAttachment));
        EnableControls();
        ShowControls();
    }
Exemplo n.º 3
0
    void Awake( )
    {
        m_arduino = GetComponent <Arduino>();
        if (m_arduino == null)
        {
            throw new Exception("No arduino component found on glove!");
        }

        m_arduino.Setup(ConfigurePins);
        m_rbf = new RBFCore(m_bendPins.Length, m_gestures.Length);
        m_rbf.setSigma(m_sigma);
        m_bendValues                = new double[m_bendPins.Length];
        m_gestureVelocity           = new double[m_gestures.Length];
        m_lastGestureOutput         = new double[m_gestures.Length];
        m_currentCalibrationSamples = new List <double[]>();
    }