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

Copter: autoyaw: correct units returned by look_ahead_yaw #26726

Merged

Conversation

peterbarker
Copy link
Contributor

there are other methods on the autoyaw object which make it clear that they're working in cd, and others in there that work in degrees. This method doesn't specify cd yet returns in that unit.

Change the method and state variable to store in degrees (as our naming standards suggest)

Tested in SITL by using "Set ROI" to swing the vehicle to a yaw, then using WP_YAW_BEHAVIOR set to 3 to swing back to "look ahead"

Copy link
Contributor

@rmackay9 rmackay9 left a comment

Choose a reason for hiding this comment

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

Thanks @peterbarker for finding this.

Could you add a comment to clarify the units of the variable (in mode.h) and return of the function? So above the look_ahead_yaw() declaration in mode.h and implementation in autoyaw.cpp.

This looks like a bug but I wonder could you ever make it misbehave in SITL? Maybe the bug appears for such a short period of time it cannot be seen?

I think we should probably label this as a bug and backport it.

Thanks again.

there are other methods on the autoyaw object which make it clear that they're working in cd, and others in there that work in degrees.  This method doesn't specify cd yet returns in that unit.

Change the method and state variable to store in degrees (as our naming standards suggest)
@peterbarker peterbarker force-pushed the pr/look-ahead-yaw-name-fix branch from 1aaa56d to 75fd655 Compare April 10, 2024 00:43
@peterbarker
Copy link
Contributor Author

Could you add a comment to clarify the units of the variable (in mode.h) and return of the function? So above the look_ahead_yaw() declaration in mode.h and implementation in autoyaw.cpp.

I considered adding such comments, but "degrees" seems to be our default return in this object (i.e. other methods in here don't comment when they return degrees, but do comment when they return cdeg. That's actually the whole reason for this PR - it didn't conform to that standard! Now I look at it, roi_yaw needs a similar fix.

I've added some comments anyway.

This looks like a bug but I wonder could you ever make it misbehave in SITL? Maybe the bug appears for such a short period of time it cannot be seen?

No, it's not a technical bug; all callers understood the return value to be cdeg-in-a-float, even 'though the method names and comments didn't indicate it was. I could have renamed it to include cd instead to solve the same problem, but since we already have methods returning degrees I thought I'd change this to be like them instead (that's the way we're supposed to be heading...).

@rmackay9 rmackay9 dismissed their stale review April 10, 2024 00:49

fixed my issues,txs

@tridge
Copy link
Contributor

tridge commented Apr 10, 2024

randy approved

@peterbarker peterbarker merged commit b849fbb into ArduPilot:master Apr 11, 2024
71 checks passed
@peterbarker peterbarker deleted the pr/look-ahead-yaw-name-fix branch April 11, 2024 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants