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();
  • Former Member
    Former Member over 7 years ago
    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.


    The ActivityInfo can be used in any application type, but the swimming metrics (swimStrokeType, swimSwolf, averageDistance) are only valid in the native swimming modes.

    The ActivityRecording module cannot trigger these modes, and the documentation could possibly be improved there. It does state:
    The SPORT_* defines the type of activity, but is not guaranteed to change device behavior.

    https://developer.garmin.com/downloads/connect-iq/monkey-c/doc/Toybox/ActivityRecording.html
  • 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


    Thanks for the suggestion. It sounds like there will probably be edge cases in doing this - like if the user turns 180° randomly, but I guess this might be mitigated by using the accelerometer data.

    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.

    Well that sucks :(. Thanks for the info.
  • Former Member
    Former Member over 7 years ago
    You will have to create your own developer field, which you can call "distance",
    ..users do not understand why the calculated distance is 0 and will give you bad ratings ;)


    Thanks for the notes on your app! Gave me insight. I may be the only user who read and understand the problem to be a Garmin restriction; not your fault!

    I'm thinking about writing a Pool Lap Counter app that needs a manual lap button press.

    Workaround idea: perhaps a web request could send lap data to a custom web service for storage/reports (max of ~100 laps, as that's ~2.8 miles in a 25 yd pool)?

    -Tim
    P.S. DanielP - Compass readings are innovative! Unfortunately the app added laps for impossible three or four sec laps. Not that fast. Actually, nobody is that fast! :p
  • I'm thinking about writing a Pool Lap Counter app that needs a manual lap button press.


    Just a note. Native Swimming apps avoid any button presses under water, as the water rating is based on the "unpressed button" and that could change when the button is pressed (the seal will be a bit different)

    Also, the compass is fast enough for 3-4 sec laps. I have apps where I update the display of the compass multiple times a second.

  • Compass readings are innovative! Unfortunately the app added laps for impossible three or four sec laps. Not that fast. Actually, nobody is that fast! :p


    When false lap detections occurs, usually the problem is that the pool calibration which takes place during the first lap was not performed properly. I wrote about it in the user guide. Apps is working pretty good for most of the people(who care to read the user guide....), including me ;)
  • Former Member
    Former Member over 7 years ago
    Unfortunately even the most sophisticated app that detects all sorts of swimming metrics will still NOT be able to supply these to the native FIT fields, such that they can contribute to the accumulation of Intensity Minutes, calories burned, etc. The latter defeating the purpose of the device: Tracking one's fitness.

    Please Garmin, consider opening up the API a bit such that standalone apps will be able to override native FIT fields with their own calculations. Otherwise there is little sense in writing apps for activity tracking in the first place!

    I'm in the process of writing apps for swimming and archery. The archery app is supposed to detect and count arrows being shot (detected from hand shock), so it can use the draw weight of the bow to add up total pounds drawn in a session (often amouting to tons). Without that information being accounted for, merely looking at steps and heart rate will not give a proper picture of the activity's effect on your fitness.

    So again, Garmin please open the API to override/replace native FIT metrics.
  • Looking at Archery, which native fields would you want to override. From what you posted, it sound like data unique to that activity. If you get HR along with it, is that bad?

    In the case of swimming, I'm on the fence if a CIQ should allow a full override of FW generated data. We all have bugs at times, and let's say that bug caused GC's lifetime data to be way off. (distance, etc). Users get mad, and the GC folks would need to clean up the "spill on aisle 3".

    Also, what happens in the case of two data fields that both want to override the same native field?
  • Unfortunately even the most sophisticated app that detects all sorts of swimming metrics will still NOT be able to supply these to the native FIT fields, such that they can contribute to the accumulation of Intensity Minutes, calories burned, etc. The latter defeating the purpose of the device: Tracking one's fitness.

    Please Garmin, consider opening up the API a bit such that standalone apps will be able to override native FIT fields with their own calculations. Otherwise there is little sense in writing apps for activity tracking in the first place!

    I'm in the process of writing apps for swimming and archery. The archery app is supposed to detect and count arrows being shot (detected from hand shock), so it can use the draw weight of the bow to add up total pounds drawn in a session (often amouting to tons). Without that information being accounted for, merely looking at steps and heart rate will not give a proper picture of the activity's effect on your fitness.

    So again, Garmin please open the API to override/replace native FIT metrics.


    Fit format foresees that native fields can be overriden. This is suported by connectiq as well. My fit files can be uploaded to sites fully supporting fit format (runaluze.com, golden cheetah, sporttrakcks.mobi, to name some of them) and native field will be overriden just fine.
    the problem here is not xonnectiq, is garmin connect. They do not fully support fit, and ignore the flag fields.

    i do not agree about Jim comments. There are ways to avoid wrong data being an issue. For instance, garmin overides elevation in fit file by information obtained from a map service. And the user has the choice, to disable this for a certain activity and get back the data in the fit file. Clean and easy. Add a switch for overriden fields and let the user decide which of both to take.

    besides, I do not know how distance zero is better than any distance calculated by the app, even if it is way off. Zero is always way off. Sorry Jim, I admire you a lot, but I don't think you are right here.
  • Like I said, I'm on the fence :)

    Would it just be the case of displaying what's already done in a better way (like the sites you mention), or would it be actually replacing the FW's data in the .fit? And if's replacing the FW's data, what if there are two DFs that both want to replace the same thing?
  • Former Member
    Former Member over 7 years ago
    Yes, there are some unique fields for archery, but, for example, I don't see a way to record in the FIT file the power required to draw the bow on each shot, such that it will count towards total Intensity Minutes and calories burnt? Depending on draw weight, that's significant physical effort. How would I best do this?