Read and process measurements from a barometric source. More...
Public Member Functions | |
| None | __init__ (self, BarometricSourceIf sensor, *float sea_level_pressure_pa=STANDARD_SEA_LEVEL_PRESSURE_PA, int vertical_speed_window_size=8, Callable[[], float] monotonic_clock=time.monotonic) |
| Create a barometric controller. | |
| bool | is_started (self) |
| Return whether the controller and sensor are started. | |
| bool | is_available (self) |
| Return whether the configured barometric source is available. | |
| str|None | status_message (self) |
| Return an availability status message. | |
| float | sea_level_pressure_pa (self) |
| Return the current sea-level pressure reference. | |
| BarometricState|None | latest_state (self) |
| Return the most recently calculated state. | |
| None | start (self) |
| Start the barometric source and reset calculated state. | |
| None | stop (self) |
| Stop the barometric source. | |
| BarometricState | read_state (self) |
| Read the source and calculate barometric state. | |
| None | set_sea_level_pressure_pa (self, float pressure_pa) |
| Set the reference pressure used for absolute altitude. | |
| float | calibrate_altitude (self, float known_altitude_m, *float|None pressure_pa=None) |
| Calibrate sea-level pressure using a known current altitude. | |
| None | reset_relative_altitude (self) |
| Set the current altitude as the relative-altitude zero point. | |
Static Public Member Functions | |
| float | calculate_altitude_m (*float pressure_pa, float sea_level_pressure_pa) |
| Calculate barometric altitude in meters. | |
Read and process measurements from a barometric source.
The controller calculates barometric altitude, relative altitude, and filtered vertical speed from pressure measurements.
The hardware sensor remains responsible only for providing pressure and temperature values.
| None environmental.barometric_controller.BarometricController.__init__ | ( | self, | |
| BarometricSourceIf | sensor, | ||
| *float | sea_level_pressure_pa = STANDARD_SEA_LEVEL_PRESSURE_PA, |
||
| int | vertical_speed_window_size = 8, |
||
| Callable[[], float] | monotonic_clock = time.monotonic |
||
| ) |
Create a barometric controller.
Args: sensor: Controller-facing environmental sensor adapter. sea_level_pressure_pa: Reference sea-level pressure used for absolute altitude calculations. vertical_speed_window_size: Number of altitude samples used to smooth vertical-speed calculations. monotonic_clock: Clock used for elapsed-time calculations.
|
static |
Calculate barometric altitude in meters.
This uses the standard atmosphere approximation and assumes a tropospheric temperature lapse rate.
| pressure_pa | Measured atmospheric pressure in pascals. |
| sea_level_pressure_pa | Sea-level reference pressure in pascals. |
| ValueError | if either pressure is not positive. |
| float environmental.barometric_controller.BarometricController.calibrate_altitude | ( | self, | |
| float | known_altitude_m, | ||
| *float | None | pressure_pa = None |
||
| ) |
Calibrate sea-level pressure using a known current altitude.
| known_altitude_m | Known altitude above mean sea level in meters. |
| pressure_pa | Current pressure in pascals; when None, read it from the configured sensor. |
| RuntimeError | if the controller has not been started. |
| ValueError | if the selected pressure is not positive. |
Reimplemented from environmental.barometric_controller_if.BarometricControllerIf.
| BarometricState | None environmental.barometric_controller.BarometricController.latest_state | ( | self | ) |
Return the most recently calculated state.
None before the first successful read. Reimplemented from environmental.barometric_controller_if.BarometricControllerIf.
| BarometricState environmental.barometric_controller.BarometricController.read_state | ( | self | ) |
Read the source and calculate barometric state.
| RuntimeError | if the controller has not been started. |
Reimplemented from environmental.barometric_controller_if.BarometricControllerIf.
| float environmental.barometric_controller.BarometricController.sea_level_pressure_pa | ( | self | ) |
Return the current sea-level pressure reference.
Reimplemented from environmental.barometric_controller_if.BarometricControllerIf.
| None environmental.barometric_controller.BarometricController.set_sea_level_pressure_pa | ( | self, | |
| float | pressure_pa | ||
| ) |
Set the reference pressure used for absolute altitude.
| pressure_pa | Positive sea-level reference pressure in pascals. |
| ValueError | if ``pressure_pa`` is not positive. |
Reimplemented from environmental.barometric_controller_if.BarometricControllerIf.