Skip to content

Reject negative sigma values in noise model constructors#2465

Merged
dellaert merged 1 commit intoborglab:developfrom
jashshah999:fix/negative-sigma-validation
Mar 12, 2026
Merged

Reject negative sigma values in noise model constructors#2465
dellaert merged 1 commit intoborglab:developfrom
jashshah999:fix/negative-sigma-validation

Conversation

@jashshah999
Copy link
Copy Markdown
Contributor

Summary

Creating a noise model with negative sigma values (e.g., noiseModel::Isotropic::Sigma(2, -2.0)) was silently accepted, producing a nonsensical noise model that behaves as a "repulsion" factor.

Added validation checks that throw std::invalid_argument for negative values in:

  • Diagonal constructor (catches all diagonal-based models)
  • Isotropic::Sigma
  • Isotropic::Variance

Added unit test NegativeSigmaThrows to verify.

Fixes #695

Negative sigma values were silently accepted, producing nonsensical
noise models. Add validation checks in Diagonal constructor,
Isotropic::Sigma, and Isotropic::Variance to throw
std::invalid_argument for negative values.

Fixes borglab#695
Copy link
Copy Markdown
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@dellaert dellaert merged commit e474862 into borglab:develop Mar 12, 2026
34 of 36 checks passed
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.

Negative sigmas in noise models: bug or feature?

2 participants