Grade Calc - Community Project

I'm still not happy with CIQ Grade calcs. I live in Florida (mostly flat) so I really don't have a lot of real world opportunities to test Grade. On the other hand, these subtle rollers are some of the most challenging use cases to test the algorithm. The problem seems to be that barometric values aren't updated quickly - and then they tend to jump in a step function when they do change.

Even up steeper grades like Colorado passes that I got to ride last weekend, barometric data isn't smooth. A balance is needed between grade being noisey (due to barometric jumps) or slow to respond (due to smoothing out those jumps). I've tried to make the balance factor adaptive. So it detects a slope inversion or a transition to/from flat roads faster.

Even the native grade values are slow to respond. However, Garmin apparently did a lot of work on this problem in the new Garmin EDGE 1050 (according to DC Rainmaker's beta evals) and now the native grade is dramatically better. As soon as you hit a steep grade from a flat road, for example, grade will reflect a legit value, not slowly adjust over 10-15 seconds. Maybe using the accelerometer sensor to assist?

Anyway, Garmin still refuses to expose native Grade to CIQ. So we have to figure this out on our own.

I am thinking about a Community Effort to optimize the CIQ Grade calcs. I'll create a DF that only generates grade, and that writes to the FIT file, with some User Settings for various variables. I'll display the current grade as well as a line graph of grade to show how our algorithm adapts to slope changes, slope inversion, and transitions to/from flat roads. And I can display this and the EDGE's native grade on the same screen to compare.

I'll post the CIQ Code in GIT Hub and allow contributors to check out, and update. I bet we can come up with a barrel pretty quick that does a great job.

This image shows a pretty steep sustained grade (grey is the elevation profile, blue is my current GRADE calc). Now that I write a FIT graph I have more visibility into the dynamics and I clearly need to smooth it a bit more. I had tried a Kalman Filter at one point that also seemed ok, but not good enough.

If you are interested in joining the project, let me know.

  • I have only compared speed, distance, and altitude. The info data saved in the FIT file is delayed by 1 second.in my FR165.

    1. fit file distance and activity.info.elapsedDistance

    It's mostly the same, but sometimes the distance in info.elapseddistance becomes 0, and the next time it travels twice the distance. Both tend to keep moving for a few seconds when they stop.

    2. fit file enhanced_speed and activity.info.currentSpeed

    Almost the same. both are rounded. Sometimes info.currentSpeed ​​changes more smoothly during large accelerations and decelerations. Both are a few seconds behind distance.

    3. fit file enhanced_altitude and activity.info.altitude

    enhanced_altitude is rounded to the nearest 0.2, but info.altitude is not. info.altitude may change suddenly by several meters to adjust the altitude. The data lag seems to be 2-3 seconds on both, not more than the speed lag.

    It may be possible to reduce the delay by using barometer data, but I don't have any technology that can do it better than Garmin's algorithm.

  • sometimes the distance in info.elapseddistance becomes 0

    This doesn't sound good at all. But how come we never heard about this problem? If it's happening even in 1% of the activities we should have heard from hundreds  of developers that thousands of users are complaining about it.

  • but I don't have any technology that can do it better than Garmin's algorithm.

    I agree - especially with the „new algorithm“ for grade on Edge 1050 and 1040, it became hard to do it better than Garmin. Grade is very responsive now - almost a little too much Joy

  • I am sorry, I made a mistake.

    The change in info.elapsedDistance in 1 second is 0.

  • not to mention very sensitive to the display or case being touched!  somehow their absolute barometer is disturbed by someone swiping the screen to change pages.