10-08-2017 14:55
10-08-2017 14:55
I have noticed that when I output batches of sensor data the gyroscope API doesn't seem to obey the same conventions as the heart rate and accelerometer ones. For instance, I used the same initialization object for all sensors:
const sensorOpts = { frequency: 2, // times a second to get reading batch: 4 // number of readings before emiting batch };
// initialize the sensor objects
const hrm = new HeartRateSensor(sensorOpts);
const gyro = new Gyroscope(sensorOpts);
const accel = new Accelerometer(sensorOpts);
which should imply I get 4 readings every two seconds emitted from each sensor but for some reason, it seems I get 4 times as many readings from the gyroscope. I have a gif of the console output but the editor for the post keeps crashing with an "unexpected error" when I try and upload it.
I am calling each sensor as follows:
hrm.onreading = function() { console.log('adding heartrate data') } gyro.onreading = function() { console.log('adding gyroscope data') }; accel.onreading = function() { console.log('adding Accelerometer data') }; // Begin monitoring the sensors hrm.start(); gyro.start(); accel.start();
Am I misinterpreting the API docs for gyroscope? It seems like all the sensor outputs are practically identical. In another semi-related question, is there a way to gather data from all the sensors at once with one `onreading()` as opposed to having to call each sensor separately?