Hi, I am testing code that receives data from the ANT+ simulator's SDM sensor. I have set the simulator to send a speed of 6 MPH on the parameters page. Stride length is set to the default 75cm.
What I am trying to do is to calculate an avg speed over time. My expectation would be in this test that my avg speed over any period of time during this simulator session would be 6 MPH. However it is not, and I don't know what I am doing wrong. I believe I am correctly interpreting distance (including fractional distance) as well as speed (including fractional speed). I accumulate the distance received over time and then take time / distance to compute the average. While it is very close to 6MPH, it is not exact, and in fact fluctuates over the course of the test. It might be 5.86, then 6.12, then 5.93, etc.
Looking closely at the data coming in, I am most suspicious of the distance I am receiving. It veries quite a bit, and it is always expressed rounded to 1/4 of a meter. In other words I see distance coming in each received message as 1.25, 2.5, 1.75, 2.5, etc.
I guess I don't understand two things:
a) in a controlled set of messages being generated by the ANT+ simulator given a fixed speed of 6mph, why would the simulator generate such an array of varying distances? Wouldnt it send me the same meters travelled each time? I understand in real life with a footpod that the data would vary, but I dont understand why it would vary coming from the simulator.
b) I am suspicious that the distance in meters I am getting is rounded by .25 meter. It seems odd that it wouldn't be a more precise number.
Here is how I am interpreting distance:
float fDistanceInMetersWhole = rxBuffer[3];
char cDistanceFractional = rxBuffer[4] & 0xF0) >> 4);
// divide by 16 to get meters
float fDistanceFractional = (float)cDistanceFractional / 16.0;
// add to the whole number distance
float fDistanceInMeters = fDistanceInMetersWhole + fDistanceFractional;
Like I said, the numbers are very close, but given the controlled nature of this test I would expect them to be exact. Also I have code that handles rollovers.
Any help would be appreciated.