Skip to content

Commit

Permalink
AC_AutoTune: allow heli to have different angle limits than multi
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Feb 27, 2024
1 parent 14bef1a commit 685bf80
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libraries/AC_AutoTune/AC_AutoTune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ void AC_AutoTune::control_attitude()
test_run(axis, direction_sign);

// Check for failure causing reverse response
if (lean_angle <= -attitude_control->lean_angle_max_cd() * AUTOTUNE_TARGET_MIN_ANGLE_RLLPIT_SCALE) {
if (lean_angle <= -target_min_angle_rllpit_cd()) {
step = WAITING_FOR_LEVEL;
positive_direction = twitch_reverse_direction();
step_start_time_ms = now;
Expand Down
3 changes: 3 additions & 0 deletions libraries/AC_AutoTune/AC_AutoTune.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ class AC_AutoTune
// return true if we have a good position estimate
virtual bool position_ok();

// methods subclasses must implement to specify max/min test angles:
virtual float target_min_angle_rllpit_cd() const = 0;

// initialise position controller
bool init_position_controller();

Expand Down
10 changes: 10 additions & 0 deletions libraries/AC_AutoTune/AC_AutoTune_Heli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
#define AUTOTUNE_SEQ_BITMASK_MAX_GAIN 8
#define AUTOTUNE_SEQ_BITMASK_TUNE_CHECK 16

// angle limits preserved from previous behaviour as Multi changed:
#define AUTOTUNE_TARGET_MIN_ANGLE_RLLPIT_CD 1000 // minimum target angle during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_ANGLE_RLLPIT_CD 2000 // target angle during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_ANGLE_YAW_CD 3000 // target angle during TESTING_RATE step that will cause us to move to next step

const AP_Param::GroupInfo AC_AutoTune_Heli::var_info[] = {

// @Param: AXES
Expand Down Expand Up @@ -1724,6 +1729,11 @@ void AC_AutoTune_Heli::updating_max_gains(float *freq, float *gain, float *phase

}

float AC_AutoTune_Heli::target_min_angle_rllpit_cd() const
{
return AUTOTUNE_TARGET_MIN_ANGLE_RLLPIT_CD;
}

#if HAL_LOGGING_ENABLED
// log autotune summary data
void AC_AutoTune_Heli::Log_AutoTune()
Expand Down
2 changes: 2 additions & 0 deletions libraries/AC_AutoTune/AC_AutoTune_Heli.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ class AC_AutoTune_Heli : public AC_AutoTune
DRB = 2,
};

float target_min_angle_rllpit_cd() const override;

// Feedforward test used to determine Rate FF gain
void rate_ff_test_init();
void rate_ff_test_run(float max_angle_cds, float target_rate_cds, float dir_sign);
Expand Down
5 changes: 5 additions & 0 deletions libraries/AC_AutoTune/AC_AutoTune_Multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,11 @@ void AC_AutoTune_Multi::Log_AutoTuneDetails()
Log_Write_AutoTuneDetails(lean_angle, rotation_rate);
}

float AC_AutoTune_Multi::target_min_angle_rllpit_cd() const
{
return attitude_control->lean_angle_max_cd() * AUTOTUNE_TARGET_MIN_ANGLE_RLLPIT_SCALE;
}

// @LoggerMessage: ATUN
// @Description: Copter/QuadPlane AutoTune
// @Vehicles: Copter, Plane
Expand Down
2 changes: 2 additions & 0 deletions libraries/AC_AutoTune/AC_AutoTune_Multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class AC_AutoTune_Multi : public AC_AutoTune
// reset the update gain variables for multi
void reset_update_gain_variables() override {};

float target_min_angle_rllpit_cd() const override;

void test_init() override;
void test_run(AxisType test_axis, const float dir_sign) override;

Expand Down

0 comments on commit 685bf80

Please sign in to comment.