-
Notifications
You must be signed in to change notification settings - Fork 861
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
Making repeated state publication optional #595
Conversation
706daab
to
e4d0bf8
Compare
@@ -991,20 +995,21 @@ namespace RobotLocalization | |||
"\ntransform_timeout is " << tfTimeout_.toSec() << | |||
"\nfrequency is " << frequency_ << | |||
"\nsensor_timeout is " << filter_.getSensorTimeout() << | |||
"\ntwo_d_mode is " << (twoDMode_ ? "true" : "false") << | |||
"\nsmooth_lagged_data is " << (smoothLaggedData_ ? "true" : "false") << | |||
"\ntwo_d_mode is " << std::boolalpha << twoDMode_ << |
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.
Sorry, I printed out the new param here using boolalpha
, and thought I might as well pick up the others.
src/ros_filter.cpp
Outdated
// If we're trying to publish with the same time stamp, it means that we had a measurement get inserted into the | ||
// filter history, and our state estimate was updated after it was already published. As of ROS Noetic, TF2 will | ||
// issue warnings whenever this occurs, so we make this behavior optional. | ||
corrected_data = (!permitCorrectedPublication_ && lastPublishedStamp_ == filteredPosition.header.stamp); |
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.
lastPublishedStamp_ == filteredPosition.header.stamp
I don't think that works, because what if its older than just the last update. If you have something with substantial latency (100ms) but your filter is spinning at 100hz, then it could be much older than last, right?
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.
So I'm thinking aloud here. The filter history handles this situation:
- In the first cycle, the filter has four measurements to process. They have timestamps
1
,2
,4
, and5
. They get processed, and we publish a state with timestamp5
. - In the second cycle, the filter receives only a measurement with timestamp
3
. It rewinds history to the posterior state after measurement2
was fused, and then processes3
,4
, and5
again. Then it publishes a state with timestamp5
. This creates the issue in question, and is solved by this PR.
Now let's go over your scenario, or at least what I think you are saying.
- In the first cycle, the filter has four measurements to process. They have timestamps
1
,2
,4
, and5
. They get processed, and we publish a state with timestamp5
. - In the second cycle, the filter has four measurements to process. They have timestamps
6
,7
,8
, and9
. They get processed, and we publish a state with timestamp9
. - In the third cycle, the filter receives only a measurement with timestamp
3
. It rewinds history to the posterior state after measurement2
was fused, and then processes3
,4
,5
,6
,7
,8
, and9
again. Then it publishes a state with stamp9
again. This also causes the issue, and is solved by this PR.
The filter was never publishing the updated state as it processed the history. It was rewinding, inserting, and processing all the way up to the latest measurement, then publishing. So I think checking the latest publication should work?
Note that in both of those cases, anyone listening to tf
will get the exact same behavior before and after this change: the first transform published won't get updated when the second one arrives. It's just that in Noetic, we also get yelled at. :)
There is a third case.
- In the first cycle, the filter has four measurements to process. They have timestamps
1
,2
,4
, and5
. They get processed, and we publish a state with timestamp5
. - In the second cycle, the filter has two measurements to process. They have timestamps
3
and6
. The filter rewinds history to the posterior state after measurement2
was fused, and then processes3
,4
,5
, and6
, and publishes the state with timestamp6
. This is obviously not an issue.
Anyway, I will readily admit that I might be totally missing your point, and I apologize if so. Can you provide an example?
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.
OK, I wasn't sure where filteredPosition
's stamp was from, I didn't know that it would already be, at this point, rewinded back up to the latest message in all cases. That works.
I might just make it a little more error proof with lastPublishedStamp_ >= filteredPosition.header.stamp
. I agree it shouldn't matter, but I think it makes syntactically more clear why this is being checked (or why they might be equal). I feel like a native reader can pull more from that than ==
.
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.
Yeah, that situation should never happen, but it also won't hurt to change it, and I agree with the increased clarity.
Shouldn't this be targeted only onto noetic and foxy? I don't think this issue affects melodic |
@@ -174,6 +174,10 @@ If *true*, the state estimation node will publish the transform from the frame s | |||
^^^^^^^^^^^^^^^^^^^^^ | |||
If *true*, the state estimation node will publish the linear acceleration state. Defaults to *false*. | |||
|
|||
~permit_corrected_publication |
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.
Any "new in XYZ distro" marker we can do?
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.
Should we just make a noetic-devel
and then change this PR to target that? Then we don't have to worry about that.
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.
Yeah
} | ||
|
||
// Retain the last published stamp so we can detect repeated transforms in future cycles | ||
lastPublishedStamp_ = filteredPosition.header.stamp; |
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 should be in the if statement, or else you could update based on a corrected_data
update.
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.
So the earlier suggestion about >= notwithstanding, as of now, if corrected_data == true
, then lastPublishedStamp_ == filteredPosition.header.stamp
anyway. However, I'm perfectly happy to move this up to line 1992.
Yes, but we don't have a Will roll your suggestion into the PR tomorrow. Thanks! |
Yeah sure |
@reobaird, were you able to try this out? |
Co-authored-by: James <jservos@clearpath.ai>
* navsat_transform diagram to address #550 (#570) * add diagram for navsat_transform Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add diagram to tutorial Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Fix frame id of imu in differential mode, closes #482 * Added local Cartesian option to navsat_transform * Fix navsat_transform issue with starting on uneven terrain * Fix typo in navsat_transform_node.rst (#588) "prodives" -> "provides" * Fix sign error in dFY_dP in transfer function jacobian * Making repeated state publication optional (#595) * PR feedback * Fixing build issues * Fixing stamp issues * Linting and uncrustifying Co-authored-by: Mabel Zhang <mabel.m.zhang@gmail.com> Co-authored-by: Jeffrey Kane Johnson <jeff@mapless.ai>
* navsat_transform diagram to address cra-ros-pkg#550 (cra-ros-pkg#570) * add diagram for navsat_transform Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * add diagram to tutorial Signed-off-by: Mabel Zhang <mabel@openrobotics.org> * Fix frame id of imu in differential mode, closes cra-ros-pkg#482 * Added local Cartesian option to navsat_transform * Fix navsat_transform issue with starting on uneven terrain * Fix typo in navsat_transform_node.rst (cra-ros-pkg#588) "prodives" -> "provides" * Fix sign error in dFY_dP in transfer function jacobian * Making repeated state publication optional (cra-ros-pkg#595) * PR feedback * Fixing build issues * Fixing stamp issues * Linting and uncrustifying Co-authored-by: Mabel Zhang <mabel.m.zhang@gmail.com> Co-authored-by: Jeffrey Kane Johnson <jeff@mapless.ai>
Addresses #574.
As far as how this will behave, if the filter publishes a state with time
t
, and we later get a measurement with stamp <t
, we'll still integrate that measurement and correct our state internally, but we won't publish a state that includes that correction until the next publication cycle aftert
.This may get its base changed to a new
noetic-devel
branch.