What is the exact formula that Garmin uses for calculating running pace (km/min)? We would like to use it for displaying the current pace in a Garmin watch app.
What is the exact formula that Garmin uses for calculating running pace (km/min)? We would like to use it for displaying the current pace in a Garmin watch app.
Thank you for the answer FlowState! We already use the exact same parameters but we have run into the problem that the pace is fluctuating a lot - in a matter of seconds it can be that the pace differs…
I have found that some users actually prefer pace that *isn't* rounded to 5 seconds, for what it's worth.
To display pace in a watch app, you can take any of the speed fields in ActivityInfo (which are in metres/second), such as currentSpeed:
https://developer.garmin.com/connect-iq/api-docs/Toybox/Activity/Info.html#currentSpeed-var
(The other two are maxSpeed and averageSpeed)
Then:
1) Convert to appropriate units (km/s or miles/s). You can do this based on the user's device settings, if you wish. (This would produce results similar to the native Pace field). developer.garmin.com/.../DeviceSettings.html
2) Take inverse
3) Format as "[hh:]mm:ss". (Garmin displays "--:--" when your pace is very slow, or when speed is null/unavailable.) For my own apps, I use 0.44704 m/s as the threshold for "moving", which is roughly 30:00 per mile. (I based that on Strava's moving cutoff). That's about 48:00 per km.
Also see: developer.garmin.com/.../Activity.html
Thank you for the answer FlowState! We already use the exact same parameters but we have run into the problem that the pace is fluctuating a lot - in a matter of seconds it can be that the pace differs almost 1 min. Garmin run mode rounds the pace by 5 seconds - do you know the logic behind it?
Do you also know what permissions should be enabled in the manifest file for the GPS to track properly? We have noticed that with one test watch (Forerunner 735XT) the run mode tracks the distance quite accurately but the app is able to track less km than there are (e.g. 5.6 km instead of 6 km) and isn't showing the elevation or map information. We currently have only ANT and Activity recording enabled - should there be anything else?
In a device app you need this permission
<iq:uses-permission id="Positioning"/>
and you need to enable GPS in the code.
Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));
See the RecordSample in the SDK.
Garmin run mode rounds the pace by 5 seconds - do you know the logic behind it?
It's because they don't think GPS is accurate enough to show pace with greater granularity. As you've found yourself:
We already use the exact same parameters but we have run into the problem that the pace is fluctuating a lot - in a matter of seconds it can be that the pace differs almost 1 min
So if you want to show the same thing as Garmin, I guess you would have to round to the nearest 5 seconds. In that case, if you put your data field next to the native pace field, the results should be identical.
If you're calculating lap pace, you can apply the additional hack/heuristic of showing instant pace for the first 30-45 seconds of a lap, then switching to actual average lap pace for the remainder of the lap. (Garmin does something similar).
I have found that some users actually prefer pace that *isn't* rounded to 5 seconds, for what it's worth.
Thank you for the advice jim_m_58! We managed to get the map to show on the Garmin Connect now :) However, we still have issues with elevation - on Forerunner 735XT the elevation info was captured but with Fenix 6X not.