Browse Source

APM_Control: Fixed the subparam indexs to start at 1

AFAIK there is still a bug in ArduPilot where subparams should not start at index 0.  This is due to the way the index math and bit shifing works as it incorrectly offsets all 0 index params to 0. We allow 2 levels of sub params - 3 levels in total.  So params, sub params and sub sub params.  The 0 parameter in all those is unfortunately always references param[0].  So param[0] and subparam[0] and subsubparam[0] will reference the same parameter value.  Its why we always say start the index from 1 as the math and bitshifting then works correctly.

Yeah this is worded badly - hard to explain.
mission-4.1.18
Grant Morphett 7 years ago committed by Randy Mackay
parent
commit
f7db538220
  1. 14
      libraries/APM_Control/AR_AttitudeControl.cpp

14
libraries/APM_Control/AR_AttitudeControl.cpp

@ -21,13 +21,6 @@ extern const AP_HAL::HAL& hal;
const AP_Param::GroupInfo AR_AttitudeControl::var_info[] = { const AP_Param::GroupInfo AR_AttitudeControl::var_info[] = {
// @Param: _STR_ANG_P
// @DisplayName: Steering control angle P gain
// @Description: Steering control angle P gain. Converts the error between the desired heading/yaw (in radians) and actual heading/yaw to a desired turn rate (in rad/sec)
// @Range: 1.000 10.000
// @User: Standard
AP_SUBGROUPINFO(_steer_angle_p, "_STR_ANG_", 0, AR_AttitudeControl, AC_P),
// @Param: _STR_RATE_P // @Param: _STR_RATE_P
// @DisplayName: Steering control rate P gain // @DisplayName: Steering control rate P gain
// @Description: Steering control rate P gain. Converts the turn rate error (in radians/sec) to a steering control output (in the range -1 to +1) // @Description: Steering control rate P gain. Converts the turn rate error (in radians/sec) to a steering control output (in the range -1 to +1)
@ -117,6 +110,13 @@ const AP_Param::GroupInfo AR_AttitudeControl::var_info[] = {
// @User: Standard // @User: Standard
AP_GROUPINFO("_STOP_SPEED", 5, AR_AttitudeControl, _stop_speed, AR_ATTCONTROL_STOP_SPEED_DEFAULT), AP_GROUPINFO("_STOP_SPEED", 5, AR_AttitudeControl, _stop_speed, AR_ATTCONTROL_STOP_SPEED_DEFAULT),
// @Param: _STR_ANG_P
// @DisplayName: Steering control angle P gain
// @Description: Steering control angle P gain. Converts the error between the desired heading/yaw (in radians) and actual heading/yaw to a desired turn rate (in rad/sec)
// @Range: 1.000 10.000
// @User: Standard
AP_SUBGROUPINFO(_steer_angle_p, "_STR_ANG_", 6, AR_AttitudeControl, AC_P),
AP_GROUPEND AP_GROUPEND
}; };

Loading…
Cancel
Save