1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 23:05:19 +03:00

Add rcYawRate into Blackbox header and Calculate Rate Function

Add the new Yaw Rate parameter into the log header
This commit is contained in:
Gary Keeble 2016-06-03 15:18:54 +01:00 committed by borisbstyle
parent a74acccb84
commit 8f993a87a4
2 changed files with 41 additions and 38 deletions

View file

@ -1181,156 +1181,159 @@ static bool blackboxWriteSysinfo()
blackboxPrintfHeaderLine("rcExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcExpo8); blackboxPrintfHeaderLine("rcExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcExpo8);
break; break;
case 14: case 14:
blackboxPrintfHeaderLine("rcYawExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcYawExpo8); blackboxPrintfHeaderLine("rcYawRate:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcYawRate8);
break; break;
case 15: case 15:
blackboxPrintfHeaderLine("thrMid:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].thrMid8); blackboxPrintfHeaderLine("rcYawExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rcYawExpo8);
break; break;
case 16: case 16:
blackboxPrintfHeaderLine("thrExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].thrExpo8); blackboxPrintfHeaderLine("thrMid:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].thrMid8);
break; break;
case 17: case 17:
blackboxPrintfHeaderLine("dynThrPID:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].dynThrPID); blackboxPrintfHeaderLine("thrExpo:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].thrExpo8);
break; break;
case 18: case 18:
blackboxPrintfHeaderLine("tpa_breakpoint:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].tpa_breakpoint); blackboxPrintfHeaderLine("dynThrPID:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].dynThrPID);
break; break;
case 19: case 19:
blackboxPrintfHeaderLine("tpa_breakpoint:%d", masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].tpa_breakpoint);
break;
case 20:
blackboxPrintfHeaderLine("rates:%d,%d,%d", blackboxPrintfHeaderLine("rates:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[ROLL], masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[ROLL],
masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[PITCH], masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[PITCH],
masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[YAW]); masterConfig.profile[masterConfig.current_profile_index].controlRateProfile[masterConfig.profile[masterConfig.current_profile_index].activeRateProfile].rates[YAW]);
break; break;
case 20: case 21:
blackboxPrintfHeaderLine("looptime:%d", targetLooptime); blackboxPrintfHeaderLine("looptime:%d", targetLooptime);
break; break;
case 21: case 22:
blackboxPrintfHeaderLine("pidController:%d", masterConfig.profile[masterConfig.current_profile_index].pidProfile.pidController); blackboxPrintfHeaderLine("pidController:%d", masterConfig.profile[masterConfig.current_profile_index].pidProfile.pidController);
break; break;
case 22: case 23:
blackboxPrintfHeaderLine("rollPID:%d,%d,%d", blackboxPrintfHeaderLine("rollPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[ROLL], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[ROLL],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[ROLL], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[ROLL],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[ROLL]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[ROLL]);
break; break;
case 23: case 24:
blackboxPrintfHeaderLine("pitchPID:%d,%d,%d", blackboxPrintfHeaderLine("pitchPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PITCH], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PITCH],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PITCH], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PITCH],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PITCH]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PITCH]);
break; break;
case 24: case 25:
blackboxPrintfHeaderLine("yawPID:%d,%d,%d", blackboxPrintfHeaderLine("yawPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[YAW], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[YAW],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[YAW], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[YAW],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[YAW]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[YAW]);
break; break;
case 25: case 26:
blackboxPrintfHeaderLine("altPID:%d,%d,%d", blackboxPrintfHeaderLine("altPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDALT], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDALT],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDALT], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDALT],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDALT]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDALT]);
break; break;
case 26: case 27:
blackboxPrintfHeaderLine("posPID:%d,%d,%d", blackboxPrintfHeaderLine("posPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDPOS], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDPOS],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDPOS], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDPOS],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDPOS]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDPOS]);
break; break;
case 27: case 28:
blackboxPrintfHeaderLine("posrPID:%d,%d,%d", blackboxPrintfHeaderLine("posrPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDPOSR], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDPOSR],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDPOSR], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDPOSR],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDPOSR]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDPOSR]);
break; break;
case 28: case 29:
blackboxPrintfHeaderLine("navrPID:%d,%d,%d", blackboxPrintfHeaderLine("navrPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDNAVR], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDNAVR],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDNAVR], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDNAVR],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDNAVR]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDNAVR]);
break; break;
case 29: case 30:
blackboxPrintfHeaderLine("levelPID:%d,%d,%d", blackboxPrintfHeaderLine("levelPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDLEVEL], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDLEVEL],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDLEVEL], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDLEVEL],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDLEVEL]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDLEVEL]);
break; break;
case 30: case 31:
blackboxPrintfHeaderLine("magPID:%d", blackboxPrintfHeaderLine("magPID:%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDMAG]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDMAG]);
break; break;
case 31: case 32:
blackboxPrintfHeaderLine("velPID:%d,%d,%d", blackboxPrintfHeaderLine("velPID:%d,%d,%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDVEL], masterConfig.profile[masterConfig.current_profile_index].pidProfile.P8[PIDVEL],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDVEL], masterConfig.profile[masterConfig.current_profile_index].pidProfile.I8[PIDVEL],
masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDVEL]); masterConfig.profile[masterConfig.current_profile_index].pidProfile.D8[PIDVEL]);
break; break;
case 32: case 33:
blackboxPrintfHeaderLine("yaw_p_limit:%d", blackboxPrintfHeaderLine("yaw_p_limit:%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.yaw_p_limit); masterConfig.profile[masterConfig.current_profile_index].pidProfile.yaw_p_limit);
break; break;
case 33: case 34:
blackboxPrintfHeaderLine("yaw_lpf_hz:%d", blackboxPrintfHeaderLine("yaw_lpf_hz:%d",
(int)(masterConfig.profile[masterConfig.current_profile_index].pidProfile.yaw_lpf_hz * 100.0f)); (int)(masterConfig.profile[masterConfig.current_profile_index].pidProfile.yaw_lpf_hz * 100.0f));
break; break;
case 34: case 35:
blackboxPrintfHeaderLine("dterm_average_count:%d", blackboxPrintfHeaderLine("dterm_average_count:%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.dterm_average_count); masterConfig.profile[masterConfig.current_profile_index].pidProfile.dterm_average_count);
break; break;
case 35: case 36:
blackboxPrintfHeaderLine("dynamic_pid:%d", blackboxPrintfHeaderLine("dynamic_pid:%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.dynamic_pid); masterConfig.profile[masterConfig.current_profile_index].pidProfile.dynamic_pid);
break; break;
case 36: case 37:
blackboxPrintfHeaderLine("rollPitchItermResetRate:%d", blackboxPrintfHeaderLine("rollPitchItermResetRate:%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.rollPitchItermIgnoreRate); masterConfig.profile[masterConfig.current_profile_index].pidProfile.rollPitchItermIgnoreRate);
break; break;
case 37: case 38:
blackboxPrintfHeaderLine("yawItermResetRate:%d", blackboxPrintfHeaderLine("yawItermResetRate:%d",
masterConfig.profile[masterConfig.current_profile_index].pidProfile.yawItermIgnoreRate); masterConfig.profile[masterConfig.current_profile_index].pidProfile.yawItermIgnoreRate);
break; break;
case 38: case 39:
blackboxPrintfHeaderLine("dterm_lpf_hz:%d", blackboxPrintfHeaderLine("dterm_lpf_hz:%d",
(int)(masterConfig.profile[masterConfig.current_profile_index].pidProfile.dterm_lpf_hz * 100.0f)); (int)(masterConfig.profile[masterConfig.current_profile_index].pidProfile.dterm_lpf_hz * 100.0f));
break; break;
case 39: case 40:
blackboxPrintfHeaderLine("airmode_activate_throttle:%d", blackboxPrintfHeaderLine("airmode_activate_throttle:%d",
masterConfig.rxConfig.airModeActivateThreshold); masterConfig.rxConfig.airModeActivateThreshold);
break; break;
case 40: case 41:
blackboxPrintfHeaderLine("deadband:%d", masterConfig.rcControlsConfig.deadband); blackboxPrintfHeaderLine("deadband:%d", masterConfig.rcControlsConfig.deadband);
break; break;
case 41: case 42:
blackboxPrintfHeaderLine("yaw_deadband:%d", masterConfig.rcControlsConfig.yaw_deadband); blackboxPrintfHeaderLine("yaw_deadband:%d", masterConfig.rcControlsConfig.yaw_deadband);
break; break;
case 42: case 43:
blackboxPrintfHeaderLine("gyro_lpf:%d", masterConfig.gyro_lpf); blackboxPrintfHeaderLine("gyro_lpf:%d", masterConfig.gyro_lpf);
break; break;
case 43: case 44:
blackboxPrintfHeaderLine("gyro_lowpass_hz:%d", (int)(masterConfig.gyro_soft_lpf_hz * 100.0f)); blackboxPrintfHeaderLine("gyro_lowpass_hz:%d", (int)(masterConfig.gyro_soft_lpf_hz * 100.0f));
break; break;
case 44: case 45:
blackboxPrintfHeaderLine("acc_lpf_hz:%d", (int)(masterConfig.acc_lpf_hz * 100.0f)); blackboxPrintfHeaderLine("acc_lpf_hz:%d", (int)(masterConfig.acc_lpf_hz * 100.0f));
break; break;
case 45: case 46:
blackboxPrintfHeaderLine("acc_hardware:%d", masterConfig.acc_hardware); blackboxPrintfHeaderLine("acc_hardware:%d", masterConfig.acc_hardware);
break; break;
case 46: case 47:
blackboxPrintfHeaderLine("baro_hardware:%d", masterConfig.baro_hardware); blackboxPrintfHeaderLine("baro_hardware:%d", masterConfig.baro_hardware);
break; break;
case 47: case 48:
blackboxPrintfHeaderLine("mag_hardware:%d", masterConfig.mag_hardware); blackboxPrintfHeaderLine("mag_hardware:%d", masterConfig.mag_hardware);
break; break;
case 48: case 49:
blackboxPrintfHeaderLine("gyro_cal_on_first_arm:%d", masterConfig.gyro_cal_on_first_arm); blackboxPrintfHeaderLine("gyro_cal_on_first_arm:%d", masterConfig.gyro_cal_on_first_arm);
break; break;
case 49: case 50:
blackboxPrintfHeaderLine("vbat_pid_compensation:%d", masterConfig.batteryConfig.vbatPidCompensation); blackboxPrintfHeaderLine("vbat_pid_compensation:%d", masterConfig.batteryConfig.vbatPidCompensation);
break; break;
case 50: case 51:
blackboxPrintfHeaderLine("rc_smoothing:%d", masterConfig.rxConfig.rcSmoothing); blackboxPrintfHeaderLine("rc_smoothing:%d", masterConfig.rxConfig.rcSmoothing);
break; break;
case 51: case 52:
blackboxPrintfHeaderLine("features:%d", masterConfig.enabledFeatures); blackboxPrintfHeaderLine("features:%d", masterConfig.enabledFeatures);
break; break;
default: default:

View file

@ -79,7 +79,7 @@ float calculateRate(int axis, const controlRateConfig_t *controlRateConfig) {
float angleRate; float angleRate;
if (isSuperExpoActive()) { if (isSuperExpoActive()) {
float rcFactor = (axis == YAW) ? (ABS(rcCommand[axis]) / 500.0f) : (ABS(rcCommand[axis]) / (500.0f * (controlRateConfig->rcRate8 / 100.0f))); float rcFactor = (axis == YAW) ? (ABS(rcCommand[axis]) / (500.0f * (controlRateConfig->rcYawRate8 / 100.0f))) : (ABS(rcCommand[axis]) / (500.0f * (controlRateConfig->rcRate8 / 100.0f)));
rcFactor = 1.0f / (constrainf(1.0f - (rcFactor * (controlRateConfig->rates[axis] / 100.0f)), 0.01f, 1.00f)); rcFactor = 1.0f / (constrainf(1.0f - (rcFactor * (controlRateConfig->rates[axis] / 100.0f)), 0.01f, 1.00f));
angleRate = rcFactor * ((27 * rcCommand[axis]) / 16.0f); angleRate = rcFactor * ((27 * rcCommand[axis]) / 16.0f);