Skip to content

Commit

Permalink
Copter: Autotune: More Feedback and Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lthall committed Feb 18, 2024
1 parent ab02152 commit 227768b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions libraries/AC_AutoTune/AC_AutoTune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define AUTOTUNE_LEVEL_RATE_Y_CD 750 // rate which qualifies as level for yaw
#define AUTOTUNE_REQUIRED_LEVEL_TIME_MS 250 // time we require the aircraft to be level
#define AUTOTUNE_LEVEL_TIMEOUT_MS 2000 // time out for level
#define AUTOTUNE_ANGLE_MAX_RLLPIT 2.0 / 3.0 // maximum allowable angle in degrees during testing
#define AUTOTUNE_ANGLE_MAX_RLLPIT 2.0 / 3.0 // maximum allowable angle during testing, as a ratio of angle_max

AC_AutoTune::AC_AutoTune()
{
Expand Down Expand Up @@ -395,7 +395,7 @@ void AC_AutoTune::control_attitude()
}

// protect from roll over
float resultant_angle = degrees(acosf(ahrs_view->cos_roll() * ahrs_view->cos_pitch()));
float resultant_angle = 100 * degrees(acosf(ahrs_view->cos_roll() * ahrs_view->cos_pitch()));
if (resultant_angle > attitude_control->lean_angle_max_cd() * AUTOTUNE_ANGLE_MAX_RLLPIT) {
step = WAITING_FOR_LEVEL;
positive_direction = twitch_reverse_direction();
Expand All @@ -410,7 +410,7 @@ void AC_AutoTune::control_attitude()
log_pids();
#endif

if (axis == YAW || axis == YAW_D ) {
if (axis == YAW || axis == YAW_D) {
desired_yaw_cd = ahrs_view->yaw_sensor;
}
break;
Expand Down
8 changes: 4 additions & 4 deletions libraries/AC_AutoTune/AC_AutoTune.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@

#define AUTOTUNE_ANNOUNCE_INTERVAL_MS 2000

#define AUTOTUNE_TARGET_MIN_ANGLE_RLLPIT 1.0 / 4.0 // minimum target angle during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_ANGLE_RLLPIT 1.0 / 2.0 // target angle during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_MIN_ANGLE_YAW 1.0 / 8.0 // minimum target angle during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_ANGLE_YAW 2.0 / 3.0 // target angle during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_MIN_ANGLE_RLLPIT 1.0 / 4.0 // minimum target angle, as a ratio of angle_max, during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_ANGLE_RLLPIT 1.0 / 2.0 // target angle, as a ratio of angle_max, during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_MIN_ANGLE_YAW 1.0 / 8.0 // minimum target angle, as a ratio of angle_max, during TESTING_RATE step that will cause us to move to next step
#define AUTOTUNE_TARGET_ANGLE_YAW 2.0 / 3.0 // target angle, as a ratio of angle_max, during TESTING_RATE step that will cause us to move to next step

class AC_AutoTune
{
Expand Down
4 changes: 2 additions & 2 deletions libraries/AC_AutoTune/AC_AutoTune_Multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ void AC_AutoTune_Multi::twitching_test_rate(float rate, float rate_target_max, f
}

// calculate early stopping time based on the time it takes to get to 75%
if (meas_rate_max < rate_target_max * 63.21) {
if (meas_rate_max < rate_target_max * 0.6321) {
// the measurement not reached the 63.21% threshold yet
step_time_limit_ms = (now - step_start_time_ms) * 3;
step_time_limit_ms = MIN(step_time_limit_ms, AUTOTUNE_TESTING_STEP_TIMEOUT_MS);
Expand Down Expand Up @@ -592,7 +592,7 @@ void AC_AutoTune_Multi::twitching_test_angle(float angle, float rate, float angl
}

// calculate early stopping time based on the time it takes to get to 75%
if (meas_angle_max < angle_target_max * 63.21) {
if (meas_angle_max < angle_target_max * 0.6321) {
// the measurement not reached the 63.21% threshold yet
step_time_limit_ms = (now - step_start_time_ms) * 3;
step_time_limit_ms = MIN(step_time_limit_ms, AUTOTUNE_TESTING_STEP_TIMEOUT_MS);
Expand Down

0 comments on commit 227768b

Please sign in to comment.