Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

collecting accelerometer and gyroscope data

ANSWERED

Hi everyone, 

 

 

I got a problem when I collect accelerometer and gyroscope data in real-time. I found that the totoal number of accelerometer data and gyroscope data are not the same.

 

For example,

 

"let acc = new Accelerometer({ frequency: 6, batch: 6});"

 

"let gyro = new Gyroscope({ frequency: 6, batch: 6 });" 

 

I set the frequency is 6, but the accelerometer data will be more than gyroscope data. I dont know why.

 

Could you help me?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

I've never had data recorded at twice the requested frequency. Is there a chance you've registered for the relevant events twice?

I'd be checking the reading timestamps as well.

I can get the watch to send messages to the companion up to about 20 times a second, so once a second should be fine. File transfer may be slower.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
22 REPLIES 22

I found that, sometimes, accelerometer frequency will be 12 and gyroscope frequency is still 6. 

 

Best Answer
0 Votes

@Aemonzzx   You posted your question in a forum designed for users having device problems.  You sound like a developer and that your question should be moved to a Developer forum.  I can do that, but the question is where? Web API or SDK?

Community Council Member

Laurie | Maryland, USA

Sense 2, Luxe, Aria 2 | iOS | Mac OS

Take a look at the Fitbit help site for further assistance and information.

Best Answer

Thank you very much. It should be SDK question.

Best Answer

@Aemonzzx   Moved to the correct forum.  I hope you get the help you need.

Community Council Member

Laurie | Maryland, USA

Sense 2, Luxe, Aria 2 | iOS | Mac OS

Take a look at the Fitbit help site for further assistance and information.

Best Answer

It might be interesting to inspect the timestamps of the individual readings. I've occasionally seen successive readings with identical timestamps (perhaps due to sampling too quickly, which you're not doing).

 

Accelerometer timestamps seem to be quantised into multiples of 8 msec (on Versa 2), but such fine quantisation shouldn't be significant at your sampling frequency.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Hi, Gondwana,

 

does accelerometer data and gyroscope data can be synced? and then I can use WebAPI with my versa to get the data?

 

Thank you. 

Best Answer
0 Votes

You can't get accelerometer or gyroscope data from the Web API.Those sensors would generate too much data to be synced (except for short periods).

There's a rough outline of how to get those data, as well as some teasers, here.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thank you.

 

By the way, how can I get the data more stable?

 

I use Versa to send the data to my companion app every second, and then my phone will upload data to database.

 

I think one of the problem is the Versa reads data too fast. It reads data twice in a time interval and send it to companion app. 

Best Answer
0 Votes

I've never had data recorded at twice the requested frequency. Is there a chance you've registered for the relevant events twice?

I'd be checking the reading timestamps as well.

I can get the watch to send messages to the companion up to about 20 times a second, so once a second should be fine. File transfer may be slower.

Peter McLennan
Gondwana Software
Best Answer

Hi, is it possible to solve this problem???801584024414_.pic.jpgScreenshot 2020-03-12 at 10.52.44 PM.pngScreenshot 2020-03-12 at 11.01.19 PM.pngWechatIMG80.jpeg

 

I set the frequncy as 10 readings per second. I got the data to generated into a csv file and then counted  the number of data at each time.  However, there are 20 data at these time and some are only 1 data. I checked Fitbit Studio console, at 16:59:33, it only send 10 times. why???

is it hard to get a stable data?

Best Answer
0 Votes

I've never had any trouble getting fairly 'stable' data. The interval between readings fluctuates slightly (16 ms?), but that can't explain what you're seeing.

Writing to file is a relatively slow operation, although I would have thought that 10 times per second should have been okay. You could try saving 10 readings in memory, and only updating the file once per second. Better, use sensor 'batch' mode unless you really need readings straight away.

I'll confess that I'm not sure exactly what some of your images are about.

I still think you should examine the timestamps of your readings to see if you're getting duplicates (which I've occasionally seen!) and to check the actual frequency.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Is it possible to read accelerometer and gyroscope data at the same time?

 

The code is :

Screenshot 2020-03-20 at 5.16.11 PM.png

However, in the json file, the gyroscope data is always more than accelerometer data. 

I think when it writes a json file, there are 20 gyroscope data but accelerometer data only has 10 or less than 10. 

Best Answer
0 Votes

I really think you should treat the gyro.onreading and accel.onreading events as separate. There's no guarantee they'll occur at identical times; it's almost certain that they won't.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

But why sometimes there are more than 6 data per second or less than 6. I set the frequency as 6. I check the timestamps. The time difference is not exactly one second

Best Answer
0 Votes

It seems to me that sensor data is collected internally at a fixed frequency. When we sample it, we can only obtain samples at multiples of that internal frequency, rather than exactly what we specify. That may be why there's occasionally more or less samples than you expect.

 

Example the reading timestamps and see if this explains it.

Peter McLennan
Gondwana Software
Best Answer

Is it possible to add some functions, like timesleep or something, to collect data at a specified sample rate?

 

Can we use other method to collect a group of data at a specified sample rate instead of BatchedAccelerometerReading? 

 

Best Answer
0 Votes

Do you know how to convert timestamp to date?

Best Answer
0 Votes

There is no direct conversion. timestamps start from an arbitrary point in time.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

let temp_lasttime = 0;

let temp_currenttime = 0;

let date = 0;

accel.onactivate=()=> {

    date = Date.now();

...

for (let index = 0 ;index <accel.readings.timestamp.length ; index++){

    if (temp_lasttime == 0){
        temp_lasttime = accel.readings.timestamp[index];
    }
        temp_currenttime = accel.readings.timestamp[index];
        date = date + temp_currenttime - temp_lasttime;
        temp_lasttime = temp_currenttime;

}

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Whether this date is the time when the sensor reads the data??

 

 

 

Best Answer
0 Votes