AirspeedSelector: add synthetic airspeed option

Synthetic airspeed is calculated based on the thrust setpoint
and the thrust<->airpseed model as configured in the parameters.
This commit is contained in:
Marco Hauswirth
2025-05-02 13:37:18 +02:00
committed by Silvan Fuhrer
parent c3c863ad95
commit 5842c991ec
14 changed files with 222 additions and 56 deletions
@@ -0,0 +1,18 @@
uint32 MESSAGE_VERSION = 0
uint64 timestamp # time since system start (microseconds)
float32 indicated_airspeed_m_s # indicated airspeed in m/s (IAS), set to NAN if invalid
float32 calibrated_airspeed_m_s # calibrated airspeed in m/s (CAS, accounts for instrumentation errors), set to NAN if invalid
float32 true_airspeed_m_s # true filtered airspeed in m/s (TAS), set to NAN if invalid
float32 calibrated_ground_minus_wind_m_s # CAS calculated from groundspeed - windspeed, where windspeed is estimated based on a zero-sideslip assumption, set to NAN if invalid
float32 true_ground_minus_wind_m_s # TAS calculated from groundspeed - windspeed, where windspeed is estimated based on a zero-sideslip assumption, set to NAN if invalid
bool airspeed_sensor_measurement_valid # True if data from at least one airspeed sensor is declared valid.
int8 selected_airspeed_index # 1-3: airspeed sensor index, 0: groundspeed-windspeed, -1: airspeed invalid
float32 airspeed_derivative_filtered # filtered indicated airspeed derivative [m/s/s]
float32 throttle_filtered # filtered fixed-wing throttle [-]
float32 pitch_filtered # filtered pitch [rad]
@@ -11,3 +11,4 @@
//#include "example_translation_service_v1.h"
#include "translation_vehicle_status_v1.h"
#include "translation_airspeed_validated_v1.h"
@@ -0,0 +1,51 @@
/****************************************************************************
* Copyright (c) 2025 PX4 Development Team.
* SPDX-License-Identifier: BSD-3-Clause
****************************************************************************/
#pragma once
// Translate AirspeedValidated v0 <--> v1
#include <px4_msgs_old/msg/airspeed_validated_v0.hpp>
#include <px4_msgs/msg/airspeed_validated.hpp>
class AirspeedValidatedV1Translation {
public:
using MessageOlder = px4_msgs_old::msg::AirspeedValidatedV0;
static_assert(MessageOlder::MESSAGE_VERSION == 0);
using MessageNewer = px4_msgs::msg::AirspeedValidated;
static_assert(MessageNewer::MESSAGE_VERSION == 1);
static constexpr const char* kTopic = "fmu/out/airspeed_validated";
static void fromOlder(const MessageOlder &msg_older, MessageNewer &msg_newer) {
// Set msg_newer from msg_older
msg_newer.timestamp = msg_older.timestamp;
msg_newer.indicated_airspeed_m_s = msg_older.indicated_airspeed_m_s;
msg_newer.calibrated_airspeed_m_s = msg_older.calibrated_airspeed_m_s;
msg_newer.true_airspeed_m_s = msg_older.true_airspeed_m_s;
msg_newer.airspeed_source = msg_older.selected_airspeed_index;
msg_newer.calibrated_ground_minus_wind_m_s = msg_older.calibrated_ground_minus_wind_m_s;
msg_newer.calibraded_airspeed_synth_m_s = NAN;
msg_newer.airspeed_derivative_filtered = msg_older.airspeed_derivative_filtered;
msg_newer.throttle_filtered = msg_older.throttle_filtered;
msg_newer.pitch_filtered = msg_older.pitch_filtered;
}
static void toOlder(const MessageNewer &msg_newer, MessageOlder &msg_older) {
// Set msg_older from msg_newer
msg_older.timestamp = msg_newer.timestamp;
msg_older.indicated_airspeed_m_s = msg_newer.indicated_airspeed_m_s;
msg_older.calibrated_airspeed_m_s = msg_newer.calibrated_airspeed_m_s;
msg_older.true_airspeed_m_s = msg_newer.true_airspeed_m_s;
msg_older.calibrated_ground_minus_wind_m_s = msg_newer.calibrated_ground_minus_wind_m_s;
msg_older.true_ground_minus_wind_m_s = msg_newer.calibrated_ground_minus_wind_m_s;
msg_older.airspeed_sensor_measurement_valid = msg_newer.airspeed_source > 0 && msg_newer.airspeed_source <= 3;
msg_older.selected_airspeed_index = msg_newer.airspeed_source;
msg_older.airspeed_derivative_filtered = msg_newer.airspeed_derivative_filtered;
msg_older.throttle_filtered = msg_newer.throttle_filtered;
msg_older.pitch_filtered = msg_newer.pitch_filtered;
}
};
REGISTER_TOPIC_TRANSLATION_DIRECT(AirspeedValidatedV1Translation);
+14 -10
View File
@@ -1,18 +1,22 @@
uint32 MESSAGE_VERSION = 0
uint32 MESSAGE_VERSION = 1
uint64 timestamp # time since system start (microseconds)
float32 indicated_airspeed_m_s # indicated airspeed in m/s (IAS), set to NAN if invalid
float32 calibrated_airspeed_m_s # calibrated airspeed in m/s (CAS, accounts for instrumentation errors), set to NAN if invalid
float32 true_airspeed_m_s # true filtered airspeed in m/s (TAS), set to NAN if invalid
float32 indicated_airspeed_m_s # [m/s] Indicated airspeed (IAS), set to NAN if invalid
float32 calibrated_airspeed_m_s # [m/s] Calibrated airspeed (CAS), set to NAN if invalid
float32 true_airspeed_m_s # [m/s] True airspeed (TAS), set to NAN if invalid
int8 airspeed_source # Source of currently published airspeed values
int8 DISABLED = -1
int8 GROUND_MINUS_WIND = 0
int8 SENSOR_1 = 1
int8 SENSOR_2 = 2
int8 SENSOR_3 = 3
int8 SYNTHETIC = 4
# debug states
float32 calibrated_ground_minus_wind_m_s # CAS calculated from groundspeed - windspeed, where windspeed is estimated based on a zero-sideslip assumption, set to NAN if invalid
float32 true_ground_minus_wind_m_s # TAS calculated from groundspeed - windspeed, where windspeed is estimated based on a zero-sideslip assumption, set to NAN if invalid
bool airspeed_sensor_measurement_valid # True if data from at least one airspeed sensor is declared valid.
int8 selected_airspeed_index # 1-3: airspeed sensor index, 0: groundspeed-windspeed, -1: airspeed invalid
float32 calibraded_airspeed_synth_m_s # synthetic airspeed in m/s, set to NAN if invalid
float32 airspeed_derivative_filtered # filtered indicated airspeed derivative [m/s/s]
float32 throttle_filtered # filtered fixed-wing throttle [-]
float32 pitch_filtered # filtered pitch [rad]