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

Add back motor slew rate #23835

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add back motor slew rate #23835

wants to merge 2 commits into from

Conversation

MaEtUgR
Copy link
Member

@MaEtUgR MaEtUgR commented Oct 21, 2024

Solved Problem

Like @Igor-Misic and me almost simultaneously found out the motor slew rate does not take effect anymore in the dynamic control allocation which is what the mixer now uses for some time:
#23794
#23798

I would have been fine with that since I don't think there should be a slew rate on the motor outputs but the ESCs should deal with the feasibility of commands. But in practise they apparently do not always do that and since there are users of this feature I don't want to leave it away.

Solution

  1. I added back a motor slew rate in the motor function (it used to be in the simple and multicopter mixer of the old static mixing) and recovered the MOT_SLEW_MAX parameter with its original meaning but a new PWM independent description for backward compatibility. The slew rate reinitializes when there are NAN values in the motor command so they could in theory still jump from NAN to a different value since the motor function does not know what NAN (output protol-specific disarmed value) maps to.
  2. I optimized it a bit since depending on the setup if the slew rate is enabled things get called at multiple kilohertz and that has some visible impact on the flight control CPU load e.g. in my test it was ~0.4% difference and not easily visible anymore after the second commit.

Changelog Entry

Feature: Bring back motor slew rate

Alternatives

I would suggest not to use this feature if not urgently necessary but rather make sure:
a) the ESC keeps up stable operation no matter what
b) the sensor noise is filtered adequately to not propagate problems
c) the setpoints are smooth such that there are no crazy jumps in normal operation

Test coverage

SITL SIH test checking that the timing e.g. 10 seconds from -1 to 1 is correct and the initialization in case of NAN values works.
Real vehicle test to see that on PWM as well as CAN output the same slew rate is percievably in action.

For users who miss it since the dynamic control allocation was introduced.
Copy link
Member

@Igor-Misic Igor-Misic left a comment

Choose a reason for hiding this comment

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

@MaEtUgR you forgote to stage
(ParamFloat<px4::params::MOT_SLEW_MAX>) _param_mot_slew_max,
in mixer_module.hpp

I've tested it with DShot and works as expected. Thanks!
Code LGTM.

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