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:

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
  • 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.
  • 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.


    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.
  • 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.
  • 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.


    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
  • 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.


    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).

    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.
  • 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.
  • 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.
  • 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.

    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.

    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.

    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).

    ... 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.

    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.

    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.

    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.

    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 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.

    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.



  • 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!





    => 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.
  • 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.

    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?