Skip to content

feat(sensors): log the gyro filter state for tuning analysis - #29064

Draft
isak-aslund wants to merge 4 commits into
PX4:mainfrom
isak-aslund:feat/gyro-notch-logging
Draft

isak-aslund wants to merge 4 commits into
PX4:mainfrom
isak-aslund:feat/gyro-notch-logging

Conversation

@isak-aslund

@isak-aslund isak-aslund commented Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

A PX4 log doesn't show where the dynamic notch filters were during a flight. Notches are parked at IMU_GYRO_DNF_MIN when RPM is low or missing, only one is updated per axis per cycle, and harmonics above Nyquist are disabled, so the position can't be rebuilt reliably from esc_status. This PR publishes the applied filter state so a log shows whether the notches sit on the motor noise. It's the PX4 part of RFC #29065; the Flight Review side is PX4/flight_review#349.

  • New topic gyro_filter_status, published by VehicleAngularVelocity at 100 Hz, with only what changes at runtime: every RPM notch frequency (per harmonic and ESC, X axis; PX4 applies the same RPM notches to all axes) and the FFT notch frequencies per axis. Notch widths, cutoffs and static notches are parameters, and the gyro and its rate are in sensor_selection and vehicle_imu_status, so they aren't repeated. Left out on CONSTRAINED_FLASH builds; about 1 KB flash on fmu-v6x.
  • Logged in the existing high-rate profile (SDLOG_PROFILE bit 4), one add_optional_topic line, with a note in the filter tuning docs.
  • SIH_GYRO_VIB / SIH_ACCEL_VIB add vibration at each motor's frequency and two harmonics to the SIH IMU, so the filters can be tested in SITL. Both default to 0.

Tested in SITL with the SIH quadrotor (1 kHz gyro, RPM and FFT notches, simulated vibration, offboard throttle sweep and per-axis excitation). Builds for px4_fmu-v6x and px4_sitl. Not yet flown on hardware.

Angular velocity spectrogram in Flight Review with the new data, same colour scale: gyro before filtering (left), with the notches over time (middle), after filtering (right):

Spectrogram before filtering, with notches, after filtering


Created on behalf of Isak Åslund with Claude (Claude Code): filter state topic, logging, SIH vibration, SITL testing and write-up.

The log shows the motor RPM and the gyro FFT peaks, but not where the dynamic notch filters actually are: notches are parked at the minimum frequency, only one is updated per cycle and harmonics above Nyquist are disabled. gyro_filter_status publishes the applied filter chain at 100 Hz so a log can show whether the notches sit on the noise. Left out on CONSTRAINED_FLASH builds.

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
The high-rate profile already logs the filtered gyro, the rate controller and the ESC RPM for filter and rate tuning; the raw gyro comes from the gyro FIFO profile.

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
SIH_GYRO_VIB and SIH_ACCEL_VIB add vibration at each motor's frequency and two harmonics, growing with rpm squared, so the gyro filters can be tested in SITL. Both default to 0.

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
@github-actions github-actions Bot added kind:feature Request or change that adds new functionality. scope:sensors Sensor pipeline, calibration, voting, or sensor validation. labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Flash and RAM Analysis

Target Flash Δ Flash Total Static RAM Δ Static RAM Total
px4_fmu-v2 (F4) 🟡 +136 B (+0.01%) 99.13% +0 B (+0.00%) 10.18%
px4_fmu-v5x (F7) 🔴 +1,616 B (+0.08%) 98.25% +8 B (+0.01%) 21.92%
px4_fmu-v6x (H7) 🟡 +464 B (+0.02%) 99.23% +0 B (+0.00%) 10.58%
px4_fmu-v2 — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  +0.0%    +136    .text
    +0.3%     +72    uORB::compressed_fields
    +0.0%     +20    [section .text]
    [NEW]     +16    __orb_gyro_filter_status
    +6.6%     +16    px4::logger::LoggedTopics::add_high_rate_topics()
     +50%      +4    Zero
     +20%      +4    get_orb_meta()
    +7.7%      +4    uORB::Subscription::subscribe()
    +0.3%      +4    uorb_topics_list
    +4.2%      +2    uORB::DeviceMaster::deviceNodeExists()
    -3.2%      -2    uORB::DeviceMaster::getDeviceNode()
   -30.8%      -4    g_nullstring
  +0.0%    +136    TOTAL

