Skip to content

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
MikeDegany:issue-31-TimeStampHandler
Open

Prevent crash in TimeStampHandler for 2D and 3D simulated laser data without/identical timestamp fields (fixes #31)#32
MikeDegany wants to merge 1 commit intoPRBonn:mainfrom
MikeDegany:issue-31-TimeStampHandler

Conversation

@MikeDegany
Copy link

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.

Copy link
Member

@benemer benemer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@benemer
Copy link
Member

benemer commented Apr 23, 2025

@tizianoGuadagnino can you please have a look at this PR?

@edelwiw
Copy link

edelwiw commented Jul 5, 2025

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants