mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 07:33:34 +08:00
Added PerformanceModel for fixed wing (#22091)
* created a Performance Model for fixed wing vehicle - added compensation for maximum climbrate, minimum sinkrate, minimum airspeed and trim airspeed based on weight ratio and air density - added atmosphere lib to standard atmosphere calculations --------- Signed-off-by: RomanBapst <bapstroman@gmail.com> Co-authored-by: Thomas Stastny <thomas.stastny@auterion.com>
This commit is contained in:
co-authored by
Thomas Stastny
parent
70cd224236
commit
dd2322d622
@@ -44,6 +44,7 @@
|
||||
*/
|
||||
|
||||
#include "batt_smbus.h"
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
extern "C" __EXPORT int batt_smbus_main(int argc, char *argv[]);
|
||||
|
||||
@@ -160,7 +161,7 @@ void BATT_SMBUS::RunImpl()
|
||||
|
||||
// Read battery temperature and covert to Celsius.
|
||||
ret |= _interface->read_word(BATT_SMBUS_TEMP, result);
|
||||
new_report.temperature = ((float)result / 10.0f) + CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
new_report.temperature = ((float)result / 10.0f) + atmosphere::kAbsoluteNullCelsius;
|
||||
|
||||
// Only publish if no errors.
|
||||
if (ret == PX4_OK) {
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "batmon.h"
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
extern "C" __EXPORT int batmon_main(int argc, char *argv[]);
|
||||
|
||||
@@ -186,7 +187,7 @@ void Batmon::RunImpl()
|
||||
|
||||
// Read battery temperature and covert to Celsius.
|
||||
ret |= _interface->read_word(BATT_SMBUS_TEMP, result);
|
||||
new_report.temperature = ((float)result / 10.0f) + CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
new_report.temperature = ((float)result / 10.0f) + atmosphere::kAbsoluteNullCelsius;
|
||||
|
||||
// Only publish if no errors.
|
||||
if (ret == PX4_OK) {
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include "airspeed.hpp"
|
||||
#include <math.h>
|
||||
#include <lib/geo/geo.h> // For CONSTANTS_*
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
const char *const UavcanAirspeedBridge::NAME = "airspeed";
|
||||
|
||||
@@ -104,7 +104,7 @@ UavcanAirspeedBridge::ias_sub_cb(const
|
||||
report.timestamp = hrt_absolute_time();
|
||||
report.indicated_airspeed_m_s = msg.indicated_airspeed;
|
||||
report.true_airspeed_m_s = _last_tas_m_s;
|
||||
report.air_temperature_celsius = _last_outside_air_temp_k + CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
report.air_temperature_celsius = _last_outside_air_temp_k + atmosphere::kAbsoluteNullCelsius;
|
||||
|
||||
publish(msg.getSrcNodeID().get(), &report);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
#include <uORB/PublicationMulti.hpp>
|
||||
#include <uORB/topics/sensor_baro.h>
|
||||
#include <lib/geo/geo.h> // For CONSTANTS_*
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
const char *const UavcanBarometerBridge::NAME = "baro";
|
||||
|
||||
@@ -78,10 +78,10 @@ void UavcanBarometerBridge::air_temperature_sub_cb(const
|
||||
|
||||
} else if (msg.static_temperature < 0) {
|
||||
// handle previous incorrect temperature conversion to Kelvin where 273 was subtracted instead of added (https://github.com/PX4/PX4-Autopilot/pull/19061)
|
||||
float temperature_c = msg.static_temperature - CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
float temperature_c = msg.static_temperature - atmosphere::kAbsoluteNullCelsius;
|
||||
|
||||
if (temperature_c > -40.f && temperature_c < 120.f) {
|
||||
_last_temperature_kelvin = temperature_c - CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
_last_temperature_kelvin = temperature_c - atmosphere::kAbsoluteNullCelsius;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void UavcanBarometerBridge::air_pressure_sub_cb(const
|
||||
sensor_baro.pressure = msg.static_pressure;
|
||||
|
||||
if (PX4_ISFINITE(_last_temperature_kelvin) && (_last_temperature_kelvin >= 0.f)) {
|
||||
sensor_baro.temperature = _last_temperature_kelvin + CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
sensor_baro.temperature = _last_temperature_kelvin + atmosphere::kAbsoluteNullCelsius;
|
||||
|
||||
} else {
|
||||
sensor_baro.temperature = NAN;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "battery.hpp"
|
||||
|
||||
#include <lib/geo/geo.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
#include <px4_defines.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
|
||||
@@ -116,7 +116,7 @@ UavcanBatteryBridge::battery_sub_cb(const uavcan::ReceivedDataStructure<uavcan::
|
||||
|
||||
_battery_status[instance].remaining = msg.state_of_charge_pct / 100.0f; // between 0 and 1
|
||||
// _battery_status[instance].scale = msg.; // Power scaling factor, >= 1, or -1 if unknown
|
||||
_battery_status[instance].temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS; // Kelvin to Celsius
|
||||
_battery_status[instance].temperature = msg.temperature + atmosphere::kAbsoluteNullCelsius; // Kelvin to Celsius
|
||||
// _battery_status[instance].cell_count = msg.;
|
||||
_battery_status[instance].connected = true;
|
||||
_battery_status[instance].source = msg.status_flags & uavcan::equipment::power::BatteryInfo::STATUS_FLAG_IN_USE;
|
||||
@@ -239,7 +239,7 @@ UavcanBatteryBridge::filterData(const uavcan::ReceivedDataStructure<uavcan::equi
|
||||
|
||||
/* Override data that is expected to arrive from UAVCAN msg*/
|
||||
_battery_status[instance] = _battery[instance]->getBatteryStatus();
|
||||
_battery_status[instance].temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS; // Kelvin to Celsius
|
||||
_battery_status[instance].temperature = msg.temperature + atmosphere::kAbsoluteNullCelsius; // Kelvin to Celsius
|
||||
_battery_status[instance].serial_number = msg.model_instance_id;
|
||||
_battery_status[instance].id = msg.getSrcNodeID().get(); // overwrite zeroed index from _battery
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "differential_pressure.hpp"
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/geo/geo.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
#include <parameters/param.h>
|
||||
#include <systemlib/err.h>
|
||||
|
||||
@@ -71,7 +71,7 @@ void UavcanDifferentialPressureBridge::air_sub_cb(const
|
||||
_device_id.devid_s.address = msg.getSrcNodeID().get() & 0xFF;
|
||||
|
||||
float diff_press_pa = msg.differential_pressure;
|
||||
float temperature_c = msg.static_air_temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
float temperature_c = msg.static_air_temperature + atmosphere::kAbsoluteNullCelsius;
|
||||
|
||||
differential_pressure_s report{};
|
||||
report.timestamp_sample = timestamp_sample;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "hygrometer.hpp"
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <lib/geo/geo.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
const char *const UavcanHygrometerBridge::NAME = "hygrometer_sensor";
|
||||
|
||||
@@ -65,7 +65,7 @@ void UavcanHygrometerBridge::hygro_sub_cb(const uavcan::ReceivedDataStructure<dr
|
||||
sensor_hygrometer_s report{};
|
||||
report.timestamp_sample = timestamp_sample;
|
||||
report.device_id = 0; // TODO
|
||||
report.temperature = msg.temperature + CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
report.temperature = msg.temperature + atmosphere::kAbsoluteNullCelsius;
|
||||
report.humidity = msg.humidity;
|
||||
report.timestamp = hrt_absolute_time();
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <uORB/SubscriptionCallback.hpp>
|
||||
#include <uORB/topics/battery_status.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
namespace uavcannode
|
||||
{
|
||||
@@ -76,7 +77,7 @@ public:
|
||||
uavcan::equipment::power::BatteryInfo battery_info{};
|
||||
battery_info.voltage = battery.voltage_v;
|
||||
battery_info.current = fabs(battery.current_a);
|
||||
battery_info.temperature = battery.temperature - CONSTANTS_ABSOLUTE_NULL_CELSIUS; // convert from C to K
|
||||
battery_info.temperature = battery.temperature - atmosphere::kAbsoluteNullCelsius; // convert from C to K
|
||||
battery_info.full_charge_capacity_wh = battery.capacity;
|
||||
battery_info.remaining_capacity_wh = battery.remaining * battery.capacity;
|
||||
battery_info.state_of_charge_pct = battery.remaining * 100;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <uORB/SubscriptionCallback.hpp>
|
||||
#include <uORB/topics/differential_pressure.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
namespace uavcannode
|
||||
{
|
||||
@@ -78,8 +79,8 @@ public:
|
||||
// raw_air_data.static_pressure =
|
||||
raw_air_data.differential_pressure = diff_press.differential_pressure_pa;
|
||||
// raw_air_data.static_pressure_sensor_temperature =
|
||||
raw_air_data.differential_pressure_sensor_temperature = diff_press.temperature - CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
raw_air_data.static_air_temperature = diff_press.temperature - CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
raw_air_data.differential_pressure_sensor_temperature = diff_press.temperature - atmosphere::kAbsoluteNullCelsius;
|
||||
raw_air_data.static_air_temperature = diff_press.temperature - atmosphere::kAbsoluteNullCelsius;
|
||||
// raw_air_data.pitot_temperature
|
||||
// raw_air_data.covariance
|
||||
uavcan::Publisher<uavcan::equipment::air_data::RawAirData>::broadcast(raw_air_data);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <uORB/SubscriptionCallback.hpp>
|
||||
#include <uORB/topics/sensor_baro.h>
|
||||
#include <lib/atmosphere/atmosphere.h>
|
||||
|
||||
namespace uavcannode
|
||||
{
|
||||
@@ -74,7 +75,7 @@ public:
|
||||
|
||||
if ((hrt_elapsed_time(&_last_static_temperature_publish) > 1_s) && uORB::SubscriptionCallbackWorkItem::update(&baro)) {
|
||||
uavcan::equipment::air_data::StaticTemperature static_temperature{};
|
||||
static_temperature.static_temperature = baro.temperature - CONSTANTS_ABSOLUTE_NULL_CELSIUS;
|
||||
static_temperature.static_temperature = baro.temperature - atmosphere::kAbsoluteNullCelsius;
|
||||
uavcan::Publisher<uavcan::equipment::air_data::StaticTemperature>::broadcast(static_temperature);
|
||||
|
||||
// ensure callback is registered
|
||||
|
||||
Reference in New Issue
Block a user