Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5624,7 +5624,7 @@ Defines rotation rate on PITCH axis that UAV will try to archive on max. stick d

### pitot_hardware

Selection of pitot hardware.
Selection of pitot hardware. VIRTUAL only works if a GPS is enabled.

| Default | Min | Max |
| --- | --- | --- |
Expand Down
3 changes: 2 additions & 1 deletion src/main/fc/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -4142,13 +4142,14 @@ static void cliStatus(char *cmdline)
#endif // for if at32
#endif // for SITL

cliPrintLinef("Sensor status: GYRO=%s, ACC=%s, MAG=%s, BARO=%s, RANGEFINDER=%s, OPFLOW=%s, GPS=%s",
cliPrintLinef("Sensor status: GYRO=%s, ACC=%s, MAG=%s, BARO=%s, RANGEFINDER=%s, OPFLOW=%s, PITOT=%s, GPS=%s",
hardwareSensorStatusNames[getHwGyroStatus()],
hardwareSensorStatusNames[getHwAccelerometerStatus()],
hardwareSensorStatusNames[getHwCompassStatus()],
hardwareSensorStatusNames[getHwBarometerStatus()],
hardwareSensorStatusNames[getHwRangefinderStatus()],
hardwareSensorStatusNames[getHwOpticalFlowStatus()],
hardwareSensorStatusNames[getHwPitotmeterStatus()],
hardwareSensorStatusNames[getHwGPSStatus()]
);

Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ groups:
condition: USE_PITOT
members:
- name: pitot_hardware
description: "Selection of pitot hardware."
description: "Selection of pitot hardware. VIRTUAL only works if a GPS is enabled."
default_value: "NONE"
table: pitot_hardware
- name: pitot_lpf_milli_hz
Expand Down
48 changes: 25 additions & 23 deletions src/main/sensors/pitotmeter.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,15 @@ bool pitotDetect(pitotDev_t *dev, uint8_t pitotHardwareToUse)
FALLTHROUGH;

case PITOT_VIRTUAL:
#if defined(USE_WIND_ESTIMATOR) && defined(USE_PITOT_VIRTUAL)
if ((pitotHardwareToUse != PITOT_AUTODETECT) && virtualPitotDetect(dev)) {
pitotHardware = PITOT_VIRTUAL;
break;
}
#endif
/* If we are asked for a specific sensor - break out, otherwise - fall through and continue */
if (pitotHardwareToUse != PITOT_AUTODETECT) {
#if defined(USE_WIND_ESTIMATOR) && defined(USE_PITOT_VIRTUAL)
if (virtualPitotDetect(dev)) {
pitotHardware = PITOT_VIRTUAL;
break;
}
#endif
// set requested to None to prevent hardware failure if GPS not enabled
requestedSensors[SENSOR_INDEX_PITOT] = PITOT_NONE;
break;
}
FALLTHROUGH;
Expand Down Expand Up @@ -226,43 +227,44 @@ STATIC_PROTOTHREAD(pitotThread)

// Init filter
pitot.lastMeasurementUs = micros();
if(pitotmeterConfig()->pitot_lpf_milli_hz >0){
if (pitotmeterConfig()->pitot_lpf_milli_hz > 0) {
pt1FilterInit(&pitot.lpfState, pitotmeterConfig()->pitot_lpf_milli_hz / 1000.0f, 0.0f);
}

while(1) {
#ifdef USE_SIMULATOR
while (SIMULATOR_HAS_OPTION(HITL_AIRSPEED) && SIMULATOR_HAS_OPTION(HITL_PITOT_FAILURE))
{
ptDelayUs(10000);
}
#endif

if ( pitot.lastSeenHealthyMs == 0 ) {
if (pitot.lastSeenHealthyMs == 0) {
if (pitot.dev.start(&pitot.dev)) {
pitot.lastSeenHealthyMs = millis();
}
}
}

if ( (millis() - pitot.lastSeenHealthyMs) >= US2MS(pitot.dev.delay)) {
if (pitot.dev.get(&pitot.dev)) // read current data
if ((millis() - pitot.lastSeenHealthyMs) >= US2MS(pitot.dev.delay)) {
if (pitot.dev.get(&pitot.dev)) { // read current data
pitot.lastSeenHealthyMs = millis();
}

if (pitot.dev.start(&pitot.dev)) // init for next read
pitot.lastSeenHealthyMs = millis();
if (pitot.dev.start(&pitot.dev)) { // init for next read
pitot.lastSeenHealthyMs = millis();
}
}


pitot.dev.calculate(&pitot.dev, &pitotPressureTmp, &pitotTemperatureTmp);

#ifdef USE_SIMULATOR
if (SIMULATOR_HAS_OPTION(HITL_AIRSPEED)) {
pitotPressureTmp = sq(simulatorData.airSpeed) * SSL_AIR_DENSITY / 20000.0f + SSL_AIR_PRESSURE;
pitotPressureTmp = sq(simulatorData.airSpeed) * SSL_AIR_DENSITY / 20000.0f + SSL_AIR_PRESSURE;
}
#endif
#if defined(USE_PITOT_FAKE)
if (pitotmeterConfig()->pitot_hardware == PITOT_FAKE) {
pitotPressureTmp = sq(fakePitotGetAirspeed()) * SSL_AIR_DENSITY / 20000.0f + SSL_AIR_PRESSURE;
}
if (pitotmeterConfig()->pitot_hardware == PITOT_FAKE) {
pitotPressureTmp = sq(fakePitotGetAirspeed()) * SSL_AIR_DENSITY / 20000.0f + SSL_AIR_PRESSURE;
}
#endif
ptYield();

Expand All @@ -280,9 +282,9 @@ STATIC_PROTOTHREAD(pitotThread)

// NOTE ::filter pressure - apply filter when NOT calibrating for zero !!!
currentTimeUs = micros();
if(pitotmeterConfig()->pitot_lpf_milli_hz >0){
if (pitotmeterConfig()->pitot_lpf_milli_hz > 0) {
pitot.pressure = pt1FilterApply3(&pitot.lpfState, pitotPressureTmp, US2S(currentTimeUs - pitot.lastMeasurementUs));
}else{
} else {
pitot.pressure = pitotPressureTmp;
}
pitot.lastMeasurementUs = currentTimeUs;
Expand All @@ -297,7 +299,7 @@ STATIC_PROTOTHREAD(pitotThread)
}

#if defined(USE_PITOT_FAKE)
if (pitotmeterConfig()->pitot_hardware == PITOT_FAKE) {
if (pitotmeterConfig()->pitot_hardware == PITOT_FAKE) {
pitot.airSpeed = fakePitotGetAirspeed();
}
#endif
Expand Down
Loading