01-17-2018 12:09 - edited 01-17-2018 12:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
01-17-2018 12:09 - edited 01-17-2018 12:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I am attempting to ascertain the total ascent and descent during an activity.
Can anyone see anything wrong with the logic below please:
if (this.altitude>this.lastAltitude) { this.totalAscent+=(this.altitude-this.lastAltitude); } else { this.totalDescent+=(this.lastAltitude-this.altitude); } this.lastAltitude=this.altitude;
The reason I ask is that I appear to be a factor of 10 out from what I expect (getting 490m instead of 49m). The above code is run on each geolocation watch update. I am comparing to my Suunto Ambit results so know roughly what to expect.

01-17-2018 13:54 - edited 01-17-2018 14:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-17-2018 13:54 - edited 01-17-2018 14:23
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Must be an issue of GPS accuracy. It typically ranges from 6 to 20 meters. GPS position randomly jumps in a circle of such a size every second. I doubt your vertical speed is comparable to 1 meter per second, therefore it's hard to get the reliable data from GPS in your case. Therefore, taking the difference every second as you do must act more like the random number generator.
That's unless vertical accuracy is much greater than horizontal. You can check that looking at the coords.altitudeAccuracy field, and/or looking at the raw sequence of the altitude measurements (don't forget to step out of the building).
I think your Ambit watches use the barometer to estimate elevation (and Ionic uses the barometer to count floors), so should probably do you.
https://dev.fitbit.com/build/guides/sensors/barometer/

01-17-2018 15:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


01-17-2018 15:40
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
The barometer can't tell you the current altitude, but you can use it to detect the changes in air pressure, and use that to calculate the change in altitude.

01-17-2018 23:27 - edited 01-17-2018 23:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
01-17-2018 23:27 - edited 01-17-2018 23:29
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Thank you @JonFitbit, @gaperton
Logic is sound. Wrong sensor. Funny thing is GPS altitude itself looks correct. Go figure.
I will code and test the barometer. I will also add in a reference to the gps altitude accuracy.
Calculating the distance from gps is about spot on. 🙂

01-18-2018 16:30 - edited 01-18-2018 22:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

01-18-2018 16:30 - edited 01-18-2018 22:59
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
> Calculating the distance from gps is about spot on. 🙂
You can expect the same problems with distance as well if you will take the difference between samples taken every second. One of the simplest possible solutions would be to increase the interval, i.e. update the distance every 3 or 5 seconds instead of one. It should give you more reliable results.
One of the ideas for a more sophisticated approach is to track significant changes of the GPS heading to detect the turns and align the smoothed route points to them. When you know that you're going straight, you can use the lesser amount of GPS location points to measure the distance on the line so it will be more accurate.

01-19-2018 01:41 - edited 01-19-2018 01:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
01-19-2018 01:41 - edited 01-19-2018 01:46
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I know I keep relating back to the Suunto Ambit, but I also have a Wahoo Bolt (which replaced a Mio 305) for my biking.
All record GPS every second, as does the Ionic built in exercise app. I would expect the Ionic to be no less accurate than any of the other devices.
Once I am able to get the GPX data out of the unit myself, and compare to my other trusted sources, I will then look at "tuning" the logging rate and how distance is calculated. I very much appreciate your input, and will more fully engage in your response above when the time comes.
Back onto the ascent calculation. This is quite strange. I have tied into the barometer readings, and am getting very strange readings indeed. I am going to shelve the ascent for now until I have moved the app more on from where it is now, and then come back to it.
The funny thing is, the gps altitude appears to be returning quite an accurate reading! I need to get the data logged and out of the Ionic to perform more analysis to see what is going on.

