@@ -201,6 +201,13 @@ void TECS::updateHeightRateSetpoint(float alt_sp_amsl_m, float target_climbrate_
201
201
_hgt_rate_setpoint = math::constrain (_hgt_rate_setpoint, -_max_sink_rate, _max_climb_rate);
202
202
}
203
203
204
+ void TECS::_update_height_rate_setpoint (float hgt_rate_sp)
205
+ {
206
+ // Limit the rate of change of height demand to respect vehicle performance limits
207
+ _hgt_rate_setpoint = math::constrain (hgt_rate_sp, -_max_sink_rate, _max_climb_rate);
208
+ _hgt_setpoint = _vert_pos_state;
209
+ }
210
+
204
211
void TECS::_detect_underspeed ()
205
212
{
206
213
if (!_detect_underspeed_enabled) {
@@ -510,7 +517,7 @@ void TECS::_update_STE_rate_lim()
510
517
void TECS::update_pitch_throttle (float pitch, float baro_altitude, float hgt_setpoint,
511
518
float EAS_setpoint, float equivalent_airspeed, float eas_to_tas, bool climb_out_setpoint, float pitch_min_climbout,
512
519
float throttle_min, float throttle_max, float throttle_cruise, float pitch_limit_min, float pitch_limit_max,
513
- float target_climbrate, float target_sinkrate)
520
+ float target_climbrate, float target_sinkrate, float hgt_rate_sp )
514
521
{
515
522
// Calculate the time since last update (seconds)
516
523
uint64_t now = hrt_absolute_time ();
@@ -548,8 +555,14 @@ void TECS::update_pitch_throttle(float pitch, float baro_altitude, float hgt_set
548
555
// Calculate the demanded true airspeed
549
556
_update_speed_setpoint ();
550
557
551
- // calculate heigh rate setpoint based on altitude demand
552
- updateHeightRateSetpoint (hgt_setpoint, target_climbrate, target_sinkrate, baro_altitude);
558
+ if (PX4_ISFINITE (hgt_rate_sp)) {
559
+ // use the provided height rate setpoint instead of the height setpoint
560
+ _update_height_rate_setpoint (hgt_rate_sp);
561
+
562
+ } else {
563
+ // calculate heigh rate setpoint based on altitude demand
564
+ updateHeightRateSetpoint (hgt_setpoint, target_climbrate, target_sinkrate, baro_altitude);
565
+ }
553
566
554
567
// Calculate the specific energy values required by the control loop
555
568
_update_energy_estimates ();
0 commit comments