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

HAL_ChibiOS: fixed cork/push #29521

Merged
merged 1 commit into from
Mar 17, 2025
Merged

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Mar 13, 2025

ensure that period[] array is not updated until we push
this fixes the stuttering motors on tilt quadplanes, and may fix other issues
this is an alternative to #29518

ensure that period[] array is not updated until we push
if (corked) {
// when corked we put the updated period in a separate array which is
// copied to period[] when we push
period_corked[chan] = period_us;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean shouldn't this always be the case? Couldn't you just assert on the non-corked case?

Copy link
Contributor Author

@tridge tridge Mar 13, 2025

Choose a reason for hiding this comment

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

there could be special cases where we write non-corked, for something going into 4.6.0 I wouldn't want to rule out non-corked output on some weird vehicle setup
one example would be ReplayGyroFFT
another in toy_mode test code
for 4.7.0 I'd be happy to enforce corked only, starting with SITL

@tpwrules
Copy link
Contributor

tpwrules commented Mar 15, 2025

So the problem is that the period[] array was read by the dshot_send function and values were sent out before the push? Does the memcpy create any tearing problems?

Should read see the pre-push or post-push value? It wasn't involved in the issue was it?

@andyp1per
Copy link
Collaborator

So the problem is that the period[] array was read by the dshot_send function and values were sent out before the push? Does the memcpy create any tearing problems?

Should read see the pre-push or post-push value? It wasn't involved in the issue was it?

Once corked, no updates should be seen until push has been called. so read should see the post-pushed or pre-corked values

@IamPete1
Copy link
Member

We could also remove the output here:

channels[i].output_ch();

So the value is not written to the hal.

@andyp1per
Copy link
Collaborator

This incurs about a 0.1% CPU cost @2k and 0.2% @4k

@andyp1per
Copy link
Collaborator

Briefly tested on my fast rate quad without issue

@tridge tridge merged commit 3ec0f93 into ArduPilot:master Mar 17, 2025
46 of 47 checks passed
Copy link
Member

@IamPete1 IamPete1 left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

6 participants