-
Notifications
You must be signed in to change notification settings - Fork 329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handled Zero Division Error in pipeline.py #344
Conversation
Thanks for the fix! Two cosmetic suggestions from my side, just to keep things compact. |
Co-authored-by: Benedikt Mersch <[email protected]>
Thanks for the fix, it is definetly helpful. The bigger question here would be, though, how you end up with a 0.000 runtime. You might have a problem somewhere else. I agree that is not the right place to explode, but something else went wrong here |
Is this PR still active? We should discuss which runtime should be reported if the total time is zero. I have two proposals:
What do you think? |
Is there any other way than returning 0? |
How about diff --git a/python/kiss_icp/pipeline.py b/python/kiss_icp/pipeline.py
index 52cb7a7..46b9d4d 100644
--- a/python/kiss_icp/pipeline.py
+++ b/python/kiss_icp/pipeline.py
@@ -184,9 +184,10 @@ class OdometryPipeline:
fps = _get_fps()
avg_fps = int(np.floor(fps))
avg_ms = int(np.ceil(1e3 / fps)) if fps > 0 else 0
- self.results.append(desc="Average Frequency", units="Hz", value=avg_fps, trunc=True)
- self.results.append(desc="Average Runtime", units="ms", value=avg_ms, trunc=True)
+ if avg_fps > 0:
+ self.results.append(desc="Average Frequency", units="Hz", value=avg_fps, trunc=True)
+ self.results.append(desc="Average Runtime", units="ms", value=avg_ms, trunc=True)
def _write_log(self):
if not self.results.empty(): Wit this, we don't have think about what the |
@karthikbolla would you please do as @benemer suggested? you can also give us access to commit there so we also ack your contribution thanks |
updated pipeline.py based on @benemer suggestions where the results are only appended when avg fps is greater than zero
@nachovizzo @benemer I've raised a new commit based on @benemer's suggestions and also granted access to the fork. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you for your contribution!
This pull request addresses a division by zero error in the
_get_fps()
function. I've implemented a check to handle the case wheretotal_time_s
is zero to prevent the error. Additionally, I've modified the calculation ofavg_ms
to ensure it doesn't result in a division by zero.Changes Made:
_get_fps()
to handle division by zero.avg_ms
to prevent division by zero.Fixes: #343