mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 05:33:35 +08:00
mtecs: add altitude prefiltering
This commit is contained in:
@@ -59,6 +59,7 @@ mTecs::mTecs() :
|
|||||||
_controlAltitude(this, "FPA", true),
|
_controlAltitude(this, "FPA", true),
|
||||||
_controlAirSpeed(this, "ACC"),
|
_controlAirSpeed(this, "ACC"),
|
||||||
_flightPathAngleLowpass(this, "FPA_LP"),
|
_flightPathAngleLowpass(this, "FPA_LP"),
|
||||||
|
_altitudeLowpass(this, "ALT_LP"),
|
||||||
_airspeedLowpass(this, "A_LP"),
|
_airspeedLowpass(this, "A_LP"),
|
||||||
_airspeedDerivative(this, "AD"),
|
_airspeedDerivative(this, "AD"),
|
||||||
_throttleSp(0.0f),
|
_throttleSp(0.0f),
|
||||||
@@ -93,18 +94,23 @@ int mTecs::updateAltitudeSpeed(float flightPathAngle, float altitude, float alti
|
|||||||
/* time measurement */
|
/* time measurement */
|
||||||
updateTimeMeasurement();
|
updateTimeMeasurement();
|
||||||
|
|
||||||
|
/* Filter altitude */
|
||||||
|
float altitudeFiltered = _altitudeLowpass.update(altitude);
|
||||||
|
|
||||||
|
|
||||||
/* calculate flight path angle setpoint from altitude setpoint */
|
/* calculate flight path angle setpoint from altitude setpoint */
|
||||||
float flightPathAngleSp = _controlAltitude.update(altitudeSp - altitude);
|
float flightPathAngleSp = _controlAltitude.update(altitudeSp - altitudeFiltered);
|
||||||
|
|
||||||
/* Debug output */
|
/* Debug output */
|
||||||
if (_counter % 10 == 0) {
|
if (_counter % 10 == 0) {
|
||||||
debug("***");
|
debug("***");
|
||||||
debug("updateAltitudeSpeed: altitudeSp %.4f, altitude %.4f, flightPathAngleSp %.4f", (double)altitudeSp, (double)altitude, (double)flightPathAngleSp);
|
debug("updateAltitudeSpeed: altitudeSp %.4f, altitude %.4f, altitude filtered %.4f, flightPathAngleSp %.4f", (double)altitudeSp, (double)altitude, (double)altitudeFiltered, (double)flightPathAngleSp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write part of the status message */
|
/* Write part of the status message */
|
||||||
_status.altitudeSp = altitudeSp;
|
_status.altitudeSp = altitudeSp;
|
||||||
_status.altitude = altitude;
|
_status.altitude = altitude;
|
||||||
|
_status.altitudeFiltered = altitudeFiltered;
|
||||||
|
|
||||||
|
|
||||||
/* use flightpath angle setpoint for total energy control */
|
/* use flightpath angle setpoint for total energy control */
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ protected:
|
|||||||
|
|
||||||
/* Other calculation Blocks */
|
/* Other calculation Blocks */
|
||||||
control::BlockLowPass _flightPathAngleLowpass; /**< low pass filter for the flight path angle */
|
control::BlockLowPass _flightPathAngleLowpass; /**< low pass filter for the flight path angle */
|
||||||
|
control::BlockLowPass _altitudeLowpass; /**< low pass filter for altitude */
|
||||||
control::BlockLowPass _airspeedLowpass; /**< low pass filter for airspeed */
|
control::BlockLowPass _airspeedLowpass; /**< low pass filter for airspeed */
|
||||||
control::BlockDerivative _airspeedDerivative; /**< airspeed derivative calulation */
|
control::BlockDerivative _airspeedDerivative; /**< airspeed derivative calulation */
|
||||||
|
|
||||||
|
|||||||
@@ -174,6 +174,13 @@ PARAM_DEFINE_FLOAT(MT_PIT_MIN, -45.0f);
|
|||||||
*/
|
*/
|
||||||
PARAM_DEFINE_FLOAT(MT_PIT_MAX, 20.0f);
|
PARAM_DEFINE_FLOAT(MT_PIT_MAX, 20.0f);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lowpass (cutoff freq.) for altitude
|
||||||
|
*
|
||||||
|
* @group mTECS
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(MT_ALT_LP, 1.0f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lowpass (cutoff freq.) for the flight path angle
|
* Lowpass (cutoff freq.) for the flight path angle
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1595,6 +1595,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
log_msg.msg_type = LOG_TECS_MSG;
|
log_msg.msg_type = LOG_TECS_MSG;
|
||||||
log_msg.body.log_TECS.altitudeSp = buf.tecs_status.altitudeSp;
|
log_msg.body.log_TECS.altitudeSp = buf.tecs_status.altitudeSp;
|
||||||
log_msg.body.log_TECS.altitude = buf.tecs_status.altitude;
|
log_msg.body.log_TECS.altitude = buf.tecs_status.altitude;
|
||||||
|
log_msg.body.log_TECS.altitudeFiltered = buf.tecs_status.altitudeFiltered;
|
||||||
log_msg.body.log_TECS.flightPathAngleSp = buf.tecs_status.flightPathAngleSp;
|
log_msg.body.log_TECS.flightPathAngleSp = buf.tecs_status.flightPathAngleSp;
|
||||||
log_msg.body.log_TECS.flightPathAngle = buf.tecs_status.flightPathAngle;
|
log_msg.body.log_TECS.flightPathAngle = buf.tecs_status.flightPathAngle;
|
||||||
log_msg.body.log_TECS.flightPathAngleFiltered = buf.tecs_status.flightPathAngleFiltered;
|
log_msg.body.log_TECS.flightPathAngleFiltered = buf.tecs_status.flightPathAngleFiltered;
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ struct log_GS1B_s {
|
|||||||
struct log_TECS_s {
|
struct log_TECS_s {
|
||||||
float altitudeSp;
|
float altitudeSp;
|
||||||
float altitude;
|
float altitude;
|
||||||
|
float altitudeFiltered;
|
||||||
float flightPathAngleSp;
|
float flightPathAngleSp;
|
||||||
float flightPathAngle;
|
float flightPathAngle;
|
||||||
float flightPathAngleFiltered;
|
float flightPathAngleFiltered;
|
||||||
@@ -454,7 +455,7 @@ static const struct log_format_s log_formats[] = {
|
|||||||
LOG_FORMAT(GS0B, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"),
|
LOG_FORMAT(GS0B, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"),
|
||||||
LOG_FORMAT(GS1A, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"),
|
LOG_FORMAT(GS1A, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"),
|
||||||
LOG_FORMAT(GS1B, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"),
|
LOG_FORMAT(GS1B, "BBBBBBBBBBBBBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15"),
|
||||||
LOG_FORMAT(TECS, "ffffffffffffffB", "AltSP,Alt,FSP,F,FF,AsSP,As,AsF,AsDSP,AsD,TERSP,TER,EDRSP,EDR,M"),
|
LOG_FORMAT(TECS, "fffffffffffffffB", "ASP,A,AF,FSP,F,FF,AsSP,As,AsF,AsDSP,AsD,TERSP,TER,EDRSP,EDR,M"),
|
||||||
LOG_FORMAT(WIND, "ffff", "X,Y,CovX,CovY"),
|
LOG_FORMAT(WIND, "ffff", "X,Y,CovX,CovY"),
|
||||||
|
|
||||||
/* system-level messages, ID >= 0x80 */
|
/* system-level messages, ID >= 0x80 */
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ struct tecs_status_s {
|
|||||||
|
|
||||||
float altitudeSp;
|
float altitudeSp;
|
||||||
float altitude;
|
float altitude;
|
||||||
|
float altitudeFiltered;
|
||||||
float flightPathAngleSp;
|
float flightPathAngleSp;
|
||||||
float flightPathAngle;
|
float flightPathAngle;
|
||||||
float flightPathAngleFiltered;
|
float flightPathAngleFiltered;
|
||||||
|
|||||||
Reference in New Issue
Block a user