Announcement

Collapse
No announcement yet.

Toybox.Activity.Info.offCourseDistance is always null when Off Course Warnings is off

Collapse
X
  • Time
  • Show
Clear All
new posts

  • Toybox.Activity.Info.offCourseDistance is always null when Off Course Warnings is off

    According to the API documentation, the attribute offCourseDistance in class Toybox.Activity.Info contains the distance to the nearest point on the current course in meters. I have tested the value of this attribute with a simple data field with the following code in the compute method of the View class:

    Code:
        function compute(info) {
            if (info != null and info has :offCourseDistance) {
                if (info.offCourseDistance == null) {
                    return "null";
                } else {
                    return info.offCourseDistance;
                }
            } else {
                return "-";
            }
    Next, I have uploaded a course on my Garmin Edge 1030, and started riding it. The Off Course Warnings setting on the Edge is off.

    While I am not riding off course, the simple data field shows null (which indicates that info.offCoursedistance is null).

    When I am riding deliberately off course, the simple data field still shows null. At the same time the native data field Dist. to Next, however, shows the distance between my current location and the nearest point on the course. (This behavior of this native data field is not documented, but from experience I have learned that this is the case.) Therefore, the Edge has detected that I am indeed off course.

    When I repeat this test with the Off Course Warnings setting switched on, info.offCoursedistance is still null when I am not riding off course, but some value is showing in my simple data field when I ride off course. This value, however, is sometimes null, and sometimes a numeric value, but never a value that is equal to the value in the native data field Dist. to Next.

    This is not at all what I expected. I would expect info.offCoursedistance to have the following value:
    • null when I am not riding a course
    • 0 when I am riding a course, and I am not off course
    • The same value shown in native data field Dist. to Next when I am riding a course and I am off course

    I would expect these values to be independent from the Off Course Warnings setting. Specifically, if Off Course Warnings is off, info.offCoursedistance should still have a value when I am riding off course. Switching on Off Course Warnings has undesired side effects (buzzes, pop-ups). And what is more, there is no way in Connect IQ to check the value of the Off Course Warnings setting.

    Some additional information:
    • Garmin Edge 1030, firmware version 3.90
    • Code sample created with Eclipse IDE for Java Developers Version: Oxygen.3a Release (4.7.3a) and Connect IQ SDK 3.0.7
    Last edited by Stephen.ConnectIQ; 01-14-2019, 09:44 AM.

  • #2
    First thing I would do is update firmware. Current FW on edge 1030 is 7.00. If you are running 3.90, there could have been relevant changes.

    If you are off course, and you have off course warnings disabled, you should still get a value from Activity.info.offCourseDistance. (if you are getting null here, I would try updating FW)

    I'm also concerned that the distance measurements are different from the native "Dist. to Next" and the Activity.Info.offCourseDistance. I don't know how the what the native data field is actually calculating, so i'm going to need to look into more detail to see if these values should be the same.

    If you update FW and are still getting null when off course, please let me know and I will make a ticket for that.

    Comment


    • #3
      I agree you've found a legitimate issue here. That said, I think you should expect offCourseDistance to not be equal to distanceToNextPoint (and the Dist. to Next data field) in *most* situations.

      The following is incorrect and left behind for continuity.

      I think the following image will help to illustrate. course_geometry.jpg


      The distanceToNext field (and the Dist. to Next data field) should tell the distance from the current location to the next recorded point in the course, regardless of whether you are on course or not. The offCourseDistance field should tell the distance from the current location to the course. If you are off course, but riding parallel to it, I'd expect distanceToNextPoint and offCourseDistance to approach the same value as you ride past the next point. I'm not sure of the logic used internally to detect when you've passed a point, but I'd expect it to do so when you cross the imaginary line that runs perpendicular to the path and passes through the given course point.

      I do agree that unless there is some good reason, we should report offCourseDistance independent of the Off Course Warnings setting.
      Last edited by Travis.ConnectIQ; 01-14-2019, 10:04 AM.

      Comment


      • #4
        Originally posted by Travis.ConnectIQ View Post
        The distanceToNext field (and the Dist. to Next data field) should tell the distance from the current location to the next recorded point in the course, regardless of whether you are on course or not.
        Isn't the "dist to next" to the next course point or calulated turn?

        From what I've seen on an older unit (800), the "dist to next" is the difference between the next course point and the distance of the track point you are nearest to.

        Comment


        • #5
          Originally posted by dpawlyk View Post
          Isn't the "dist to next" to the next course point or calulated turn?
          Yes, that is exactly what I'm saying above. Dist. to Next is the distance from you to the next course point... the blue line in the graphic.

          The only way that makes any sense is described above. The distanceToNext (and Dist. to Next) is the distance between your current position and the next course point, and offCourseDistance is the minimum distance to get back to the course.


          Originally posted by dpawlyk View Post
          From what I've seen on an older unit (800), the "dist to next" is the difference between the next course point and the distance of the track point you are nearest to.
          I can't say what the edge800 does or did, but it sounds like you're saying Dist. to Next is reported on that device as the distance from nearest point on course to next point on course? That doesn't make any sense to me. Imagine that you are on a course segment that is 1 miles long, and you were 2 miles off course, the distance reported would be at most 1 mile... even though you'd have to go at least 2 miles just to reach the nearest point.

          Travis

          Comment


          • #6
            Originally posted by Travis.ConnectIQ View Post
            The distanceToNext field (and the Dist. to Next data field) should tell the distance from the current location to the next recorded point in the course, regardless of whether you are on course or not.
            Originally posted by Travis.ConnectIQ View Post
            Yes, that is exactly what I'm saying above. Dist. to Next is the distance from you to the next course point... the blue line in the graphic.
            "Next Recorded point"' sounds like "next track point" (people might have gotten confused).

            Originally posted by Travis.ConnectIQ View Post

            I can't say what the edge800 does or did, but it sounds like you're saying Dist. to Next is reported on that device as the distance from nearest point on course to next point on course? That doesn't make any sense to me. Imagine that you are on a course segment that is 1 miles long, and you were 2 miles off course, the distance reported would be at most 1 mile... even though you'd have to go at least 2 miles just to reach the nearest point.
            What makes sense when you are on the course?

            When you are on the course, the "dist to next" is a indication of how far you need to ride to get there.

            The 800 (if I recall) stopped updating the field when you went off-course. When you returned to the course, it would update using the point on the course you returned to (the point on the course the unit "found").

            The general idea of the "off course warning" is to make you get back on course as quickly as possible. For that, there isn't much utility to changing the the value of "dist to next".

            Changing the value from being "along the course" to "straight line distance" to the next course point could cause the number to drop to something much smaller (depending on the course), which would be confusing.

            Given that the "off course warning" happens at a short distance, it would be weird to change the number to "straight line distance" (because the number could change by a lot). It makes more sense (to me) to just stop updating it.

            If you are two miles off-course, that un-updated number wouldn't be useful but the straight-line distance might not be useful either. The straight line is not really an indication of how far you need to ride and following it might not be possible.

            Being far-off the course (two miles is huge) means you aren't following the course. It's really outside of how courses (and course points) are intended to be used.

            ==================================

            The "dist to next" is not just a navigation tool ("how far to the next turn").

            It's also an effort tool ("how far will I need to ride the race course until I can get food/water").


            If you are really off-course, the next course point isn't usually going to be useful for navigation.


            If you go off-course, you could be moving farther away from the next course point. Flipping to displaying the straight-line distance would, in that case, be wrong.

            Straight-line distance to a point is not that useful without an indication of the bearing to that point.
            Last edited by dpawlyk; 01-12-2019, 06:43 AM.

            Comment


            • #7
              Originally posted by Travis.ConnectIQ View Post
              I can't say what the edge800 does or did, but it sounds like you're saying Dist. to Next is reported on that device as the distance from nearest point on course to next point on course? That doesn't make any sense to me. Imagine that you are on a course segment that is 1 miles long, and you were 2 miles off course, the distance reported would be at most 1 mile... even though you'd have to go at least 2 miles just to reach the nearest point.
              The usual response to going off-course is to do a U-turn. In many cases, it's the only real (or allowed option).

              Being 2 miles off course is an unusual situation.

              If you want a better estimate of how far you need to ride, the number should be the sum of your path off-course and the distance to the next course point along the course (in your picture, the sum of the legs, not the length of the hypotenuse). That's what it should do but I doubt that it does that.
              Last edited by dpawlyk; 01-12-2019, 06:44 AM.

              Comment


              • #8
                I believe his would come into play for other devices that have something like hiking or trail running along with cycling, where a U-turn isn't involved.
                My Connect IQ Apps in the Store
                Facebook - Instagram -
                Twitter

                Comment


                • #9
                  Originally posted by dpawlyk View Post
                  What makes sense when you are on the course?
                  Using the system I've outlined above, when you are on course, offCourseDistance could be null (you are not off course), or 0 (you are zero units from the course line). Personally, I feel like null makes sense, but neither seems wrong. And distanceToNext should be the length of the line segment from your current position to the next course point.

                  Originally posted by dpawlyk View Post
                  When you are on the course, the "dist to next" is a indication of how far you need to ride to get there.
                  Yes, using the definition I've provided above, distanceToNext would be a reasonable estimate of the distance you'd have to ride to get to the next course point regardless of how far you are off course.

                  Originally posted by dpawlyk View Post
                  The 800 (if I recall) stopped updating the field when you went off-course.
                  But we're not talking about an edge800. That device doesn't support ConnectIQ, and it most likely does not have any way to indicate the offCourseDistance.

                  Originally posted by dpawlyk View Post
                  The general idea of the "off course warning" is to make you get back on course as quickly as possible.
                  If you want to get back to the course as quickly as possible, you'd proceed directly to the course line from your current position. That path would be the blue line segment shown above (offCourseDistance).

                  Originally posted by dpawlyk View Post
                  ... there isn't much utility to changing the the value of "dist to next".
                  If you're following a course and there is a detour it would seem useful to see how you are from the next course point.

                  Originally posted by dpawlyk View Post
                  Changing the value from being "along the course" to "straight line distance" to the next course point could cause the number to drop to something much smaller (depending on the course), which would be confusing.
                  Certainly. And reporting the distanceToNext as the distance from the _nearest point on course_ to the _next point on course_ would be misleading as well. If you are a block off course and it reports that you are 0 meters off course, that would be very confusing.

                  Originally posted by dpawlyk View Post
                  Given that the "off course warning" happens at a short distance, it would be weird to change the number to "straight line distance" (because the number could change by a lot).
                  If you have not deviated from the course significantly (because the warning happens at a short distance) the distanceToNext number won't change by a lot, right? Only when you get off course by a significant amount would the difference even be noticeable.

                  Originally posted by dpawlyk View Post
                  If you are two miles off-course, that un-updated number wouldn't be useful but the straight-line distance might not be useful either. The straight line is not really an indication of how far you need to ride and following it might not be possible.
                  A straight-line distance is a better estimate of how far you will need to go than no estimate at all.

                  Originally posted by dpawlyk View Post
                  If you go off-course, you could be moving farther away from the next course point. Flipping to displaying the straight-line distance would, in that case, be wrong.
                  There is no flipping. I'm suggesting that distanceToNext is [b]always[/i] the hypotenuse of the triangle above. If you are on course, the distanceToNext is going to be so close to the distance from the nearest point on course to the next point on course that you'd never be able to tell which is being used. The further you go off course, the more you'd see a difference.

                  If you are moving further away from the next course point, distanceToNext would increase. You'd be able to tell pretty easily that you were going the wrong direction. Not to mention you have offCourseDistance to tell you that you're getting further from the course.

                  Originally posted by dpawlyk View Post
                  Straight-line distance to a point is not that useful without an indication of the bearing to that point.
                  It seems better to provide that than to stop updating the distanceToNext entirely.


                  Comment


                  • #10

                    Originally posted by Travis.ConnectIQ View Post
                    There is no flipping. I'm suggesting that distanceToNext is always the hypotenuse of the triangle above.
                    It isn't and it would be a garbage number if it was (while on course).

                    In the image below, the curvy line is the course/track.

                    On course, the distance to next isn't the straight-line distance because that distance is almost always wrong.

                    If you are off course, the straight-line distance could be very misleading. In the image below, the straight-line distance would be decreasing, misleading you into believing you where going the right way!

                    distnext.png



                    => The distance-to-next number should decrease if you are going the right way.
                    => Ideally, it should increase if you are going the wrong way.
                    Last edited by dpawlyk; 01-13-2019, 06:19 AM.

                    Comment


                    • #11
                      Originally posted by Stephen.ConnectIQ View Post
                      If you update FW and are still getting null when off course, please let me know and I will make a ticket for that.
                      You are right of course, I should have updated the firmware before posting. I did update the firmware to version 7.00 just now, and rode another test ride going deliberately off course, with the Off Course Warnings setting off. The results is the same: info.offCourseDistance is null.

                      So if you could submit a ticket for this issue, that would be great.

                      Originally posted by Stephen.ConnectIQ View Post
                      I'm also concerned that the distance measurements are different from the native "Dist. to Next" and the Activity.Info.offCourseDistance. I don't know how the what the native data field is actually calculating, so i'm going to need to look into more detail to see if these values should be the same.
                      I am curious how the native data field Dist. to Next is calculated, especially when I am riding off course. Maybe you can retrieve some information about that and post it?

                      Comment


                      • #12
                        Originally posted by Travis.ConnectIQ View Post
                        Yes, that is exactly what I'm saying above. Dist. to Next is the distance from you to the next course point... the blue line in the graphic.
                        I don't know about the distanceToNexPoint attribute, because I haven't tested that. But on my Edge 1030 (and also on my old Edge 800) the Dist. to Next data field does not show the distance of the blue line in your drawing, that is, the distance from the current location to the next course point when you are off course. Instead, Dist. to Next shows the distance from the current location to the nearest point on the course track, that is, the green line in your drawing. I have experienced this behavior very often. When I am riding on course, and the distance to the next course point is, say, 50 kms, Dist. to Next displays 50 kms. As soon as I go off course, Dist. to Next displays values like 10 meters, 20 meters, and so on, steadily increasing as I move away from the course. Obviously, the next course point is still approximately 50 kms away (blue line), and the values of 10 meters, 20 meters etc. are the distance from the current location to the nearest point on the course (green line). Therefore, my conclusion is that the Dist. to Next data field shows the off course distance when you are riding off course.

                        I agree with your statement in my other post that info.offCourseDistance should contain the distance of the green line. Whether the value of the native data field Dist. to Next should show the distance of the green line or of the blue line is another (interesting) question.

                        Comment


                        • #13
                          Originally posted by Travis.ConnectIQ View Post
                          Using the system I've outlined above, when you are on course, offCourseDistance could be null (you are not off course), or 0 (you are zero units from the course line). Personally, I feel like null makes sense, but neither seems wrong.
                          Null indicates "no data". It should be used when off-course distance can't be determined (like when there is no GPS signal).

                          Originally posted by Travis.ConnectIQ View Post
                          And distanceToNext should be the length of the line segment from your current position to the next course point.
                          No, it should be the amount of distance you need to ride on the course until the next course point.

                          Originally posted by Travis.ConnectIQ View Post
                          Yes, using the definition I've provided above, distanceToNext would be a reasonable estimate of the distance you'd have to ride to get to the next course point regardless of how far you are off course.
                          No. Often, it would just be wrong. It's very rare that it would be possible to ride that straight path. So, in practice, we already know it's wrong.


                          Originally posted by Travis.ConnectIQ View Post
                          But we're not talking about an edge800. That device doesn't support ConnectIQ, and it most likely does not have any way to indicate the offCourseDistance.
                          The devices tend to all work the same way for the same features. IQ is new stuff added to old stuff.

                          Originally posted by Travis.ConnectIQ View Post
                          If you're following a course and there is a detour it would seem useful to see how you are from the next course point.
                          It's not that useful. It's likely that most people would not understand it. The distance people care about is how far they need to ride. The straight-line distance is almost always never the distance they need to ride (it's generally shorter).

                          Originally posted by Travis.ConnectIQ View Post
                          Certainly. And reporting the distanceToNext as the distance from the _nearest point on course_ to the _next point on course_ would be misleading as well.
                          Nothing is perfect. The straight-line distance is almost always wrong (since it is rarely a path you can take).

                          Originally posted by Travis.ConnectIQ View Post
                          If you are a block off course and it reports that you are 0 meters off course, that would be very confusing.
                          Originally posted by Travis.ConnectIQ View Post
                          If you have not deviated from the course significantly (because the warning happens at a short distance) the distanceToNext number won't change by a lot, right? Only when you get off course by a significant amount would the difference even be noticeable.
                          No. It depends on how close the course points are and how curvy the track is.

                          Originally posted by Travis.ConnectIQ View Post
                          A straight-line distance is a better estimate of how far you will need to go than no estimate at all.
                          You always have a number. There's always an estimate. The straight-line distance is almost always wrong.

                          Originally posted by Travis.ConnectIQ View Post
                          There is no flipping. I'm suggesting that distanceToNext is [b]always[/i] the hypotenuse of the triangle above.
                          No, on the course, it's the track distance.

                          Originally posted by Travis.ConnectIQ View Post
                          If you are on course, the distanceToNext is going to be so close to the distance from the nearest point on course to the next point on course that you'd never be able to tell which is being used.
                          No, that would only ever really be true for a straight track. If the track is curvy or if the course points were far apart, the straight-line distance would be wrong.

                          Comment


                          • #14
                            Originally posted by mweijs View Post
                            I don't know about the distanceToNexPoint attribute, because I haven't tested that. But on my Edge 1030 (and also on my old Edge 800) the Dist. to Next data field does not show the distance of the blue line in your drawing, that is, the distance from the current location to the next course point when you are off course. Instead, Dist. to Next shows the distance from the current location to the nearest point on the course track, that is, the green line in your drawing. I have experienced this behavior very often. When I am riding on course, and the distance to the next course point is, say, 50 kms, Dist. to Next displays 50 kms.
                            When you are on course, the only reasonable thing is for the dist-to-next to indicate the track distance (the distance along the course you need to ride, taking all the curves into account).

                            If you leave the track and return to it closer to the next course point, the distance is updated to reflect the point you return to.

                            While you are on-course, the hypotenuse (straight-line) distance is a meaningless number.

                            Originally posted by mweijs View Post
                            I agree with your statement should contain the distance of the green line.
                            This is the only reasonable thing for the off-course distance to be.

                            Originally posted by mweijs View Post
                            Whether the value of the native data field Dist. to Next should show the distance of the green line or of the blue line is another (interesting) question.
                            If you are not very far off course, changing the value of this number to the straight line distance would sometimes, give a number that is much smaller than it was just an instance ago. That would just be confusing. Since it's only rarely possible to travel on the straight-line distance, for all practical purposes, it never indicates the distance you need to ride. In some cases, it would radically underestimate the distance.

                            If you are way off-course, the dist-to-next becomes meaningless and there really isn't anyway to make it meaningful. Given that the straight-line distance is almost always wrong, it isn't a choice (it's meaningless too).


                            => The distance-to-next number should decrease if you are going the right way.
                            => Ideally, it should increase if you are going the wrong way.


                            =====================

                            The straight-line distance can be used for navigation but you also need the bearing for it to be useful. It's kind-of a specialized navigational skill. Hikers in places that don't have mapped trails (or with GPS's that don't have maps) use this method. For cycling (or driving) on roads, it's not that useful (and confusing to many people).

                            Straight-line/bearing is one navigational technique.

                            Track-following is a different navigational technique.

                            No device should flip from one technique to another.
                            Last edited by dpawlyk; 01-13-2019, 06:50 AM.

                            Comment


                            • #15
                              Again, this post shows my misunderstanding. It is not unreasonable to have a course with two course points and a track that has many turns.

                              The course you've drawn doesn't make sense to me. If you assume that the start of the course is a course point, and the next point on the course is the X, the course is a straight line from the start to the X. If you assume that the black line is the path to follow, then:
                              1. The statistics will be completely wrong. The course distance will be significantly shorter than the trail the user is expected to follow, the elevation profile will be compressed..
                              2. Most of the trail will be off course. As soon as you leave the start heading east, you'd go off course. The distance to the course will increase until some point along the eastern edge of the bottom half of the S. As you head back toward the middle of the S, the distance to the course should decrease until you cross the middle of the S. At that point the off course distance would keep increasing until some point along the western edge of the top half of the S.
                              Right?
                              Last edited by Travis.ConnectIQ; 01-14-2019, 10:07 AM.

                              Comment

                              Working...
                              X