@@ -641,14 +641,22 @@ FixedwingPositionControl::update_desired_altitude(float dt)
641
641
if (_manual_control_setpoint_altitude > deadBand) {
642
642
/* pitching down */
643
643
float pitch = -(_manual_control_setpoint_altitude - deadBand) / factor;
644
- _hold_alt += (_param_sinkrate_target.get () * dt) * pitch;
645
- _was_in_deadband = false ;
644
+
645
+ if (pitch * _param_sinkrate_target.get () < _tecs.hgt_rate_setpoint ()) {
646
+ _hold_alt += (_param_sinkrate_target.get () * dt) * pitch;
647
+ _manual_height_rate_setpoint_m_s = pitch * _param_sinkrate_target.get ();
648
+ _was_in_deadband = false ;
649
+ }
646
650
647
651
} else if (_manual_control_setpoint_altitude < - deadBand) {
648
652
/* pitching up */
649
653
float pitch = -(_manual_control_setpoint_altitude + deadBand) / factor;
650
- _hold_alt += (_param_climbrate_target.get () * dt) * pitch;
651
- _was_in_deadband = false ;
654
+
655
+ if (pitch * _param_climbrate_target.get () > _tecs.hgt_rate_setpoint ()) {
656
+ _hold_alt += (_param_climbrate_target.get () * dt) * pitch;
657
+ _manual_height_rate_setpoint_m_s = pitch * _param_climbrate_target.get ();
658
+ _was_in_deadband = false ;
659
+ }
652
660
653
661
} else if (!_was_in_deadband) {
654
662
/* store altitude at which manual.x was inside deadBand
@@ -657,6 +665,7 @@ FixedwingPositionControl::update_desired_altitude(float dt)
657
665
_hold_alt = _current_altitude;
658
666
_althold_epv = _local_pos.epv ;
659
667
_was_in_deadband = true ;
668
+ _manual_height_rate_setpoint_m_s = NAN;
660
669
}
661
670
662
671
if (_vehicle_status.is_vtol ) {
@@ -1113,7 +1122,8 @@ FixedwingPositionControl::control_position(const hrt_abstime &now, const Vector2
1113
1122
_param_fw_thr_cruise.get (),
1114
1123
false ,
1115
1124
pitch_limit_min,
1116
- tecs_status_s::TECS_MODE_NORMAL);
1125
+ tecs_status_s::TECS_MODE_NORMAL,
1126
+ _manual_height_rate_setpoint_m_s);
1117
1127
1118
1128
/* heading control */
1119
1129
if (fabsf (_manual_control_setpoint.y ) < HDG_HOLD_MAN_INPUT_THRESH &&
@@ -1225,7 +1235,8 @@ FixedwingPositionControl::control_position(const hrt_abstime &now, const Vector2
1225
1235
_param_fw_thr_cruise.get (),
1226
1236
false ,
1227
1237
pitch_limit_min,
1228
- tecs_status_s::TECS_MODE_NORMAL);
1238
+ tecs_status_s::TECS_MODE_NORMAL,
1239
+ _manual_height_rate_setpoint_m_s);
1229
1240
1230
1241
_att_sp.roll_body = _manual_control_setpoint.y * radians (_param_fw_man_r_max.get ());
1231
1242
_att_sp.yaw_body = 0 ;
0 commit comments