So I've been trying to find a way to control the heading on takeoff and within the code there is the following section on the Attitude tab:
// Yaw is separated into a function for future implementation of heading hold on take-off
// ----------------------------------------------------------------------------------------
void calc_nav_yaw(float speed_scaler)
{
// read_adc(4) is y axis accel;
// Control is a feedforward from the aileron control + a PID to coordinate the turn (drive y axis accel to zero)
servo_out[CH_RUDDER] = kff[CASE_RUDDER_MIX] * servo_out[CH_ROLL] + PID((long)read_adc(4), deltaMiliSeconds, CASE_SERVO_RUDDER, speed_scaler);
}
My question is whether anyone has done the "future implementation" already. If not, how would I do this? Would the calculation be similar to that used in the calc_nav_pitch section (below) ?
void calc_nav_pitch()
{
// Calculate the Pitch of the plane
// --------------------------------
nav_pitch = -PID(airspeed_error, dTnav, CASE_NAV_PITCH_ASP, 1.0);
nav_pitch = constrain(nav_pitch, pitch_min, pitch_max);
}
Replies