-
Notifications
You must be signed in to change notification settings - Fork 2
Add PID and FWBA Control #41
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
base: main
Are you sure you want to change the base?
Conversation
…fs-zeropilot-3.5b into feature/am/PID updated PID controller to use the up to date rudder mixing code
Var names, formatting, file names, etc.
Keeping pid calc files separate to allow general use of pid.
- Corrected mistake in accidentally clamping absolute position (pid_output) instead of pid_control_effort. - Added some comments.
outputToMotor(THROTTLE, motorOutputs.throttle); | ||
outputToMotor(FLAP_ANGLE, motorOutputs.flapAngle); | ||
outputToMotor(STEERING, motorOutputs.yaw); | ||
signedYaw = motorOutputs.roll-50; |
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.
seems to be only used here, maybe better as local variable?
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.
Issue with constructor (?) tryna fix.
- Fixed lint check's case style errors - Made rollPID & pitchPID into ptrs and added ptr stuff wherever they're used.
- Removed redundant vars for roll & pitch i.e. PID consts and tau. Note: tau is updated in an alg. whenever KD is. - Fixed constructor for roll and pitch PID. - Linked setters for roll & pitch to setter in pid class. - Added destructors.
motorOutputs.yaw = 0; | ||
} | ||
|
||
outputToMotor(YAW, (100-motorOutputs.yaw)*ifYawMotorsInvert+motorOutputs.yaw*(ifYawMotorsInvert-1)+yawmotorsTrim); |
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.
inverted logic is already in outputToMotor()
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.
Great work! Left some minor comments.
|
||
void MotorControl::set(uint32_t percent) { | ||
percent = percent > 100 ? 100 : percent; | ||
percent = (percent < 0) ? 0 : (percent > 100 ? 100 : percent); |
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.
It is uint32_t
so cannot be < 0
so this check is not needed.
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.
- Integral calculation in pid.cpp was missing multiplication with time. Corrected now. - Removed dynamic alloc - Changed file names to correct misspelling (lol) - Changed class names for clarity - Moved function bodies to .cpp files - Roll integral, pitch integral, and output limits changed to const static var - Added noexcept keyword to some functions that don't throw exceptions for optimization.
Added AM_pid header and source and pid_mapping header and source files. Left actual values like integral limits, output limits and PID constants as placeholder values for now.