Exemple #1
0
    public void updateAllClasses()
    {
        //Update filter for pedometer
        fbwX.Update(Input.acceleration.x);

        // Update using the filter for acceleration data related to gravity finding in X, Y, Z
        findGX.Update(Input.acceleration.x);
        findGY.Update(Input.acceleration.y);
        findGZ.Update(Input.acceleration.z);

        //Update pedometer
        pedometer.update(fbwX.Value);
        //update our angle of rotation from the magnetometer readings
        magnetoAxisRotationAngles.update_compass(Input.compass.rawVector.x, Input.compass.rawVector.y, Input.compass.rawVector.z);
        // Update the gyro for old method just integrating gyro data
        gyroIntegrator.update_orientation(Input.gyro.rotationRate.x, Input.gyro.rotationRate.y, Input.gyro.rotationRate.z);
        // Initialise the gyro with compass values if need be
        if (!gyroIntegrator.isInitialised)
        {
            gyroIntegrator.init_gyro_values(magnetoAxisRotationAngles.aboutX, magnetoAxisRotationAngles.aboutY, magnetoAxisRotationAngles.aboutZ);
            gyroIntegrator.isInitialised = true;

            // Initialise the Kalman values
            kalmanX.init_kalman_values(magnetoAxisRotationAngles.aboutX);
            kalmanY.init_kalman_values(magnetoAxisRotationAngles.aboutY);
            kalmanZ.init_kalman_values(magnetoAxisRotationAngles.aboutZ);
            kalmanX.isInitialised = true;
            kalmanY.isInitialised = true;
            kalmanZ.isInitialised = true;
        }
        //update kalman filter in x, y, z using raw gyro and
        kalmanX.update(Input.gyro.rotationRate.x, magnetoAxisRotationAngles.aboutX);
        kalmanY.update(Input.gyro.rotationRate.y, magnetoAxisRotationAngles.aboutY);
        kalmanZ.update(Input.gyro.rotationRate.z, magnetoAxisRotationAngles.aboutZ);
        // old method of Kalman using integrated gyro term to compare
        // kalmanZ.update(gyroIntegrator.orientationZ, magnetoAxisRotationAngles.aboutZ);


        //update heading
        // heading.updateHeading(magnetoAxisRotationAngles.aboutZ, magnetoAxisRotationAngles.aboutX, findGX.outputHistory[0], findGY.outputHistory[0], findGZ.outputHistory[0]);
        heading.updateHeading(kalmanZ.xhat, kalmanX.xhat, findGX.outputHistory[0], findGY.outputHistory[0], findGZ.outputHistory[0]);
        filteredHeading.Update((float)heading.current_heading);
    }
Exemple #2
0
    void FixedUpdate()
    {
        initialise += 1;


        if (initialise > 2 / 0.02)
        {
            // Log the time and acceleration data
            string data = System.DateTime.Now.ToString();
            fbwX.Update(Input.acceleration.x);
            // print(fbwX.Value);
            pedometer.update(fbwX.Value);
            //data = data + "   " + pedometer.numSteps;
            //data = data + "   " + Input.acceleration.x;
            //stepCountViewer.GetComponent<UnityEngine.UI.Text>().text = data;

            stepCountViewer.GetComponent <UnityEngine.UI.Text>().text = "Currently at " + pedometer.numSteps + " steps";


            //data += "," + Input.acceleration.x + "," + Input.acceleration.y + "," + Input.acceleration.z + "," + fbwX.Value + "," + fbwY.Value + "," + fbwZ.Value + ",";
            data += "," + Input.acceleration.x + "," + Input.acceleration.y + "," + Input.acceleration.z + ",";
            //print(data);
        }
    }