Skip to content

Check for 0 stddev when generating a random number using normal distribution#615

Merged
iche033 merged 3 commits intogz-math7from
rand_normal
Aug 6, 2024
Merged

Check for 0 stddev when generating a random number using normal distribution#615
iche033 merged 3 commits intogz-math7from
rand_normal

Conversation

@iche033
Copy link
Copy Markdown
Contributor

@iche033 iche033 commented Aug 6, 2024

🦟 Bug fix

Fixes gazebosim/gz-sim#2519

Summary

We use std::normal_distribution in our Rand class. From the doc:

The behavior is undefined if stddev is not greater than zero.

So added a check for 0 stddev (sigma) and return mean if its 0.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

iche033 added 2 commits August 6, 2024 21:21
Signed-off-by: Ian Chen <ichen@openrobotics.org>
Signed-off-by: Ian Chen <ichen@openrobotics.org>
@codecov
Copy link
Copy Markdown

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.98%. Comparing base (11caaf7) to head (59848ab).
Report is 8 commits behind head on gz-math7.

Additional details and impacted files
@@             Coverage Diff              @@
##           gz-math7     #615      +/-   ##
============================================
- Coverage     94.11%   93.98%   -0.14%     
============================================
  Files           146      149       +3     
  Lines          9809     9956     +147     
============================================
+ Hits           9232     9357     +125     
- Misses          577      599      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@azeey azeey added the beta Targeting beta release of upcoming collection label Aug 6, 2024
Signed-off-by: Ian Chen <ichen@openrobotics.org>
@iche033 iche033 merged commit 197e189 into gz-math7 Aug 6, 2024
@iche033 iche033 deleted the rand_normal branch August 6, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

beta Targeting beta release of upcoming collection 🌱 garden Ignition Garden 🎵 harmonic Gazebo Harmonic

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[OdometryPublisher] Crash if initialized with zero gaussian noise standard deviation

2 participants