Gyroscope Logging returns empty file

edited February 9 in Android

Hi,

I'm using a MetaMotionR and trying to log both accelerometer and gyroscope data at the same time on Android. I'm logging to a file, and I am serializing the board and saving the route ids to be restored as the application should be able to be closed and reopened. When retrieving the log, I'm seeing the accelerometer file fill up with valid data but the gyroscope file is empty. I'm programming it as follows:

- Configure the acclerometer and gyroscope

- Set subscribers for accelerometer and gyroscope (neither of the tasks were faulted)



- Start the acclerometer and gyroscope

- Serialize the object

- Start logging

Then to collect data, I do the following sequence:
- Stop sensors and logging
- Set the environment (0 for accelerometer, and 1 for gyroscope) after using lookupRoute to get the Route for each.
- Download using downloadAsync
-


In the end, two files, but only the accelerometer file contains the information that was logged. Is there anything I'm doing wrong here to log from both at the same time? Thanks for your help, please let me know if you need any more information.

Comments

  • edited February 10

    Why are you using index 1 for the gyro environment? How are you setting the environment for each subscriber?

  • Hi Eric,

    Perhaps I misunderstood the documentation, should I be using 0 as the environment for both? I'm using the following to set the environment after reading it from a file I had saved it to earlier:

    int routeId = Integer.parseInt(res);
    Route accelRoute = m_board.lookupRoute(routeId);
    String datetime = DateFormat.getDateTimeInstance().format(new Date());
    fosAccel = context.openFileOutput(m_board.getMacAddress() + "_accelerometer_" + datetime, context.MODE_PRIVATE);
    accelRoute.setEnvironment(0, fosAccel);
    

    And then I have the same thing for gyroscope except with a different filename:

    fosGyro = context.openFileOutput(m_board.getMacAddress() + "_gyroscope_" + datetime, context.MODE_PRIVATE);
    accelRoute.setEnvironment(1, fosGyro);
    

    Should I not be using two different environment variables for each different file? If so, could you please tell me what I should have instead in my code to log both the gyroscope and accelerometer at the same time?

  • Each subscriber has its own environment.

    What is accelRoute assigned to? Is it intentional that you are using it for both acc and gyro routes?

Sign In or Register to comment.