Record Swimming activity within app

In writing an app for swimming I'm encountering a few issues.

1) I'd like to get distance updates by polling with Activity.getActivityInfo(). I've been checking the 'elapsedDistance' field of the Info object, but it doesn't seem to match the distance swum with the Fenix 5x at all. It shows around 600 or 700 (not sure which units) for a 25m swim. Am I just not interpreting this distance correctly or is this a bug or missing feature?

2) When the .FIT file which is generated syncs with Garmin Connect, the data is not right - a few times when I went for about a 100m swim Garmin Connect showed around 5k yards swum in a few minutes. Other times Garmin Connect has shown 0 for the distance. Am I not recording the swim activity correctly?

var activityName = "Swimming";
var activitySport = ActivityRecording.SPORT_SWIMMING;
var activitySubSport = ActivityRecording.SUB_SPORT_LAP_SWIMMING;

session = ActivityRecording.createSession({
:name=>activityName,
:sport=>activitySport,
:subSport=>activitySubSport
});

session.start();


and later...

var info = Act.getActivityInfo();


and later ...

session.save();
  • This sounds like a question for the developer forum (one level up), and isn't really a bug report. There's a sticky at the top of this forum that shows how to make a bug report.

    Are you trying to use GPS while you're recording? That will likely give you bad info in the water., especially if you didn't wait for a good GPS signal.
  • Ah, my bad. Should I start a new thread in the developer forum? Also, I didn't enable GPS in code at all - is it at the device settings level that I need to disable it or can it be done through code?
  • Former Member
    Former Member over 7 years ago
    I moved the thread for you.

    At this time (SDK version 2.4.2) it is not possible to access the special swimming recording modes of the device when recording applications with Connect IQ. Setting a swimming mode for the activity will tag the activity as that mode, but does not enable lap or open water swimming distance calculation methods within the device.
  • Former Member
    Former Member over 7 years ago
    Hi
    just wondered if anyone could help. How do you get the vivisport to record your swimming laps? Thanks
  • At this time (SDK version 2.4.2) it is not possible to access the special swimming recording modes of the device when recording applications with Connect IQ. Setting a swimming mode for the activity will tag the activity as that mode, but does not enable lap or open water swimming distance calculation methods within the device.


    That's very disappointing to hear, especially since we've been in talks with Garmin for some time now about using this functionality in a stand-alone app. Why does the documentation show this data as being available with no mention that it cannot be accessed?

    I did notice that the distances would update (although inaccurately) when I changed directions in the pool. This leads me to believe there might be a slightly unorthodox way to track distance swum - by 1) knowing the length of the pool, and 2) adding that length to the total distance every time the distance updates. Does this sound like a work-around you would recommend?
  • Former Member
    Former Member over 7 years ago
    I am not familiar with the behavior you are describing, so I cannot make a recommendation there.

    The swimming metrics that are available in the ActivityInfo are available for use by the Data Field application type, which can be embedded into the lap swimming native activity profile. Is this the documentation you are referring to?

  • That's very disappointing to hear, especially since we've been in talks with Garmin for some time now about using this functionality in a stand-alone app. Why does the documentation show this data as being available with no mention that it cannot be accessed?

    I did notice that the distances would update (although inaccurately) when I changed directions in the pool. This leads me to believe there might be a slightly unorthodox way to track distance swum - by 1) knowing the length of the pool, and 2) adding that length to the total distance every time the distance updates. Does this sound like a work-around you would recommend?


    if you develop a standalone app, you can use the in-device sensors (accelerometer, compass,...) to detect turns and then calculate the distance by adding lengths. This is what I do in my app


    https://apps.garmin.com/en-US/apps/f134a024-6ee4-47d3-8aec-3a397e3c9733

  • if you develop a standalone app, you can use the in-device sensors (accelerometer, compass,...) to detect turns and then calculate the distance by adding lengths. This is what I do in my app


    Great I'll check out your app! Any advice on the turn-detection algorithm you'd be willing to share? I totally understand if you don't want to share but it would be a great help.
  • The swimming metrics that are available in the ActivityInfo are available for use by the Data Field application type, which can be embedded into the lap swimming native activity profile. Is this the documentation you are referring to?


    This needs to be made much clearer. I'm having trouble finding where in your documentation you say that ActivityInfo can only be used with a Data Field (I'm not saying it's definitely not there, but I can't find it). Can you point me to that?

    Unfortunately I don't think I'm going to be able to get away with just creating a Data Field, since the main point of the app is to sync up with the phone, grab and post data to our endpoints, display different options to the user etc.
  • Great I'll check out your app! Any advice on the turn-detection algorithm you'd be willing to share? I totally understand if you don't want to share but it would be a great help.

    I use the compass. A turn happens when direction changes 180°
    it could be probably be done with the accelerometers by looking for peaks, if you assume that the swimmer will push the wall after each turn.
    one problem you are going to have, is that you won't be able to write the native distance field shown in garmin connect (and in strava, when the activity gets synced). You will have to create your own developer field, which you can call "distance", but which will not override native one, because neither garmin connect nor strava do support fit2 format.
    the funny thing is that some 3rd party sites (sporttracks, training peaks, runalyze, maybe more) do support this format. And they will override the distance.
    users do not understand why the calculated distance is 0 and will give you bad ratings ;)