Exemple #1
0
void imuConfigure(
    imuRuntimeConfig_t *initialImuRuntimeConfig,
    accDeadband_t *initialAccDeadband,
    float accz_lpf_cutoff,
    uint16_t throttle_correction_angle
)
{
    imuRuntimeConfig = initialImuRuntimeConfig;
    accDeadband = initialAccDeadband;
    fc_acc = calculateAccZLowPassFilterRCTimeConstant(accz_lpf_cutoff);
    throttleAngleScale = calculateThrottleAngleScale(throttle_correction_angle);
}
Exemple #2
0
void activateConfig(void)
{
    static imuRuntimeConfig_t imuRuntimeConfig;

    activateControlRateConfig();

    useRcControlsConfig(currentProfile->modeActivationConditions, &masterConfig.escAndServoConfig, &currentProfile->pidProfile);

    useGyroConfig(&masterConfig.gyroConfig);
#ifdef TELEMETRY
    useTelemetryConfig(&masterConfig.telemetryConfig);
#endif
    setPIDController(currentProfile->pidController);
#ifdef GPS
    gpsUseProfile(&currentProfile->gpsProfile);
    gpsUsePIDs(&currentProfile->pidProfile);
#endif
    useFailsafeConfig(&currentProfile->failsafeConfig);
    setAccelerationTrims(&masterConfig.accZero);
    mixerUseConfigs(
            currentProfile->servoConf,
            &masterConfig.flight3DConfig,
            &masterConfig.escAndServoConfig,
            &currentProfile->mixerConfig,
            &masterConfig.airplaneConfig,
            &masterConfig.rxConfig,
            &currentProfile->gimbalConfig
            );

    imuRuntimeConfig.gyro_cmpf_factor = masterConfig.gyro_cmpf_factor;
    imuRuntimeConfig.gyro_cmpfm_factor = masterConfig.gyro_cmpfm_factor;
    imuRuntimeConfig.acc_lpf_factor = currentProfile->acc_lpf_factor;
    imuRuntimeConfig.acc_unarmedcal = currentProfile->acc_unarmedcal;;
    imuRuntimeConfig.small_angle = masterConfig.small_angle;

    configureImu(&imuRuntimeConfig, &currentProfile->pidProfile, &currentProfile->accDeadband);
    configureAltitudeHold(&currentProfile->pidProfile, &currentProfile->barometerConfig, &currentProfile->rcControlsConfig, &masterConfig.escAndServoConfig);

    calculateThrottleAngleScale(currentProfile->throttle_correction_angle);
    calculateAccZLowPassFilterRCTimeConstant(currentProfile->accz_lpf_cutoff);

#ifdef BARO
    useBarometerConfig(&currentProfile->barometerConfig);
#endif
}