getActivityInfo Current Speed Filtering

I'm using the following function to get the current speed.

function getCurrentSpeed() {
var info = Activity.getActivityInfo();
return info.currentSpeed;
}


When the Activity is setup like below:

_activity = Recording.createSession({
:sport => Recording.SPORT_CYCLING,
:subSport => Recording.SUB_SPORT_GENERIC,
:name => "515"
});


The returned speed value appears to have almost no filtering. It responds to a change in speed very quickly but it's also very noisy.

When the Activity is setup as a running activity like:

_activity = Recording.createSession({
:sport => Recording.SPORT_RUNNING,
:subSport => Recording.SUB_SPORT_GENERIC,
:name => "515"
});


The returned speed value appears to be smoothed for 30 - 60 seconds.

Is this the intended behavior? Can the smoothing be adjusted?

For my application, the 30-60 seconds is too slow of a response. I don't want to use the CYCLING sport type because then it doesn't record running cadence from the watch accelerometer. What are my options for getting at a less filtered speed value from the GPS?
  • I worked around the problem by calculating my own speed value from the distance and time values.

    This function is called once per second so this gives me about 5 second smoothing but can be easily adjusted. Seems to provide nice feedback on a VivoActive in my initial test. It's easy to change paces to hit a new target.

    This way, I can use a RUNNING Activity and also collect the running cadence data.

    hidden var _spdSmooth = 5;
    hidden var _distList = new [_spdSmooth + 1];
    hidden var _timeList = new [_spdSmooth + 1];
    hidden var _numValues = 0;

    ...

    function getCurrentSpeed() {
    var info = Activity.getActivityInfo();
    var speed = null;
    var sumX = 0;
    var sumY = 0;
    var sumXY = 0;
    var sumXX = 0;
    if (info.elapsedDistance != null && info.elapsedTime != null) { // if they aren't null, add them to the list
    _timeList[_numValues] = info.elapsedTime;
    _distList[_numValues] = info.elapsedDistance;
    _numValues = _numValues + 1;

    if (_numValues > _spdSmooth) { // if the list is full, shift it down
    for (var i = 0; i < _numValues; ++i) {
    _timeList= _timeList[i + 1];
    _distList= _distList[i + 1];
    _numValues = _spdSmooth;
    }
    }

    if (_numValues > 1) { // if we have more than 2 values, try to calculate the slope
    for (var i = 0; i < _numValues; ++i) {
    sumX = sumX + _timeList;
    sumY = sumY + _distList;
    sumXY = sumXY + _timeList*_distList;
    sumXX = sumXX + _timeList*_timeList;
    }
    if (_numValues * sumXX - sumX * sumX != 0) {
    speed = 1000 * (_numValues * sumXY - sumX * sumY) / (_numValues * sumXX - sumX * sumX);
    }
    else {
    speed = null;
    }
    }
    }
    return speed;
    }
    [/CODE]
  • was playing around with the F3 and saw that it also happens on the F3. When running the bike app, the speed is very responsive. But when I use a custom app and do speed, I can see that the speed is very dampened.
  • Former Member
    Former Member over 9 years ago
    How it looks on speed graph? Does it take whole minute to stabilize, like on VA? Some smoothing is expected, just not that much.