Skip to content

Commit

Permalink
Block idlethtrust and unarmed feature at run time.
Browse files Browse the repository at this point in the history
We need to override the idleThrust param stored in eeprom with 0 if arming is not on
The (brushless) motors needs to be fed a 0 signal after they started up and we do not know exactly when that is.
These two features are mutually eclusive and can not be used together
  • Loading branch information
ToveRumar committed Jun 11, 2024
1 parent 7dbccfd commit aa03faa
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/modules/src/power_distribution_quadrotor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
* power_distribution_quadrotor.c - Crazyflie stock power distribution code
*/


#include "power_distribution.h"

#include <string.h>
#include "debug.h"
#include "log.h"
#include "param.h"
#include "num.h"
Expand Down Expand Up @@ -66,6 +68,11 @@ uint16_t powerDistributionStopRatio(uint32_t id)

void powerDistributionInit(void)
{
#if (!defined(CONFIG_MOTORS_REQUIRE_ARMING) || (CONFIG_MOTORS_REQUIRE_ARMING == 0))
if(idleThrust > 0) {
DEBUG_PRINT("WARNING: idle thrust will be overridden with value 0. Autoarming can not be on while idle thrust is higher than 0. If you want to use idle thust please use use arming\n");
}
#endif
}

bool powerDistributionTest(void)
Expand Down Expand Up @@ -166,14 +173,19 @@ bool powerDistributionCap(const motors_thrust_uncapped_t* motorThrustBatCompUnca
for (int motorIndex = 0; motorIndex < STABILIZER_NR_OF_MOTORS; motorIndex++)
{
int32_t thrustCappedUpper = motorThrustBatCompUncapped->list[motorIndex] - reduction;
motorPwm->list[motorIndex] = capMinThrust(thrustCappedUpper, idleThrust);
motorPwm->list[motorIndex] = capMinThrust(thrustCappedUpper, powerDistributionGetIdleThrust());
}

return isCapped;
}

uint32_t powerDistributionGetIdleThrust() {
return idleThrust;
uint32_t powerDistributionGetIdleThrust()
{
int32_t thrust = idleThrust;
#if (!defined(CONFIG_MOTORS_REQUIRE_ARMING) || (CONFIG_MOTORS_REQUIRE_ARMING == 0))
thrust = 0;
#endif
return thrust;
}

float powerDistributionGetMaxThrust() {
Expand Down

0 comments on commit aa03faa

Please sign in to comment.