Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b924207
added all rudder mixing stuff into newest branch + fixed some old issues
JJKSweaty Jan 19, 2026
3b99848
Update zeropilot4.0/src/attitude_manager/attitude_manager.cpp
JJKSweaty Jan 20, 2026
d61cd7c
added mixing logic
JJKSweaty Jan 20, 2026
091165e
Merge branch 'feauture/am/rudder-mixing-fix' of https://github.com/UW…
JJKSweaty Jan 20, 2026
27ffb7d
Update zeropilot4.0/include/driver_ifaces/motor_datatype.hpp
SuperMK15 Jan 23, 2026
8bcf6b8
Update zeropilot4.0/src/attitude_manager/attitude_manager.cpp
SuperMK15 Jan 23, 2026
b6a750c
update trim value default and documentation
SuperMK15 Jan 23, 2026
d5655c8
update setRudderMixingCoeff
SuperMK15 Jan 23, 2026
ddab2b5
fix inversion logic
SuperMK15 Jan 23, 2026
cda232e
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Jan 23, 2026
9672957
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 8, 2026
4c7077e
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 8, 2026
9265454
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 9, 2026
d884172
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 11, 2026
0e0bd96
move rudder mixing logic from AM to FBWA
SuperMK15 Feb 11, 2026
b571d71
fix rudder mixing logic
SuperMK15 Feb 11, 2026
5371d82
whitespace
SuperMK15 Feb 11, 2026
201b433
more whitespace
SuperMK15 Feb 11, 2026
3daf694
remove silent failure
SuperMK15 Feb 11, 2026
a6858ce
naming
SuperMK15 Feb 11, 2026
fb1f557
cleanup
SuperMK15 Feb 11, 2026
f0c07bc
commenting
SuperMK15 Feb 11, 2026
9a7eb37
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 11, 2026
42bb6ad
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 11, 2026
e0f9b5f
Merge branch 'main' into feauture/am/rudder-mixing-fix
SuperMK15 Feb 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions stm32h753iitx/boardfiles/model/src/drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ void initDrivers()
rfdHandle->startReceive();

// Motor instance bindings
leftAileronMotorInstance = {leftAileronMotorHandle, true};
rightAileronMotorInstance = {rightAileronMotorHandle, true};
elevatorMotorInstance = {elevatorMotorHandle, false};
rudderMotorInstance = {rudderMotorHandle, false};
throttleMotorInstance = {throttleMotorHandle, false};
leftFlapMotorInstance = {leftFlapMotorHandle, false};
rightFlapMotorInstance = {rightFlapMotorHandle, true};
steeringMotorInstance = {steeringMotorHandle, true};
leftAileronMotorInstance = {leftAileronMotorHandle, true, 0};
rightAileronMotorInstance = {rightAileronMotorHandle, true, 0};
elevatorMotorInstance = {elevatorMotorHandle, false, 0};
rudderMotorInstance = {rudderMotorHandle, false, 0};
throttleMotorInstance = {throttleMotorHandle, false, 0};
leftFlapMotorInstance = {leftFlapMotorHandle, false, 0};
rightFlapMotorInstance = {rightFlapMotorHandle, true, 0};
steeringMotorInstance = {steeringMotorHandle, true, 0};

aileronMotorInstances[0] = leftAileronMotorInstance;
aileronMotorInstances[1] = rightAileronMotorInstance;
Expand Down
16 changes: 8 additions & 8 deletions stm32l552xx/boardfiles/model/src/drivers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ void initDrivers()
rfdHandle->startReceive();

// Motor instance bindings
leftAileronMotorInstance = {leftAileronMotorHandle, true};
rightAileronMotorInstance = {rightAileronMotorHandle, true};
elevatorMotorInstance = {elevatorMotorHandle, false};
rudderMotorInstance = {rudderMotorHandle, false};
throttleMotorInstance = {throttleMotorHandle, false};
leftFlapMotorInstance = {leftFlapMotorHandle, false};
rightFlapMotorInstance = {rightFlapMotorHandle, true};
steeringMotorInstance = {steeringMotorHandle, true};
leftAileronMotorInstance = {leftAileronMotorHandle, true, 0};
rightAileronMotorInstance = {rightAileronMotorHandle, true, 0};
elevatorMotorInstance = {elevatorMotorHandle, false, 0};
rudderMotorInstance = {rudderMotorHandle, false, 0};
throttleMotorInstance = {throttleMotorHandle, false, 0};
leftFlapMotorInstance = {leftFlapMotorHandle, false, 0};
rightFlapMotorInstance = {rightFlapMotorHandle, true, 0};
steeringMotorInstance = {steeringMotorHandle, true, 0};

