Gyro streaming 1hz

edited August 2016 in Android
I can stream gyro data 25hz per second,Is there any way I can stream gyro data 1hz per second.
My second question is if I set my output rate 25hz per seconds, is there any way I can average each axis(x,y,z) data, and bring it to 1hz per second for streaming.

Comments

  • Use a timer filter with a 1000ms period.  

    You can compute the average but you will have to compute it over each axis individually.  Furthermore, the average is a running average so you must periodically reset the average.
  • Thanks Eric, if possible could you please provide sample coding for timer filter with gyro stream.
  • Thanks Eric. I tried but no results. Could you please check .
    try {
    gyroModule = mwBoard.getModule(Bmi160Gyro.class);
    } catch (UnsupportedModuleException e) {
    e.printStackTrace();
    }

    gyroModule.configure()
    .setOutputDataRate(OutputDataRate.ODR_25_HZ)
    .setFullScaleRange(FullScaleRange.FSR_500)
    .commit();
    AsyncOperation<RouteManager> routeManagerResultGyro = gyroModule.routeData().fromAxes()
    .process(new Time(Time.OutputMode.ABSOLUTE,1000))
    .stream(GYRO_STREAM_KEY)
    .commit();
    routeManagerResultGyro.onComplete(new AsyncOperation.CompletionHandler<RouteManager>() {
    @Override
    public void success(RouteManager result) {
    result.subscribe(GYRO_STREAM_KEY, new RouteManager.MessageHandler() {
    @Override
    public void process(Message msg) {
    final CartesianFloat spinData = msg.getData(CartesianFloat.class);
    Log.i(TAG, String.format("Gyroscope: %s", spinData.toString()));


    }
    });
    }
    });

    gyroModule.start();
  • At a glance, the code looks fine so try overriding the failure function to see if anything is returned there
  • I have tried with failure function still, running perfectly but no error or no result.
        @Override
    public void failure(Throwable error) {
    Log.i("Failure", error.getMessage());
    }
    });

    Result:
    08-25 11:24:07.279 13615-13615/com.example.ram.rproaccelerometertest I/MetaWear: Clicked connect
    08-25 11:24:09.771 13615-13711/com.example.ram.rproaccelerometertest I/MetaWear: Connected
    08-25 11:24:12.984 13615-13615/com.example.ram.rproaccelerometertest I/MetaWear: switch is clicked

  • The only thing I can think of is to move the start function into the CompletionHandler, otherwise the code works fine for me.
This discussion has been closed.