Copter: fix send_pid_tuning

the rate roll PID was being overwritten when PID logging was enabled
This commit is contained in:
Randy Mackay 2019-04-13 11:49:07 +09:00
parent 54fe1dad82
commit 571d933b3f

View File

@ -201,37 +201,38 @@ void GCS_MAVLINK_Copter::send_pid_tuning()
if (!HAVE_PAYLOAD_SPACE(chan, PID_TUNING)) { if (!HAVE_PAYLOAD_SPACE(chan, PID_TUNING)) {
return; return;
} }
AC_PID &pid = copter.attitude_control->get_rate_roll_pid(); // dummy ref const AP_Logger::PID_Info *pid_info = nullptr;
float achieved; float achieved;
switch (axes[i]) { switch (axes[i]) {
case PID_TUNING_ROLL: case PID_TUNING_ROLL:
pid = copter.attitude_control->get_rate_roll_pid(); pid_info = &copter.attitude_control->get_rate_roll_pid().get_pid_info();
achieved = degrees(gyro.x); achieved = degrees(gyro.x);
break; break;
case PID_TUNING_PITCH: case PID_TUNING_PITCH:
pid = copter.attitude_control->get_rate_pitch_pid(); pid_info = &copter.attitude_control->get_rate_pitch_pid().get_pid_info();
achieved = degrees(gyro.y); achieved = degrees(gyro.y);
break; break;
case PID_TUNING_YAW: case PID_TUNING_YAW:
pid = copter.attitude_control->get_rate_yaw_pid(); pid_info = &copter.attitude_control->get_rate_yaw_pid().get_pid_info();
achieved = degrees(gyro.z); achieved = degrees(gyro.z);
break; break;
case PID_TUNING_ACCZ: case PID_TUNING_ACCZ:
pid = copter.pos_control->get_accel_z_pid(); pid_info = &copter.pos_control->get_accel_z_pid().get_pid_info();
achieved = -(AP::ahrs().get_accel_ef_blended().z + GRAVITY_MSS); achieved = -(AP::ahrs().get_accel_ef_blended().z + GRAVITY_MSS);
break; break;
default: default:
continue; continue;
} }
const AP_Logger::PID_Info &pid_info = pid.get_pid_info(); if (pid_info != nullptr) {
mavlink_msg_pid_tuning_send(chan, mavlink_msg_pid_tuning_send(chan,
axes[i], axes[i],
pid_info.desired*0.01f, pid_info->desired*0.01f,
achieved, achieved,
pid_info.FF*0.01f, pid_info->FF*0.01f,
pid_info.P*0.01f, pid_info->P*0.01f,
pid_info.I*0.01f, pid_info->I*0.01f,
pid_info.D*0.01f); pid_info->D*0.01f);
}
} }
} }