aileronMotorInstances[0] = leftAileronMotorInstance;
aileronMotorInstances[1] = rightAileronMotorInstance;
Expand Down
6 changes: 6 additions & 0 deletions zeropilot4.0/include/attitude_manager/fbwa_mapping.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class FBWAMapping : public Flightmode {
// Setter for *pitch* PID consts
void setPitchPIDConstants(float newKp, float newKi, float newKd, float newTau) noexcept;

// Setter for *yaw* rudder mixing const
void setYawRudderMixingConstant(float newMixingConst) noexcept;

// Destructor
~FBWAMapping() noexcept override;

Expand All @@ -23,6 +26,9 @@ class FBWAMapping : public Flightmode {
PID rollPID;
PID pitchPID;

// Yaw rudder mixing constant
float yawRudderMixingConst;

// Roll integral limits
static constexpr float ROLL_INTEGRAL_MIN_LIM = -50.0f;
static constexpr float ROLL_INTEGRAL_MAX_LIM = +50.0f;
Expand Down
1 change: 1 addition & 0 deletions zeropilot4.0/include/driver_ifaces/motor_datatype.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
typedef struct {
IMotorControl *motorInstance;
bool isInverted;
int trim; // trim value to adjust motor output, can be positive or negative in range [-50,50]
} MotorInstance_t;

typedef struct {
Expand Down
17 changes: 13 additions & 4 deletions zeropilot4.0/src/attitude_manager/attitude_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,21 @@ void AttitudeManager::outputToMotor(ControlAxis_t axis, uint8_t percent) {
for (uint8_t i = 0; i < motorGroup->motorCount; i++) {
MotorInstance_t *motor = (motorGroup->motors + i);

if (motor->isInverted) {
motor->motorInstance->set(100 - percent);
int32_t cmd = (int32_t)percent + motor->trim;

// Clamp cmd to [0, 100]
if (cmd > 100) {
cmd = 100;
} else if (cmd < 0) {
cmd = 0;
}
else {
motor->motorInstance->set(percent);

// Invert command if motor is inverted
if (motor->isInverted) {
cmd = 100 - cmd;
}

motor->motorInstance->set(cmd);
}
}

Expand Down
18 changes: 17 additions & 1 deletion zeropilot4.0/src/attitude_manager/fbwa_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ FBWAMapping::FBWAMapping(float control_iter_period_s) noexcept :
ROLL_INTEGRAL_MIN_LIM, ROLL_INTEGRAL_MAX_LIM, control_iter_period_s),
pitchPID(0.0f, 0.0f, 0.0f,
0.0f, OUTPUT_MIN, OUTPUT_MAX,
PITCH_INTEGRAL_MIN_LIM, PITCH_INTEGRAL_MAX_LIM, control_iter_period_s)
PITCH_INTEGRAL_MIN_LIM, PITCH_INTEGRAL_MAX_LIM, control_iter_period_s),
yawRudderMixingConst(0.0f)
{
rollPID.pidInitState();
pitchPID.pidInitState();
Expand All @@ -26,6 +27,12 @@ void FBWAMapping::setPitchPIDConstants(float newKp, float newKi, float newKd, fl
pitchPID.setConstants(newKp, newKi, newKd, newTau);
}

// Setter for *yaw* rudder mixing const
void FBWAMapping::setYawRudderMixingConstant(float newMixingConst) noexcept {
yawRudderMixingConst = newMixingConst;
}

// Main control mapping function for FBWA mode
RCMotorControlMessage_t FBWAMapping::runControl(RCMotorControlMessage_t controlInputs, const DroneState_t &droneState){
// Convert RC inputs into radians
float rollSetpoint = (controlInputs.roll / MAX_RC_INPUT_VAL) * (ROLL_MAX_ANGLE_RAD - ROLL_MIN_ANGLE_RAD) + ROLL_MIN_ANGLE_RAD;
Expand All @@ -42,5 +49,14 @@ RCMotorControlMessage_t FBWAMapping::runControl(RCMotorControlMessage_t controlI
controlInputs.roll = rollOutput + FBWA_PID_OUTPUT_SHIFT; // setting desired roll angle, adding 50 to shift to [0,100] range
controlInputs.pitch = pitchOutput + FBWA_PID_OUTPUT_SHIFT; // setting desired pitch angle, adding 50 to shift to [0,100] range

// Yaw control via rudder mixing
float aileronSignalCentered = controlInputs.roll - (MAX_RC_INPUT_VAL / 2.0f); // Centering aileron signal around 0 for mixing calculation
controlInputs.yaw += (yawRudderMixingConst * aileronSignalCentered); // Yaw adjustment based on roll PID output and mixing constant
if (controlInputs.yaw < 0.0f) {
controlInputs.yaw = 0.0f; // Ensuring yaw does not go below 0
} else if (controlInputs.yaw > MAX_RC_INPUT_VAL) {
controlInputs.yaw = MAX_RC_INPUT_VAL; // Ensuring yaw does not exceed max RC input value
}

return controlInputs;
}