Skip to content

Commit 1d4c738

Browse files
committed
Plane: moved assign tilt to the run() function
this prevents double calling and fixes qhover
1 parent de100ce commit 1d4c738

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

ArduPlane/mode_qhover.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void ModeQHover::run()
3737
quadplane.relax_attitude_control();
3838
pos_control->relax_z_controller(0);
3939
} else {
40+
plane.quadplane.assign_tilt_to_fwd_thr();
4041
quadplane.hold_hover(quadplane.get_pilot_desired_climb_rate_cms());
4142
}
4243

ArduPlane/mode_qstabilize.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ void ModeQStabilize::update()
3535
plane.nav_roll_cd = roll_input * plane.quadplane.aparm.angle_max;
3636
plane.nav_pitch_cd = pitch_input * plane.quadplane.aparm.angle_max;
3737
}
38-
39-
if (plane.control_mode->mode_number() == Mode::Number::QSTABILIZE) {
40-
// protect against this function running twice
41-
plane.quadplane.assign_tilt_to_fwd_thr();
42-
}
4338
}
4439

4540
// quadplane stabilize mode
@@ -52,6 +47,8 @@ void ModeQStabilize::run()
5247
return;
5348
}
5449

50+
plane.quadplane.assign_tilt_to_fwd_thr();
51+
5552
// special check for ESC calibration in QSTABILIZE
5653
if (quadplane.esc_calibration != 0) {
5754
quadplane.run_esc_calibration();

ArduPlane/quadplane.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,9 @@ QuadPlane::ActiveFwdThr QuadPlane::get_vfwd_method(void) const
29722972
return ActiveFwdThr::NONE;
29732973
}
29742974

2975+
/*
2976+
map from pitch tilt to fwd throttle when enabled
2977+
*/
29752978
void QuadPlane::assign_tilt_to_fwd_thr(void) {
29762979

29772980
const auto fwd_thr_active = get_vfwd_method();
@@ -2991,7 +2994,8 @@ void QuadPlane::assign_tilt_to_fwd_thr(void) {
29912994
if (is_positive(fwd_tilt_range_cd)) {
29922995
// rate limit the forward tilt change to slew between the motor good and motor failed
29932996
// value over 10 seconds
2994-
const float fwd_pitch_lim_cd_tgt = plane.quadplane.pos_control->get_fwd_pitch_is_limited() ? (float)aparm.angle_max : 100.0f * q_fwd_pitch_lim;
2997+
const bool fwd_limited = plane.quadplane.pos_control->is_active_xy() and plane.quadplane.pos_control->get_fwd_pitch_is_limited();
2998+
const float fwd_pitch_lim_cd_tgt = fwd_limited ? (float)aparm.angle_max : 100.0f * q_fwd_pitch_lim;
29952999
const float delta_max = 0.1f * fwd_tilt_range_cd * plane.G_Dt;
29963000
q_fwd_pitch_lim_cd += constrain_float((fwd_pitch_lim_cd_tgt - q_fwd_pitch_lim_cd), -delta_max, delta_max);
29973001
// Don't let the forward pitch limit be more than the forward pitch demand before limiting to

0 commit comments

Comments
 (0)