Skip to content

Start using altitude getter - towards private alt in Location #28481

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

Closed
wants to merge 13 commits into from

Conversation

Ryanf55
Copy link
Contributor

@Ryanf55 Ryanf55 commented Oct 28, 2024

Purpose

We want to move towards having the altitude in AP_Location private and force using frames when getting/setting it to make it easier to spot frame bugs. This PR gets us 1/3 of the way to making the altitude field private. Once that's private, we can start to use grep to migrate off get_alt_cm() where we are worried about using the wrong frame.

Also, this could get us closer towards geoid-datum aware altitudes in AP.

Context

#28406 (comment)

Issue

Relates to #28435

Testing

None, hopefully this is narrowly scoped we can merge via inspection and manual testing in any areas of higher concern.

* This is used when the get_alt_cm(frame, alt) fails

Signed-off-by: Ryan Friedman <[email protected]>
Signed-off-by: Ryan Friedman <[email protected]>
@Ryanf55 Ryanf55 force-pushed the private-alt-in-location branch from 3cc6fa3 to 1e30872 Compare October 28, 2024 05:25
Comment on lines +46 to +49
// retrieve the altitude (in cm) in the stored frame.
int32_t get_alt_cm() const WARN_IF_UNUSED {
return alt;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I don't think this is acceptable.

The API requires you to specify a frame for a reason, and adding this is a significant step backwards.

Copy link
Contributor Author

@Ryanf55 Ryanf55 Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently You can just call myLocation.alt = 42.0 and now you just set the value (without a frame) without any ability for us to find and stop it.

This PR gives us ability to make .alt private, add a deprecation to this getter on a branch, and use the compiler to tell us all the places we need to phase it out of the codebase.
Eventually, this function gets removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did discuss the approach with Pete Hall before starting, he thought this approach was valuable because we can grep the code. I'm totally open to alternatives, and am only 1/3 of the way through at the current state.

@Ryanf55 Ryanf55 closed this Nov 12, 2024
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