Repository navigation
Added covariance calculation to rs-imu-calibration.py - #14512
Merged
Merged
Conversation
|
Can one of the admins verify this patch? |
mbloechli
force-pushed
the
feature/covariance
branch
from
December 11, 2025 15:20
bc2729f to
de0f860
Compare
remibettan
reviewed
Aug 30, 2026
…tion.json Addresses review feedback on PR realsenseai#14512: - Initialize gyro=None so file mode without --gyro_file no longer NameErrors in the newly-added covariance block. - Guard against empty accel buckets and missing/malformed gyro so partial captures print a skip message instead of crashing on IndexError. - Average accel variance across all populated buckets instead of using bucket 0 only; the noise floor should be pose-independent, and this is less sensitive to a single shaky pose. - Document the still-window preconditions used by each mode (file: first ~4 s already trimmed for gyro-bias; interactive: last bucket's stability window returned by imu_wrapper.get_measurements) so a reader knows what the numbers actually represent. - Rename the print label from "Covariance (diagonal values)" to "Variance (per-axis, ...)" for consistency with the accel_var / gyro_var variable names; formatting is explicit scientific + decimal. - Serialize the noise variances into calibration.json under imus[0]["accelerometer"]["noise_variances"] and ["gyroscope"] ["noise_variances"] so downstream tooling can consume them without scraping stdout. Tracked by: RSDSO-21809
Addresses rs-agentic bot feedback on PR realsenseai#14512: The gyro guard previously accepted any 2-D non-empty `gyro`. If a file-mode CSV had a different column count (e.g. no timestamp column, or extra columns), `gyro[:, 1:]` would silently produce a wrong-width variance vector - either crashing the three-element format string with IndexError, or worse, printing values from the wrong axes. The expected shape is (N, 4) with columns [timestamp, x, y, z]: - file mode: np.loadtxt on the gyro CSV (existing convention) - interactive mode: imu_wrapper appends timestamp + xyz per sample (see imu_callback L132) Now the guard requires `shape[1] == 4` and falls through to an explicit "unexpected gyro shape ... expected (N, 4) with columns [timestamp, x, y, z]" message when the assumption is violated, distinct from the "no gyro samples available" path. Tracked by: RSDSO-21809
… call
Self-review polish, no behavior change:
- Drop redundant np.stack around np.mean(per_bucket_var, axis=0); a list
of shape-(3,) arrays already averages correctly.
- Replace a magic line-number reference ("see imu_callback L132") with
the symbolic form "imu_wrapper.imu_callback" so the comment doesn't
rot when the file changes.
- Drop PX4 from the sensor-fusion example list; PX4 doesn't typically
consume rs-imu-calibration output, and the remaining examples cover
the intended audience.
Tracked by: RSDSO-21809
remibettan
self-requested a review
August 31, 2026 10:33
remibettan
approved these changes
Aug 31, 2026
Contributor
|
ok to test |
alexkunin-gh
pushed a commit
to alexkunin-gh/librealsense
that referenced
this pull request
Sep 2, 2026
…tion.json Addresses review feedback on PR realsenseai#14512: - Initialize gyro=None so file mode without --gyro_file no longer NameErrors in the newly-added covariance block. - Guard against empty accel buckets and missing/malformed gyro so partial captures print a skip message instead of crashing on IndexError. - Average accel variance across all populated buckets instead of using bucket 0 only; the noise floor should be pose-independent, and this is less sensitive to a single shaky pose. - Document the still-window preconditions used by each mode (file: first ~4 s already trimmed for gyro-bias; interactive: last bucket's stability window returned by imu_wrapper.get_measurements) so a reader knows what the numbers actually represent. - Rename the print label from "Covariance (diagonal values)" to "Variance (per-axis, ...)" for consistency with the accel_var / gyro_var variable names; formatting is explicit scientific + decimal. - Serialize the noise variances into calibration.json under imus[0]["accelerometer"]["noise_variances"] and ["gyroscope"] ["noise_variances"] so downstream tooling can consume them without scraping stdout. Tracked by: RSDSO-21809
alexkunin-gh
pushed a commit
to alexkunin-gh/librealsense
that referenced
this pull request
Sep 2, 2026
Addresses rs-agentic bot feedback on PR realsenseai#14512: The gyro guard previously accepted any 2-D non-empty `gyro`. If a file-mode CSV had a different column count (e.g. no timestamp column, or extra columns), `gyro[:, 1:]` would silently produce a wrong-width variance vector - either crashing the three-element format string with IndexError, or worse, printing values from the wrong axes. The expected shape is (N, 4) with columns [timestamp, x, y, z]: - file mode: np.loadtxt on the gyro CSV (existing convention) - interactive mode: imu_wrapper appends timestamp + xyz per sample (see imu_callback L132) Now the guard requires `shape[1] == 4` and falls through to an explicit "unexpected gyro shape ... expected (N, 4) with columns [timestamp, x, y, z]" message when the assumption is violated, distinct from the "no gyro samples available" path. Tracked by: RSDSO-21809
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull requests adds calculation of the diagonal covariance matrix for linear acceleration and angular velocity to rs-imu-calibration.py
Closes #14511