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

wrong arrival altitude in Map Labels #1424

Closed
bomilkar opened this issue May 9, 2024 · 10 comments · Fixed by #1432
Closed

wrong arrival altitude in Map Labels #1424

bomilkar opened this issue May 9, 2024 · 10 comments · Fixed by #1432
Labels
Milestone

Comments

@bomilkar
Copy link
Contributor

bomilkar commented May 9, 2024

XCSoar versions having the problem

The issue was introduced in 7.34

XCSoar versions not having the problem

Up to 7.33 it worked OK.

System information

Not platform dependent.

Steps to reproduce the behavior

Start XCSoar in Sim mode.
Increase the altitude by clicking on an altitude InfoBox until you see a Waypoint in reach.
Then change Wind manually and observe how the content of "WP AltD" InfoBox changes compared to the altitude shown on the Map Label.

Expected behavior

Up to 7.33 "WP AltD" InfoBox and Map Labels are in sync.
7 33 headWind

Actual behavior

7 34 headWind

Do you have any idea what may have caused this?

It seems as if since 7.33 there is a sign error in calculating the arrival altitude in the map label.

  InfoBox Map Label
head Wind 422 469
no Wind 448 447
tail Wind 470 421

Do you have an idea how to solve the issue?

@lordfolken
Copy link
Contributor

Polar, saftey mc, and stf factor are the same?
We need a unit test for this.

@lordfolken lordfolken added the bug label May 9, 2024
@lordfolken
Copy link
Contributor

Probably all the same by judging the wp altd.

@bomilkar
Copy link
Contributor Author

bomilkar commented May 9, 2024

Polar, saftey mc, and stf factor are the same.
This becomes obvious at 0 wind: wp altd and altitude in label are the same.

@bomilkar
Copy link
Contributor Author

bomilkar commented May 9, 2024

We need a unit test for this.

What does that mean?

@bomilkar
Copy link
Contributor Author

The fix might be trivial, but I simply can't find the part in the code, which calculates the arrival altitude in the map labels.
So unless somebody helps me find it, I won't be able to fix it.

@lordfolken
Copy link
Contributor

So the labels show you the altitude you have above glide ratio at mc 0.
The infobox will factor in saftey mc (from settings) and current mc. If you set this to 0 then its the same.

But as soon as you add the wind component, it increases where its supposed to decrease.

The reachability is calculated here:

(

void CalculateReachability(const ProtectedRoutePlanner &route_planner,
)

@bomilkar
Copy link
Contributor Author

I don't want to give up hunting the bug, but I don't want to predict by when I'll be done. The code is too convoluted for my limited tool set and my abilities. Sorry!
So, I'd like to ask someone else to step in. @lordfolken maybe you??
The bug is too severe (in my opinion) to leave it there for much longer. (However, I'm surprised nobody noticed it much sooner!)

@lordfolken
Copy link
Contributor

lordfolken commented May 15, 2024

Dont worry, im angry at this bug.
"Tactical glide computer" my ass. We cant even get the basics right.
And I also invested last Sunday into this issue. The ammount of abstraction layers in xcsoar are staggering.

@lordfolken lordfolken added this to the v7.43 milestone May 15, 2024
@ryanetz
Copy link

ryanetz commented May 17, 2024

Just want to thank you guys for taking this issue seriously. I don’t have the right technical skills to fix this, but my hunch is that somewhere in the label arrival altitude calculation a + got replace with a - in the wind factor calculation.
Looking forward for the fix. Meanwhile I ignore the green labels with wind more than 5 knots…

Ramy (who initially reported this issue)

@lordfolken
Copy link
Contributor

lordfolken commented May 17, 2024

So the commit that introduces the bug is: e020359
There the GetSpeedUps is refactored, and tries to reuse the GetDelta() function.
Unfortunatly the arguments for the FlatGeoPoints are reversed in GetDelta, than to what was before.

constexpr FlatGeoPoint GetDelta() const noexcept {
return FlatGeoPoint(second) - FlatGeoPoint(first);

While one could flip those first/second arguments... GetDelta is much older, and was introduced in 2015: ca1ab2c
GetDelta() is used in CrossProduct() and DotProduct() which are functions used all over the place.

So I think its best to revert e020359 and not change GetDelta().

lordfolken added a commit to lordfolken/XCSoar that referenced this issue May 17, 2024
This reverts commit e020359.
The GetDelta() function calculates delta between second - first
arguments. The old implementation for CalcSpeedups calculated
the difference however with first - second argument.

This led to bug report XCSoar#1424 that noticed that the reachable labels
on the map increased altitude with increasing headwind, instead of
the opposite.

Fixes XCSoar#1424
@lordfolken lordfolken linked a pull request May 17, 2024 that will close this issue
@lordfolken lordfolken added the pr-provided Provided a pr label May 17, 2024
lordfolken added a commit that referenced this issue May 19, 2024
This reverts commit e020359.
The GetDelta() function calculates delta between second - first
arguments. The old implementation for CalcSpeedups calculated
the difference however with first - second argument.

This led to bug report #1424 that noticed that the reachable labels
on the map increased altitude with increasing headwind, instead of
the opposite.

Fixes #1424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants