Allow negative differential pressure if parameter enabled (#24434)
Build all targets / Scan for Board Targets (push) Waiting to run
Build all targets / Build Group [${{ matrix.group }}] (push) Blocked by required conditions
Build all targets / Upload Artifacts to S3 (push) Blocked by required conditions
Build all targets / Create Release and Upload Artifacts (push) Blocked by required conditions
Checks / build (NO_NINJA_BUILD=1 px4_fmu-v5_default) (push) Waiting to run
Checks / build (NO_NINJA_BUILD=1 px4_sitl_default) (push) Waiting to run
Checks / build (check_format) (push) Waiting to run
Checks / build (check_newlines) (push) Waiting to run
Checks / build (module_documentation) (push) Waiting to run
Checks / build (px4_fmu-v2_default stack_check) (push) Waiting to run
Checks / build (px4_sitl_allyes) (push) Waiting to run
Checks / build (shellcheck_all) (push) Waiting to run
Checks / build (tests) (push) Waiting to run
Checks / build (tests_coverage) (push) Waiting to run
Checks / build (validate_module_configs) (push) Waiting to run
Clang Tidy / build (push) Waiting to run
MacOS build / build (px4_fmu-v5_default) (push) Waiting to run
MacOS build / build (px4_sitl) (push) Waiting to run
Ubuntu environment build / Build and Test (ubuntu:22.04) (push) Waiting to run
Ubuntu environment build / Build and Test (ubuntu:24.04) (push) Waiting to run
Container build / Build and Push Container (push) Waiting to run
EKF Update Change Indicator / unit_tests (push) Waiting to run
Failsafe Simulator Build / build (failsafe_web) (push) Waiting to run
FLASH usage analysis / Analyzing px4_fmu-v5x (push) Waiting to run
FLASH usage analysis / Analyzing px4_fmu-v6x (push) Waiting to run
MAVROS Mission Tests / build (map[mission:MC_mission_box vehicle:iris]) (push) Waiting to run
MAVROS Mission Tests / build (map[mission:rover_mission_1 vehicle:rover]) (push) Waiting to run
MAVROS Offboard Tests / build (map[test_file:mavros_posix_tests_offboard_posctl.test vehicle:iris]) (push) Waiting to run
Nuttx Target with extra env config / build (px4_fmu-v5_default) (push) Waiting to run
Python CI Checks / build (push) Waiting to run
ROS Translation Node Tests / Build and test (map[ros_version:humble ubuntu:jammy]) (push) Waiting to run
ROS Translation Node Tests / Build and test (map[ros_version:jazzy ubuntu:noble]) (push) Waiting to run
SITL Tests / Testing PX4 tailsitter (push) Waiting to run
SITL Tests / Testing PX4 iris (push) Waiting to run
SITL Tests / Testing PX4 standard_vtol (push) Waiting to run

This commit is contained in:
Andy Wheatley
2025-03-24 08:42:36 +00:00
committed by GitHub
parent fdebdc447d
commit ca2ed655b8
10 changed files with 85 additions and 2 deletions
@@ -40,6 +40,7 @@
*/
#include "ASP5033.hpp"
#include <parameters/param.h>
ASP5033::ASP5033(const I2CSPIDriverConfig &config) :
I2C(config),
@@ -232,6 +233,15 @@ int ASP5033::collect()
differential_pressure.timestamp_sample = timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = _pressure;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * _pressure;
}
differential_pressure.temperature = _temperature ;
differential_pressure.error_count = perf_event_count(_comms_errors);
differential_pressure.timestamp = timestamp_sample;
@@ -32,6 +32,7 @@
****************************************************************************/
#include "AUAV_Differential.hpp"
#include <parameters/param.h>
AUAV_Differential::AUAV_Differential(const I2CSPIDriverConfig &config) :
AUAV(config)
@@ -46,6 +47,14 @@ void AUAV_Differential::publish_pressure(const float pressure_p, const float tem
differential_pressure.timestamp_sample = timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = pressure_p;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * pressure_p;
}
differential_pressure.temperature = temperature_c;
differential_pressure.error_count = perf_event_count(_comms_errors);
_differential_pressure_pub.publish(differential_pressure);
@@ -32,6 +32,7 @@
****************************************************************************/
#include "ETSAirspeed.hpp"
#include <parameters/param.h>
ETSAirspeed::ETSAirspeed(const I2CSPIDriverConfig &config) :
I2C(config),
@@ -113,6 +114,14 @@ int ETSAirspeed::collect()
differential_pressure.timestamp_sample = timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = diff_press_pa;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * diff_press_pa;
}
differential_pressure.temperature = NAN;
differential_pressure.error_count = perf_event_count(_comms_errors);
differential_pressure.timestamp = hrt_absolute_time();
@@ -32,6 +32,7 @@
****************************************************************************/
#include "MS4515.hpp"
#include <parameters/param.h>
MS4515::MS4515(const I2CSPIDriverConfig &config) :
I2C(config),
@@ -163,6 +164,14 @@ int MS4515::collect()
differential_pressure.timestamp_sample = timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = diff_press_pa;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * diff_press_pa;
}
differential_pressure.temperature = temperature_c;
differential_pressure.error_count = perf_event_count(_comms_errors);
differential_pressure.timestamp = hrt_absolute_time();
@@ -32,6 +32,7 @@
****************************************************************************/
#include "MS4525DO.hpp"
#include <parameters/param.h>
using namespace time_literals;
@@ -200,6 +201,14 @@ void MS4525DO::RunImpl()
differential_pressure.timestamp_sample = _timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = diff_press_pa;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * diff_press_pa;
}
differential_pressure.temperature = temperature_c;
differential_pressure.error_count = perf_event_count(_comms_errors);
differential_pressure.timestamp = hrt_absolute_time();
@@ -32,6 +32,7 @@
****************************************************************************/
#include "MS5525DSO.hpp"
#include <parameters/param.h>
MS5525DSO::MS5525DSO(const I2CSPIDriverConfig &config) :
I2C(config),
@@ -308,6 +309,14 @@ int MS5525DSO::collect()
differential_pressure.timestamp_sample = timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = diff_press_pa;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * diff_press_pa;
}
differential_pressure.temperature = temperature_c;
differential_pressure.error_count = perf_event_count(_comms_errors);
differential_pressure.timestamp = hrt_absolute_time();
@@ -32,6 +32,7 @@
****************************************************************************/
#include "SDP3X.hpp"
#include <parameters/param.h>
using namespace time_literals;
@@ -187,6 +188,14 @@ int SDP3X::collect()
differential_pressure.timestamp_sample = timestamp_sample;
differential_pressure.device_id = get_device_id();
differential_pressure.differential_pressure_pa = diff_press_pa;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
differential_pressure.differential_pressure_pa = -1.0f * diff_press_pa;
}
differential_pressure.temperature = temperature_c;
differential_pressure.error_count = perf_event_count(_comms_errors);
differential_pressure.timestamp = hrt_absolute_time();
@@ -69,8 +69,15 @@ void UavcanDifferentialPressureBridge::air_sub_cb(const
_device_id.devid_s.devtype = DRV_DIFF_PRESS_DEVTYPE_UAVCAN;
_device_id.devid_s.address = msg.getSrcNodeID().get() & 0xFF;
float diff_press_pa = msg.differential_pressure;
int32_t differential_press_rev = 0;
param_get(param_find("SENS_DPRES_REV"), &differential_press_rev);
//If differential pressure reverse param set, swap positive and negative
if (differential_press_rev == 1) {
diff_press_pa = -1.0f * msg.differential_pressure;
}
float temperature_c = msg.static_air_temperature + atmosphere::kAbsoluteNullCelsius;
differential_pressure_s report{};
@@ -168,7 +168,7 @@ int do_airspeed_calibration(orb_advert_t *mavlink_log_pub)
/* do not allow negative values */
calibration_log_critical(mavlink_log_pub, "[cal] Negative pressure difference detected (%d Pa)",
(int)differential_pressure_pa);
calibration_log_critical(mavlink_log_pub, "[cal] Swap static and dynamic ports!");
calibration_log_critical(mavlink_log_pub, "[cal] Swap static and dynamic ports or set SENS_DPRES_REV");
/* the user setup is wrong, wipe the calibration to force a proper re-calibration */
diff_pres_offset = 0.0f;
+12
View File
@@ -87,6 +87,18 @@ PARAM_DEFINE_FLOAT(CAL_AIR_TUBED_MM, 1.5f);
*/
PARAM_DEFINE_FLOAT(SENS_DPRES_OFF, 0.0f);
/**
* Reverse differential pressure sensor readings
*
* Reverse the raw measurements of all differential pressure sensors.
* This can be enabled if the sensors have static and dynamic ports swapped.
*
* @category system
* @group Sensor Calibration
* @boolean
*/
PARAM_DEFINE_INT32(SENS_DPRES_REV, 0);
/**
* Differential pressure sensor analog scaling
*