px4_fmu-v5x — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  +0.1% +1.57Ki    .text
    [NEW]    +648    Sih::update_motor_vibration()
    [NEW]    +244    sensors::VehicleAngularVelocity::PublishFilterStatus()
    +0.1%    +236    g_cromfs_image
    +0.1%     +88    [section .text]
    +3.3%     +84    Sih::Sih()
     +12%     +68    Sih::reconstruct_sensors_signals()
    +0.3%     +64    uORB::compressed_fields
   -99.1%     +32    [14 Others]
    +5.2%     +28    Sih::updateParamsImpl()
    +3.6%     +28    sensors::VehicleAngularVelocity::VehicleAngularVelocity()
    +6.8%     +20    px4::logger::LoggedTopics::add_high_rate_topics()
    +0.7%     +16    Sih::parameters_updated()
    [NEW]     +16    __orb_gyro_filter_status
    +0.1%     +16    px4::parameters
    [NEW]      +8    CSWTCH.182
    +2.0%      +8    sensors::VehicleAngularVelocity::CalibrateAndPublish()
    +2.5%      +8    sensors::VehicleAngularVelocity::~VehicleAngularVelocity()
    +1.9%      +4    FieldSensorBiasEstimator::updateEstimate()
    +4.8%      +4    FlightTask
    -0.4%      -4    AeroSeg::update_aero()
    [DEL]      -8    CSWTCH.180
  +0.1%      +8    .ramfunc
    [NEW]      +8    ___ZNK3px412AtomicBitsetILj1934EEixEj_veneer
    +1.2%      +4    Ekf::measurementUpdate()
     +20%      +4    get_orb_meta()
     +14%      +1    __stm32_i2c_set_bytes_to_transfer_veneer
   -12.5%      -1    __nxsched_gettid_veneer
    [DEL]      -8    ___ZNK3px412AtomicBitsetILj1932EEixEj_veneer
  +0.1% +1.58Ki    TOTAL

px4_fmu-v6x — Bloaty section/symbol breakdown
     VM SIZE    
 -------------- 
  +0.0%    +464    .text
    [NEW]    +244    sensors::VehicleAngularVelocity::PublishFilterStatus()
    +0.3%     +64    uORB::compressed_fields
    +0.0%     +36    [section .text]
    +3.6%     +28    sensors::VehicleAngularVelocity::VehicleAngularVelocity()
    +6.8%     +20    px4::logger::LoggedTopics::add_high_rate_topics()
    [NEW]     +16    __orb_gyro_filter_status
   -99.2%     +12    [3 Others]
    +5.7%      +8    MagnetometerChecks::MagnetometerChecks()
    +2.0%      +8    sensors::VehicleAngularVelocity::CalibrateAndPublish()
    +2.5%      +8    sensors::VehicleAngularVelocity::~VehicleAngularVelocity()
    +1.9%      +4    FieldSensorBiasEstimator::updateEstimate()
     +50%      +4    Zero
     +20%      +4    get_orb_meta()
    +2.5%      +4    px4::logger::Logger::handle_vehicle_command_update()
    +3.2%      +4    sensors::VehicleAngularVelocity::SensorBiasUpdate()
    +3.3%      +4    uORB::Manager::orb_device_node_exists()
    +3.0%      +4    uORB::Subscription::Subscription()
    +5.0%      +4    uORB::Subscription::copy()
    -1.1%      -4    GnssChecks::run()
   -30.8%      -4    g_nullstring
    -0.5%      -4    px4::logger::Logger::write_formats()
  +0.0%    +464    TOTAL

Updated: 2026-10-09T23:37:25

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

No broken links found in changed files.

…status

The filter cutoffs, notch bandwidths and static notches are parameters, the gyro and its rate are in sensor_selection and vehicle_imu_status, and the FFT notch width follows from sensor_gyro_fft, all already logged. Only the notch frequencies change at runtime.

Signed-off-by: Isak Åslund <isak.aslund@airolit.com>
@dakejahl

dakejahl commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

I don't think we should publish the message at 100Hz by default, I'd put it behind a parameter. Since you're really only going to be doing this during testing, on an already tuned vehicle it's an unnecessary burden

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

Labels

kind:feature Request or change that adds new functionality. scope:sensors Sensor pipeline, calibration, voting, or sensor validation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants