GaussianNoiseModel: avoid calling DblNormal with invalid standard deviation#396
Merged
iche033 merged 2 commits intogazebosim:mainfrom Oct 27, 2023
oysstu:fix/gaussian_noise_zero_stddev
Merged
GaussianNoiseModel: avoid calling DblNormal with invalid standard deviation#396iche033 merged 2 commits intogazebosim:mainfrom oysstu:fix/gaussian_noise_zero_stddev
iche033 merged 2 commits intogazebosim:mainfrom
oysstu:fix/gaussian_noise_zero_stddev
Conversation
Signed-off-by: Øystein Sture <os@skarvtech.com>
Codecov Report
@@ Coverage Diff @@
## main #396 +/- ##
==========================================
+ Coverage 72.34% 72.36% +0.01%
==========================================
Files 37 37
Lines 5052 5055 +3
==========================================
+ Hits 3655 3658 +3
Misses 1397 1397
|
Contributor
|
changes look good to me. @scpeters, Perhaps we should add a check in gz::math::Rand::DblNormal to make sure standard deviations are greater than 0? As pointed out in https://stackoverflow.com/a/9186515: explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0);
Requires: 0 < stddev. |
mjcarroll
approved these changes
Oct 23, 2023
iche033
approved these changes
Oct 27, 2023
azeey
pushed a commit
that referenced
this pull request
Mar 15, 2024
Signed-off-by: Øystein Sture <os@skarvtech.com> Co-authored-by: Michael Carroll <mjcarroll@intrinsic.ai>
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.
🦟 Bug fix
Fixes #395
Summary
The fix checks for zero standard deviation before sampling the normal distribution. If the standard deviation is zero, the mean is set directly. I've fixed both cases as mentioned in #395, as I think a crash is undesirable for both cases, but perhaps a warning should be emitted in Load() if the state standard deviation is zero.
Checklist
codecheckpassed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-bymessages.