Prevent crash in TimeStampHandler for 2D and 3D simulated laser data without/identical timestamp fields (fixes #31)#32
Open
MikeDegany wants to merge 1 commit intoPRBonn:mainfrom
Conversation
Member
|
@tizianoGuadagnino can you please have a look at this PR? |
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a crash in the TimeStampHandler when processing 3D or 2D laser data in simulations. In scenarios where the PointCloud2 message does not include a per-point timestamp (common with simulated 3D laser scanners), and where the PointCloud2 messages have identical timestamps (common with simulated 2D laser scanner), the current implementation returns an empty vector and later attempts to dereference iterators from it, resulting in a crash.
Changes Introduced
Early Check for Empty Timestamps:
Added an explicit check for an empty timestamps vector in ProcessTimestamps. If no timestamps are found (i.e., the timestamp field is missing), the function now logs a warning and returns early without attempting normalization.
Strict Equality for 2D Data:
Retained the strict equality check (*max_it != *min_it) for normalization when timestamps are present. This ensures that 2D laser data is processed correctly, while bypassing normalization only when all timestamps are identical.
Impact
3D Laser Data:
The fix ensures that 3D laser data in some simulation scenarios—which often lack per-point timestamps—does not lead to crashes, while scan deskewing is disabled gracefully.
2D Laser Data:
It occures in 2D laser data in some simulation scenarios, where timestamps are the same resulting in a crash exit code -6. The fix bypass the normalization in such cases.
The behavior remains unchanged, with normalization occurring only when a genuine timestamp range exists and changes.
Rationale
By handling the absence of timestamp data explicitly, and checking if timestamps are not identical, this change improves the robustness of the kinematic-ICP package and prevents runtime crashes due to invalid iterator dereferencing when users run kinematic-icp on simulation data and logs appropriate warning in each case. This approach is consistent with the intent to only process meaningful timestamp variations and gracefully handle missing data.