Skip to content

Conversation

AWheats
Copy link
Contributor

@AWheats AWheats commented Mar 2, 2025

Solved Problem

If pressure tubes for static/dynamic pressure are not accessible without disassembling the aircraft, it may be preferable to users to set a parameter rather than redo the pipe routing. This change enables this to happen for all supported pressure sensors by setting SENS_DIFF_PRES_REV to 1.

Changelog Entry

For release notes:

New parameter: SENS_DIFF_PRES_REV
Documentation: Need to amend airspeed calibration to state that SENS_DIFF_PRES_REV can be used: https://docs.px4.io/main/en/config/airspeed.html#airspeed-calibration

Alternatives

Could change the UORB message itself rather than the sensors, but this would require changing both the publish and the subscribe functions.

Test coverage

  • Unit/integration test:
  • Tested on SITL to check parameter appears in param list and is stored in non volatile
  • Tested on Pixhawk 6X hardware with DroneCAN airspeed sensor (matek digital airspeed sensor ASPD-DLVR) to check parameter behaves as required; if SENS_DIFF_PRES_REV is set to anything other than 1, then airspeed calibration fails and negative values for airspeed are will be used when differential pressure is applied. If SENS_DIFF_PRES_REV is set, then airspeed calibration passes and only positive values will be seen when applying differential pressure (except for offsets below zero)

AWheats added 3 commits March 2, 2025 15:36
Allow negative values of differential pressure to be used by converting them to absolute values if SENS_DIFF_PRESS_ABS is set to 1. Allows users to fly an aircraft where static and pitot pipes aren't installed correctly but are no longer accessible
@AWheats AWheats marked this pull request as ready for review March 4, 2025 07:24
Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also automatically detect and change the parameter during airspeed calibration by checking the sign instead of asking the user to swap the tubes, right?

@AWheats
Copy link
Contributor Author

AWheats commented Mar 5, 2025

We could also automatically detect and change the parameter during airspeed calibration by checking the sign instead of asking the user to swap the tubes, right?

We can change the code to do it automatically, yes, but I'd be worried about it taking the choice away from the user.

If users want to reverse the tubes, then it doesn't matter if the swap is automatic or manual via a parameter, because they'll want to do it anyway.

However if users don't want to reverse the tubes, the only time they will know there is an issue is during airspeed cal, where we'll send them a message stating negative differential pressure and the parameter has been set to 1 (unless we flash a periodic message?)

Having a negative value of differential pressure may mean the tubes are connected the wrong way, but it could also mean a tube has come loose in flight, which could have dangerous results for different aircraft if airspeed starts messing with the EKF. By having it as a parameter that the user has to manually enable, the user is accepting this risk - the parameter text (I hope) also makes this clear. Therefore I'd rather keep the parameter as a manually set value so that the user has to consciously accept the risk.

Do you still want me to make the change?

@AWheats AWheats requested a review from bresch March 6, 2025 07:18
@bresch
Copy link
Member

bresch commented Mar 6, 2025

Ok, fair enough.

BTW, why taking the absolute value rather than adding a minus sign? If the tubes are swapped, you also don't want to use the "raw positive values", right?

@AWheats
Copy link
Contributor Author

AWheats commented Mar 6, 2025 via email

@bresch
Copy link
Member

bresch commented Mar 6, 2025

I was worried about the value flip flopping between cycles

It's just about changing the sign of the measurement, we're not changing the sign of a member variable at every iteration.

it was safer to just use the absolute value

But you also just said about automatically changing the sign that "it could also mean a tube has come loose in flight, which could have dangerous results for different aircraft if airspeed starts messing with the EKF". By taking the absolute value we exactly do this.

@AWheats
Copy link
Contributor Author

AWheats commented Mar 7, 2025

I was worried about the value flip flopping between cycles

It's just about changing the sign of the measurement, we're not changing the sign of a member variable at every iteration.

it was safer to just use the absolute value

But you also just said about automatically changing the sign that "it could also mean a tube has come loose in flight, which could have dangerous results for different aircraft if airspeed starts messing with the EKF". By taking the absolute value we exactly do this.

Fair point, I'll make the change to use the negative sign then, standby :)

@AWheats
Copy link
Contributor Author

AWheats commented Mar 8, 2025

Change has been made but now it seems to have a merge conflict with another change, can't figure out how to resolve it because every time I try to push git says everything up to date

@bresch
Copy link
Member

bresch commented Mar 10, 2025

@NotAWalrus You probably added all your changes with git add . while having local changes on mavlink and gazebo (or submodules that where not up to date).

You can undo your last commit with git reset HEAD^, then stage each hunk of code using git add -p (do not add the submodule changes). Then commit and force push (git push -f origin pr-addabsolutediffpres).

@AWheats AWheats force-pushed the pr-addabsolutediffpres branch from b9fc27d to 28872d7 Compare March 11, 2025 07:55
@bresch
Copy link
Member

bresch commented Mar 11, 2025

@NotAWalrus I think you forgot to commit the last changes (after you staged them with git add -p you need to git commit, then push)

Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"inverse" is 1/value, let's rather call it "reverse", no?

Also, it's probably cleaner to have a single implementation in sensors.cpp rather than in each and every driver.

… pressure functionality in drivers, because if the functionality is moved to sensors.cpp, airspeed calibration and mavlink inspector must also be modified, as these read the differential pressure UORB message.

Kept the internal param_get type as int32_t, because param_get does not support boolean types.
@AWheats AWheats requested a review from bresch March 18, 2025 07:12
Copy link
Member

@bresch bresch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You didn't push your latest changes

@AWheats AWheats force-pushed the pr-addabsolutediffpres branch from 00727db to e3943a5 Compare March 18, 2025 18:35
@AWheats
Copy link
Contributor Author

AWheats commented Mar 18, 2025

You didn't push your latest changes

Sorry, my bad, still getting used to git/github as I'm sure you can tell. I've pushed them now, tested the code, the last issue seems to be with the automated code testing? Any tips for how to resolve please?

@AWheats AWheats requested a review from bresch March 18, 2025 18:56
@bresch
Copy link
Member

bresch commented Mar 19, 2025

the last issue seems to be with the automated code testing? Any tips for how to resolve please?

The SITL test for standard_vtol is under maintenance, the failing check is not related to your PR, we can ignore it.

@AWheats AWheats requested a review from bresch March 20, 2025 07:39
@bresch bresch merged commit ca2ed65 into PX4:main Mar 24, 2025
58 of 59 checks passed
@dagar
Copy link
Member

dagar commented Aug 12, 2025

This should have been done alongside SENS_DPRES_OFF rather than in every individual driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants