Fix #2035: Initialize previous_publish_timestamp_ in on_configure#2084
Fix #2035: Initialize previous_publish_timestamp_ in on_configure#2084Bharath4444 wants to merge 2 commits intoros-controls:masterfrom
Conversation
| @@ -220,18 +220,10 @@ controller_interface::return_type DiffDriveController::update_and_write_commands | |||
| orientation.setRPY(0.0, 0.0, odometry_.getHeading()); | |||
|
|
|||
| bool should_publish = false; | |||
There was a problem hiding this comment.
I think this variable can/should be removed now.
There was a problem hiding this comment.
I guess it is still needed to be able to control the frequency of publishing the message
There was a problem hiding this comment.
You are right, we can combine the logic and we can remove it
saikishor
left a comment
There was a problem hiding this comment.
Combine the logic and remove should_publish variable
christophfroehlich
left a comment
There was a problem hiding this comment.
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.
| 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.
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.
| 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.
still: This comparison will throw an exception if the timesource changes
|
This PR is stale because it has been open for 45 days with no activity. Please tag a maintainer for help on completing this PR, or close it if you think it has become obsolete. |
|
This pull request is in conflict. Could you fix it @Bharath4444? |
|
@Bharath4444 could you fix the remaining threads please? |
…e try-catch also removing should_publish variable
cd0b235 to
04e7542
Compare
christophfroehlich
left a comment
There was a problem hiding this comment.
Please don't do force pushes if a PR is already under review. Have you changed anything, have you considered the remarks in the threads?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2084 +/- ##
==========================================
- Coverage 84.85% 84.85% -0.01%
==========================================
Files 153 153
Lines 15016 15011 -5
Branches 1298 1297 -1
==========================================
- Hits 12742 12737 -5
Misses 1800 1800
Partials 474 474
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
I read through the diff and the review comments. It seems the main issue is that removing the try-catch leaves no handling for when the clock source changes at runtime. The comparison on line 241 would still throw in that case. One idea: check if the clock type changed before doing the arithmetic, using |
|
Thanks for your work and comments, but I think we will just remove this functionality with #2245 |
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