Skip to content

Conversation

EemanAleem
Copy link

@EemanAleem EemanAleem commented Jul 10, 2025

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.

@EemanAleem EemanAleem requested a review from avancruy July 10, 2025 22:05
@avancruy avancruy changed the title Feature/am/pid Add PID and FWBA Control Jul 10, 2025
outputToMotor(THROTTLE, motorOutputs.throttle);
outputToMotor(FLAP_ANGLE, motorOutputs.flapAngle);
outputToMotor(STEERING, motorOutputs.yaw);
signedYaw = motorOutputs.roll-50;
Copy link
Contributor

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?

Copy link
Author

@EemanAleem EemanAleem Jul 10, 2025

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);
Copy link
Contributor

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()

Copy link
Contributor

@SuperMK15 SuperMK15 left a 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);
Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

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

EemanAleem and others added 3 commits September 20, 2025 00:58
- 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.
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.

6 participants