Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(telemetry): Inconsistent/wrong GPS distance calculation #4442

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

mha1
Copy link
Contributor

@mha1 mha1 commented Dec 20, 2023

fixes #4437

PR #4250 introduced a mechanism to allow a value widget to detect a change in GPS position. This was realized by storing a hash value in the value variable of class TelemetryItem. Unfortunately value is defined in a union together with a placeholder for distFromEarthAxis.

class TelemetryItem
{
  public:
    union {
      int32_t  value;           // value, stored as uint32_t but interpreted accordingly to type
      uint32_t distFromEarthAxis;
    };
...

By writing the hash for the changed lat/lon to value the calculated distFromEarthAxis is overwritten. In case a calculated telemetry sensor "distance" is defined this leads to a wrong calculation of the distance between craft and home point.

Changes:

  • separated and moved storage of distFromEarthAxis to class TelemetryItem's gps struct to prevent overwriting distFromEarthAxis. This should not affect RAM usage due to the way the gps struct is embedded in a union for other types of data (cells struct is still larger).
  • changed distFromEarthAxis to pilotDistFromEarthAxis to align variable name with pilotLatitude and pilotLongitude

Tested using the procedure described in #4437

Sharing the calculated earth radius of the pilot's GPS position (home point) with value in a union leads to overwriting the earth radius upon craft's position because value is newly used to store a hash to allow value widget to recognize change in crafts's lat/lon.

changes:
- moved storage of home point earth radius to gps struct to prevent overwriting the home point earth radius. This should not affect RAM usage.
@mha1
Copy link
Contributor Author

mha1 commented Dec 20, 2023

tested on 2.9.2 and current main:

  • value widget updating GPS position ok
  • calculation of GPS distance ok

@pfeerick pfeerick changed the title Fixes error leading to wrong GPS distance calculation fix(telemetry): Inconsistent/wrong GPS distance calculation Dec 21, 2023
@pfeerick pfeerick added telemetry 📶 bug/regression ↩️ A new version of EdgeTX broke something labels Dec 21, 2023
@pfeerick pfeerick added this to the 2.10 milestone Dec 21, 2023
@pfeerick
Copy link
Member

Will this cherrypick into 2.9 without any conflicts? If so, you can have it for 2.9.3 ;)

@mha1
Copy link
Contributor Author

mha1 commented Dec 21, 2023

Will this cherrypick into 2.9 without any conflicts? If so, you can have it for 2.9.3 ;)

yes sir

@pfeerick pfeerick modified the milestones: 2.10, 2.9.3 Dec 21, 2023
@pfeerick pfeerick merged commit 587a143 into EdgeTX:main Dec 21, 2023
39 checks passed
@pfeerick pfeerick deleted the PR_fix_GPS_distance branch December 21, 2023 09:16
pagrey pushed a commit to pagrey/edgetx that referenced this pull request Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/regression ↩️ A new version of EdgeTX broke something telemetry 📶
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2.9.2: Calculated telemetry sensor "distance" not working
2 participants