Skip to content

Commit 90fb0b7

Browse files
authored
Merge pull request #1543 from FinlaySanders/master
Implements powerDistributionForce for force control mode
2 parents d6f1532 + 01c5553 commit 90fb0b7

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/modules/src/power_distribution_quadrotor.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,27 @@ static void powerDistributionForceTorque(const control_t *control, motors_thrust
116116
}
117117
}
118118

119+
/**
120+
* @brief Allows for direct control of motor power with clipping
121+
*
122+
* This function applies clipping to the motor values, which is different to
123+
* the "capping" behaviour found in powerDistributionForceTorque() - which
124+
* instead prioritizes stability rather than thrust.
125+
*/
119126
static void powerDistributionForce(const control_t *control, motors_thrust_uncapped_t* motorThrustUncapped) {
120-
// Not implemented yet
127+
for (int i = 0; i < STABILIZER_NR_OF_MOTORS; i++) {
128+
float f = control->normalizedForces[i];
129+
130+
if (f < 0.0f) {
131+
f = 0.0f;
132+
}
133+
134+
if (f > 1.0f) {
135+
f = 1.0f;
136+
}
137+
138+
motorThrustUncapped->list[i] = f * UINT16_MAX;
139+
}
121140
}
122141

123142
void powerDistribution(const control_t *control, motors_thrust_uncapped_t* motorThrustUncapped)
@@ -195,4 +214,4 @@ PARAM_GROUP_START(powerDist)
195214
* common value is between 3000 - 6000.
196215
*/
197216
PARAM_ADD_CORE(PARAM_UINT32 | PARAM_PERSISTENT, idleThrust, &idleThrust)
198-
PARAM_GROUP_STOP(powerDist)
217+
PARAM_GROUP_STOP(powerDist)

0 commit comments

Comments
 (0)