2018-12-07 03:52:05 -04:00
|
|
|
#include "Plane.h"
|
|
|
|
#include "qautotune.h"
|
|
|
|
|
|
|
|
#if QAUTOTUNE_ENABLED
|
|
|
|
|
|
|
|
/*
|
|
|
|
initialise QAUTOTUNE mode
|
|
|
|
*/
|
|
|
|
bool QAutoTune::init()
|
|
|
|
{
|
|
|
|
if (!plane.quadplane.available()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// use position hold while tuning if we were in QLOITER
|
2019-01-15 13:46:13 -04:00
|
|
|
bool position_hold = (plane.previous_mode == &plane.mode_qloiter);
|
2018-12-07 03:52:05 -04:00
|
|
|
|
|
|
|
return init_internals(position_hold,
|
|
|
|
plane.quadplane.attitude_control,
|
|
|
|
plane.quadplane.pos_control,
|
|
|
|
plane.quadplane.ahrs_view,
|
|
|
|
&plane.quadplane.inertial_nav);
|
|
|
|
}
|
|
|
|
|
|
|
|
float QAutoTune::get_pilot_desired_climb_rate_cms(void) const
|
|
|
|
{
|
|
|
|
return plane.quadplane.get_pilot_desired_climb_rate_cms();
|
|
|
|
}
|
|
|
|
|
2019-02-28 07:11:05 -04:00
|
|
|
void QAutoTune::get_pilot_desired_rp_yrate_cd(float &des_roll_cd, float &des_pitch_cd, float &yaw_rate_cds)
|
2018-12-07 03:52:05 -04:00
|
|
|
{
|
|
|
|
if (plane.channel_roll->get_control_in() == 0 && plane.channel_pitch->get_control_in() == 0) {
|
|
|
|
des_roll_cd = 0;
|
|
|
|
des_pitch_cd = 0;
|
|
|
|
} else {
|
|
|
|
des_roll_cd = plane.nav_roll_cd;
|
|
|
|
des_pitch_cd = plane.nav_pitch_cd;
|
|
|
|
}
|
|
|
|
yaw_rate_cds = plane.quadplane.get_desired_yaw_rate_cds();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QAutoTune::init_z_limits()
|
|
|
|
{
|
2021-03-16 18:54:03 -03:00
|
|
|
plane.quadplane.pos_control->set_max_speed_z(-plane.quadplane.get_pilot_velocity_z_max_dn(), plane.quadplane.pilot_velocity_z_max_up);
|
2018-12-07 03:52:05 -04:00
|
|
|
plane.quadplane.pos_control->set_max_accel_z(plane.quadplane.pilot_accel_z);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-21 22:26:31 -04:00
|
|
|
// log VTOL PIDs for during twitch
|
|
|
|
void QAutoTune::log_pids(void)
|
|
|
|
{
|
2019-01-18 00:24:08 -04:00
|
|
|
AP::logger().Write_PID(LOG_PIQR_MSG, plane.quadplane.attitude_control->get_rate_roll_pid().get_pid_info());
|
|
|
|
AP::logger().Write_PID(LOG_PIQP_MSG, plane.quadplane.attitude_control->get_rate_pitch_pid().get_pid_info());
|
|
|
|
AP::logger().Write_PID(LOG_PIQY_MSG, plane.quadplane.attitude_control->get_rate_yaw_pid().get_pid_info());
|
2018-12-21 22:26:31 -04:00
|
|
|
}
|
|
|
|
|
2018-12-07 03:52:05 -04:00
|
|
|
#endif // QAUTOTUNE_ENABLED
|
|
|
|
|