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

AP_Baro: Do not cache EAS2TAS conversions #26783

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

WickedShell
Copy link
Contributor

Caching this introduces discontinuities in TECS, as the step change modifies the target speed demand.

The graph of speed demand steps are from EAS2TAS recalculating every 25 meters in the climb, these changes then ripple into the throttle feed forward for throttle as a throttle spike, that makes it all the way out to the motor.

2024-04-11T18:21:15,050500232-07:00

My understanding of the reason for this cache is this was very expensive for us back in the APM2 days, but the world has moved on since then and has a lot more processing power available then we used to. We could try to limit this to faster boards, but I think we can probably afford this on all our currently supported boards. (Side benefit, saves memory :) )

Will be test flying this on a backport to 4.4 tomorrow.

Comment on lines 447 to 448
const float _EAS2TAS = sqrtf(eas2tas_squared);
return _EAS2TAS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const float _EAS2TAS = sqrtf(eas2tas_squared);
return _EAS2TAS;
return sqrtf(eas2tas_squared);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha! Yeah, I definitely should have just done that. Fixed.

@peterbarker
Copy link
Contributor

That change in spdem demand seems to be having an out-sized impact on that throttle demand.

Caching this introduces discontinuities in TECS, as the step change
modifies the target speed demand.
@WickedShell WickedShell force-pushed the wickedshell/recalculate-tecs branch from 4ef362a to 207665e Compare April 12, 2024 16:20
@WickedShell
Copy link
Contributor Author

That change in spdem demand seems to be having an out-sized impact on that throttle demand.

I think it's because it's a step change, that we take the derivative of, so the rate of change is suddenly high. After that it just ripples straight into the throttle feed forward. It's definitely more then I expected it to be.

@WickedShell
Copy link
Contributor Author

Flew it, looks fine, I can't find the regular large throttle spikes anymore, and is smoother.

@IamPete1
Copy link
Member

How about moving the calculation to the update call? This would mean that we only do the calculation once per loop rather than on each call. It would also give the possibility of getting the value from a secondary sensor. Currently EKF baro affinity always uses the EAS2TAS from the primary baro even if the rest of the core is using the second sensor.

@tridge
Copy link
Contributor

tridge commented Apr 22, 2024

@WickedShell we should also fix the few places that are not using the ahrs.get_EAS2TAS() function which is memoised

@tridge tridge merged commit ff7a215 into ArduPilot:master Apr 22, 2024
91 checks passed
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.

5 participants