-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Better handling of motor power distribution #1147
Conversation
Moved all thrust manipulation to the stabilizer loop for better overview. Added a platform specific cap function to allow a platform to cap thrust in more meaningful way.
@matejkarasek I have updated the power distribution a bit and thus modified the flapper power distribution file. It all looks good (in my opinion) but I have note tested on a real Flapper. The intention is that the functionality should be identical to before, would it be possible for you to take a look?
|
Thanks for the heads up, will try to test it and report back soon. The new capping method, which prioritizes the attitude, could also be interesting for the Flapper :) |
Agree, I think it can be interesting for the Flapper as well. I did not want to change anything without checking with you first :-) |
motorPwm->motors.m2 = limitThrust(motorThrustBatCompUncapped->motors.m2, 0, UINT16_MAX); // pitch servo | ||
motorPwm->motors.m3 = limitThrust(motorThrustBatCompUncapped->motors.m3, 0, UINT16_MAX); // yaw servo | ||
motorPwm->motors.m1 = limitThrust(motorThrustBatCompUncapped->motors.m1, idleThrust, UINT16_MAX); // left motor | ||
motorPwm->motors.m4 = limitThrust(motorThrustBatCompUncapped->motors.m4, idleThrust, UINT16_MAX); // left motor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy&paste error in the comment, should be :
// right motor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks!
So I tested this on the flapper platform and all seems fine, thanks! |
Great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and something we should have done a long time ago.
This PR updates the power distribution.
Previously the motor power has been capped per motor if the desired thrust exceeds the maximum possible thrust. In this PR the capping has been updated to maintain the relative power of the motors and the trust of all motors are reduced equally much. The intention is to prioritize attitude over altitude to reduce the risk of flipping.
The power distribution code has also been refactored to make it easier to understand and test.