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

Fixed suspicious if-expression #8545

Merged
merged 1 commit into from
Mar 12, 2020

Conversation

alexeylysenko
Copy link
Contributor

In existing code there is no need to check specifiesCoordinate() and coordinate().isValid(), because they are always true. I assume the correct logic should be like that (start timer if expression is true or set _terrainAltitude to NaN otherwise).

@DonLakeFlyer
Copy link
Contributor

Obviously out of whack. But there is some subtle insanity in this area which I vaguely remember dealing with. Going to take some time for me to get into this to remember exactly what needs to happen.

@DonLakeFlyer
Copy link
Contributor

Part of the mystery is here: e476d52#diff-440910e4f5733cf3d942e2b3afa29237

Still digging...

@alexeylysenko
Copy link
Contributor Author

Part of the mystery is here: e476d52#diff-440910e4f5733cf3d942e2b3afa29237

Still digging...

Judging by that commit my changes are still correct. They keep the idea "Don't query terrain if no location".

@DonLakeFlyer
Copy link
Contributor

Judging by that commit my changes are still correct.

That is a correct statement, but only if the original logic is correct. Which I'm not sure of at this point.

@DonLakeFlyer
Copy link
Contributor

So the concern is around the case where the user changes the command for an item. This can cause specifiesCoordinate to change to false, but the coordinate will stay valid. The coordinate is not cleared in this case to keep it around in case the user switches back to a coordinate based command. And then given all of the above what happens to the terrain value. Should it be kept, or should it be cleared. The answers to those questions could affect the need for different boolean logic. In looking through that I discovered there is no signalling connected to specifiesCoordinateChanged associated with terrain values. So I needed to also determine whether that was a problem or not.

Anyway, not sure if that makes any sense to anyone who hasn't started at this stuff for months. It a complexity problem caused by the fact that the base class for all items: VIsualMissionItem is trying to do generic work with respect to terrain altitudes so that the superclasses don't need to. But the superclasses control some of the data like the command which can affect the lower level values.

It critical to get this right because if you don't it can lead to strange situations where things are waiting on terrain data when they shouldn't be. And if that happens at the field, where you may hav no internet you can get hosed. Hence my paranoia.

After poking around and staring at it for a while I've decided that:

  • It make sense to keep the old terrain altitude for an item even when the item transitions to !specifiesCoordinate
  • It's ok that there is missing signalling on specifiesCoordinateChanged since the first bullet above is true

So long story short this change is fine.

@DonLakeFlyer
Copy link
Contributor

And thanks again for the fix

@DonLakeFlyer DonLakeFlyer merged commit 6423d11 into mavlink:master Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants