Getting negative speeds from Position?

Hi all. I am developing a very simple app that acts as a position logger. Put simply, I set up my position object (Position.enableLocationEvents) and create a session (ActivityRecording.createSession with sport Activity.SPORT_GENERIC), and my Garmin (a Fenix 6 pro device) already logs position and speed to a FIT file.

The problem comes when I analyze the data from speed (enhanced_speed field to be more precise). I realized that, if I stay still in a place for a while (before starting my running) the speed goes to 0 as intended, but just at the moment fo the start it goes to negative values just after increasing to the real corresponding speed.

I also noticed that the plotted data seems "too smooth" to be the raw speed as obtained from the GPS. These two things lead me to think that this enhanced_speed field does not correspond to the raw speed data but has some sort of filtering applied, which creates these moments of negative speed and smoothness. 

My question now is: how can I disable the filtering? Or, is there any way to directly retrieve the raw GPS speed from a FIT file?

Thanks in advance!

  • Why don't you record the whatever data you want (gps coord or speed you calculate from it)?

  • What is the difference between that and what I am currently doing?

  • You can't disable the filtering, and location/etc is written to the fit file by the firmware.  You can use fitcontrib to write your own data, but is does not override what the firmware wrote.

    There was a great presentation about GPS, and why this filtering occurs at the CIQ Summit in 2018, but there is no video available from it.

  • but this negative speed sounds like a huge bug

  • But where is that coming from?  The FW or is it being calculated?  With GPS, and the version of GPS on a device, if you start an activity with GPS, get a lock, and just stay in the same spot for a couple minutes, when you save and sync the activity, in GPS, you'll often see kind of a "startburst" around where you were standing still.  GPS isn't accurate to the mm, and it can "wobble" a bit, and the location changes a few feet in different directions even if you are standing still.  I've never see a "negative speed" in any app that uses the GPS data from the FW.  The OP didn't mention the device being used, but I started doing GPS apps back in 2015 on the original vivoactive.

    I wonder if he calls it "negative speed" if the location shows he's moving in the opposite direction from what he thinks he should be moving?

  • But where is that coming from?  The FW or is it being calculated?  With GPS, and the version of GPS on a device, if you start an activity with GPS, get a lock, and just stay in the same spot for a couple minutes, when you save and sync the activity, in GPS, you'll often see kind of a "startburst" around where you were standing still.  GPS isn't accurate to the mm, and it can "wobble" a bit, and the location changes a few feet in different directions even if you are standing still.  I've never see a "negative speed" in any app that uses the GPS data from the FW.  The OP didn't mention the device being used, but I started doing GPS apps back in 2015 on the original vivoactive.

    I wonder if he calls it "negative speed" if the location shows he's moving in the opposite direction from what he thinks he should be moving?

    If you bothered for once to use the awesome power of “actually reading the post you’re replying to” (as opposed to skimming and condescendingly assuming OP has no idea what they’re talking about), you would see they that they are referring to the native enhanced_speed field in the FIT file. It’s in that field that they see negative values when they go from standing still to running.

  • It does, indeed! I can provide a FIT file as an example if needed, but it should be easy to replicate, since it happens both in my Fenix 5 and 6. I also suspect that there may be some kind of kalman/complementary filter going on here, since I think that these small spikes with negative speed take place mainly when I get some impulse before starting the activity from a stop position (maybe there's some data from the accelerometer producing these negative values?) This is just a random guess though, I don't know if anyone else has more experience with this

  • I'm not Garmin but I think it would be useful if you could play with it a bit more and include a list of steps to reproduce. To tell you the truth I've never looked (I think) at the enchanced_speed field (unless it's something displayed in GC) so maybe it does happen to me as well. Occasionally I exit my home, start a walk or run immediately even though I see the GPS hasn't got a fix yet. I think (at least that's what I would do) in this case the step counter will take over until a GPS fix is aquired. I know it works when I enter a building where there isn't any chance for the GPS (though I did report a few weeks ago that in this case strangely the distance calculated based on the steps is about half of what it would be calculated if I disable GPS in the activity) My guess is that maybe a glitch happens at the moment when the calculations are switched from step based to GPS based. Anyway negative speed makes no sense, it should be fixed (0 or abs)

  • Problem solved!! I was implementing a filter with the data from the GPS Speed and at some specific glitchy situations as you suggested it could deliver some negative values. Thanks for the help!