node-metawear icon indicating copy to clipboard operation
node-metawear copied to clipboard

node-metawear receives SENSORFUSION + GYRO, even if not explicitly

Open hamilton opened this issue 7 years ago • 2 comments

Hello again -

I have been attempting to do some framerate tests with a MetaMotion R. I was finding that if I streamed the magnetometer, gyro, accelerometer, and quaternions via sensorfusion, the framerate is actually quite slow (~2Hz). Stripping out everything except the accelerometer still yields a very slow rate.

So I decided to try one of the example scripts to debug my logic, running the snippet below. I'm a bit confused, however - is it the case that node-metawear is always receiving the sensorfusion & gyro as well, even if not explicitly subscribed?

hamilton.local$ DEBUG="noble-device" node examples/accelerometer.js
  noble-device start +0ms
discovered device  d2:8e:1e:ef:a8:e4
were connected!
Start accelerometer with 50hz ang +-2g
  noble-device  send LOGGING <Buffer 0b 0b 00> +5s
  noble-device  send LOGGING <Buffer 0b 01 01> +3ms
  noble-device  send ACCELEROMETER <Buffer 03 03 27 03> +1ms
  noble-device  send ACCELEROMETER <Buffer 03 04 01> +0ms
  noble-device  send ACCELEROMETER <Buffer 03 02 01 00> +0ms
  noble-device  send ACCELEROMETER <Buffer 03 01 01> +1ms
x: 0.09228515625 		y: -0.021728515625 		z: 1.03826904296875
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 e8 05 9c fe 73 42> +10ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 02 00 04 00> +14ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +30ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 02 00 04 00> +0ms
x: 0.092041015625 		y: -0.02227783203125 		z: 1.0390625
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 e4 05 93 fe 80 42> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 04 00> +0ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 f9 ff 02 00 04 00> +1ms
x: 0.09246826171875 		y: -0.0216064453125 		z: 1.04046630859375
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 eb 05 9e fe 97 42> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 04 00> +0ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +71ms
  noble-device  received MAGNETOMETER 5 <Buffer 15 05 a7 00 8a 01 c3 00> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 05 00> +73ms
x: 0.0927734375 		y: -0.0211181640625 		z: 1.038818359375
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 f0 05 a6 fe 7c 42> +496ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 02 00 05 00> +0ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 f9 ff 02 00 05 00> +370ms
x: 0.092041015625 		y: -0.02081298828125 		z: 1.03839111328125
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 e4 05 ab fe 75 42> +619ms
  noble-device  received GYRO 5 <Buffer 13 05 fb ff 01 00 04 00> +247ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 00 00 05 00> +0ms
x: 0.09161376953125 		y: -0.02374267578125 		z: 1.0400390625
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 dd 05 7b fe 90 42> +247ms
  noble-device  received GYRO 5 <Buffer 13 05 f8 ff 00 00 04 00> +0ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 03 00> +1ms
x: 0.092529296875 		y: -0.0223388671875 		z: 1.0406494140625
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 ec 05 92 fe 9a 42> +122ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 03 00 05 00> +1ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +618ms
  noble-device  received GYRO 5 <Buffer 13 05 f9 ff 01 00 04 00> +1ms
x: 0.092041015625 		y: -0.02154541015625 		z: 1.03955078125
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 e4 05 9f fe 88 42> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 04 00> +2ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  noble-device  received MAGNETOMETER 5 <Buffer 15 05 62 00 90 01 bd 00> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 fb ff 02 00 04 00> +120ms
x: 0.0916748046875 		y: -0.02142333984375 		z: 1.04052734375
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 de 05 a1 fe 98 42> +371ms
  noble-device  received GYRO 5 <Buffer 13 05 fc ff 01 00 06 00> +1ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 fb ff 03 00 05 00> +1ms
x: 0.09185791015625 		y: -0.02288818359375 		z: 1.0380859375
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 e1 05 89 fe 70 42> +0ms
  noble-device  received MAGNETOMETER 5 <Buffer 15 05 62 00 8a 01 99 00> +122ms
x: 0.092529296875 		y: -0.02239990234375 		z: 1.03924560546875
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 ec 05 91 fe 83 42> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 02 00 06 00> +1ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 03 00> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 05 00> +1ms
x: 0.0914306640625 		y: -0.02154541015625 		z: 1.03900146484375
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 da 05 9f fe 7f 42> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fa ff 01 00 05 00> +0ms
  noble-device  received SENSORFUSION 7 <Buffer 19 07 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> +0ms
  noble-device  received GYRO 5 <Buffer 13 05 f9 ff 01 00 04 00> +615ms
x: 0.09228515625 		y: -0.0220947265625 		z: 1.03936767578125
  noble-device  received ACCELEROMETER 4 <Buffer 03 04 e8 05 96 fe 85 42> +1ms
  noble-device  received GYRO 5 <Buffer 13 05 fb ff 00 00 03 00> +0ms

hamilton avatar Feb 25 '17 22:02 hamilton

update: I tried a soft reset of the device through the mobile app. Removes the GYRO + SENSORFUSION receives. Does the device remember the services last received, and if so, is there a way to automatically soft reset it or something so we don't receive it?

hamilton avatar Feb 25 '17 22:02 hamilton

@hamilton I also experience slow frame rate on my MacOs (yes I assume your launched the test on a Mac, am I right ?), but I did yet had the time to dig into it since I mostly use, Raspberry Pi 3, Beaglebone Green Wireless for testing.

Regarding the configuration of the sensors, yes the device keep the configuration till a soft rest is performed or the coin cell is removed. I need to make sure the configuration will then properly override any previous settings or the other way around, the previous sensor fusion is properly reseted.

Btw, you can perform a soft reset via the Debug register, here is an example

alanhortz avatar Mar 02 '17 16:03 alanhortz