-
Notifications
You must be signed in to change notification settings - Fork 440
Fix #2035: Initialize previous_publish_timestamp_ in on_configure #2084
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
base: master
Are you sure you want to change the base?
Fix #2035: Initialize previous_publish_timestamp_ in on_configure #2084
Conversation
| tf2::Quaternion orientation; | ||
| orientation.setRPY(0.0, 0.0, odometry_.getHeading()); | ||
|
|
||
| bool should_publish = false; |
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.
I think this variable can/should be removed now.
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.
I guess it is still needed to be able to control the frequency of publishing the message
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.
You are right, we can combine the logic and we can remove it
saikishor
left a comment
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.
Combine the logic and remove should_publish variable
…e try-catch also removing should_publish variable
christophfroehlich
left a comment
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.
This just removes the logic introduced with #585
Are we sure that this is not needed anymore?
| previous_publish_timestamp_ = time; | ||
| should_publish = true; | ||
| } | ||
| previous_publish_timestamp_ += publish_period_; |
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.
| previous_publish_timestamp_ += publish_period_; | |
| previous_publish_timestamp_ = time; |
@christophfroehlich I think this should fix #585 and also be better overall.
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.
no because the comparison above fails if the time source changed.
|
|
||
| bool should_publish = false; | ||
| try | ||
| if (previous_publish_timestamp_ + publish_period_ <= time) |
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.
| if (previous_publish_timestamp_ + publish_period_ <= time) | |
| if (previous_publish_timestamp_ + publish_period_ > time) |
I was misunderstanding the logic here. I think with this change and the earlier one everything should work. This should cause this if statement to pass as true the first time in simulation and from there on work correctly.
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.
still: This comparison will throw an exception if the timesource changes
Description
This PR addresses issue #2035 by moving the initialization of
previous_publish_timestamp_into theon_configure()lifecycle method.Previously, this variable was initialized inside a
catchblock within the update loop, effectively using exception handling for normal control flow. Moving it toon_configurealigns it with howprevious_update_timestamp_is handled and ensures the timestamp is valid before the update loop begins.Related Issues
Closes #2035
Type of Change
Checklist