mirror of https://github.com/ArduPilot/ardupilot
Copter: convert the rest of motors class for tricopter
This commit is contained in:
parent
d005cbffd8
commit
1297a7dedb
|
@ -608,6 +608,9 @@ private:
|
|||
float takeoff_alt_cm;
|
||||
} gndeffect_state;
|
||||
|
||||
// set when we are upgrading parameters from 3.4
|
||||
bool upgrading_frame_params;
|
||||
|
||||
static const AP_Scheduler::Task scheduler_tasks[];
|
||||
static const AP_Param::Info var_info[];
|
||||
static const struct LogStructure log_structure[];
|
||||
|
|
|
@ -1164,25 +1164,7 @@ void Copter::convert_pid_parameters(void)
|
|||
const uint16_t old_aux_chan_mask = 0x3FF0;
|
||||
// note that we don't pass in rcmap as we don't want output channel functions changed based on rcmap
|
||||
if (SRV_Channels::upgrade_parameters(old_rc_keys, old_aux_chan_mask, nullptr)) {
|
||||
// do frame specific upgrade. This is only done the first time we run the new firmware
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 12, CH_1);
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 13, CH_2);
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 14, CH_3);
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 15, CH_4);
|
||||
#else
|
||||
if (g2.frame_class == AP_Motors::MOTOR_FRAME_TRI) {
|
||||
const AP_Param::ConversionInfo tri_conversion_info[] = {
|
||||
{ Parameters::k_param_motors, 32, AP_PARAM_INT16, "SERVO7_TRIM" },
|
||||
{ Parameters::k_param_motors, 33, AP_PARAM_INT16, "SERVO7_MIN" },
|
||||
{ Parameters::k_param_motors, 34, AP_PARAM_INT16, "SERVO7_MAX" },
|
||||
{ Parameters::k_param_motors, 35, AP_PARAM_FLOAT, "MOT_YAW_SV_ANGLE" },
|
||||
};
|
||||
// we need to use CONVERT_FLAG_FORCE as the SERVO7_* parameters will already be set from RC7_*
|
||||
AP_Param::convert_old_parameters(tri_conversion_info, ARRAY_SIZE(tri_conversion_info), AP_Param::CONVERT_FLAG_FORCE);
|
||||
const AP_Param::ConversionInfo tri_conversion_info_rev { Parameters::k_param_motors, 31, AP_PARAM_INT8, "SERVO7_REVERSED" };
|
||||
AP_Param::convert_old_parameter(&tri_conversion_info_rev, 1, AP_Param::CONVERT_FLAG_REVERSE | AP_Param::CONVERT_FLAG_FORCE);
|
||||
}
|
||||
#endif
|
||||
// the rest needs to be done after motors allocation
|
||||
upgrading_frame_params = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -615,4 +615,29 @@ void Copter::allocate_motors(void)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (upgrading_frame_params) {
|
||||
// do frame specific upgrade. This is only done the first time we run the new firmware
|
||||
#if FRAME_CONFIG == HELI_FRAME
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 12, CH_1);
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 13, CH_2);
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 14, CH_3);
|
||||
SRV_Channels::upgrade_motors_servo(Parameters::k_param_motors, 15, CH_4);
|
||||
#else
|
||||
if (g2.frame_class == AP_Motors::MOTOR_FRAME_TRI) {
|
||||
const AP_Param::ConversionInfo tri_conversion_info[] = {
|
||||
{ Parameters::k_param_motors, 32, AP_PARAM_INT16, "SERVO7_TRIM" },
|
||||
{ Parameters::k_param_motors, 33, AP_PARAM_INT16, "SERVO7_MIN" },
|
||||
{ Parameters::k_param_motors, 34, AP_PARAM_INT16, "SERVO7_MAX" },
|
||||
{ Parameters::k_param_motors, 35, AP_PARAM_FLOAT, "MOT_YAW_SV_ANGLE" },
|
||||
};
|
||||
// we need to use CONVERT_FLAG_FORCE as the SERVO7_* parameters will already be set from RC7_*
|
||||
AP_Param::convert_old_parameters(tri_conversion_info, ARRAY_SIZE(tri_conversion_info), AP_Param::CONVERT_FLAG_FORCE);
|
||||
const AP_Param::ConversionInfo tri_conversion_info_rev { Parameters::k_param_motors, 31, AP_PARAM_INT8, "SERVO7_REVERSED" };
|
||||
AP_Param::convert_old_parameter(&tri_conversion_info_rev, 1, AP_Param::CONVERT_FLAG_REVERSE | AP_Param::CONVERT_FLAG_FORCE);
|
||||
// AP_MotorsTri was converted from having nested var_info to one level
|
||||
AP_Param::convert_parent_class(Parameters::k_param_motors, motors, motors->var_info);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue