Repository navigation
fix: parse ROS image trailers and expose RealSense depth units - #155
Open
theluckystrike wants to merge 1 commit into
Open
theluckystrike wants to merge 1 commit into
theluckystrike wants to merge 1 commit into
Conversation
ROSBag no longer guesses how many trailing bytes to strip. Image and CompressedImage messages are parsed up to the end of their data array for ROS1 and CDR, legal CDR padding is accepted, and a 4-byte RealSense footer is decoded as depth_units instead of being dropped. ROSBag gains depth_units (None, 'auto' or a float, metres per unit) and invalid_is_nan, with the precedence described in the issue. Closes petercorke#151
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 64 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This branch has not been deployed
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.
Closes #151
ROSBagguessed how many trailing bytes to strip from each image message, so RealSense bags lost their depth units footer and a RealSense bag with no trailer (Intel'ssingle_depth_color_640x480.baglayout) would have had 4 real bytes chopped off.What changed, following the checklist in the issue
ImageandCompressedImageare parsed by hand up to the end of the data array (header, height, width, encoding, is_bigendian, step, then the array length), for both ROS1 and CDR. Onlyraw[:end]goes to the type store,n == height * stepis checked, and legal CDR alignment padding is accepted. The old 0/4/8 probe is kept only as a fallback for other message types.tests/create_ros_fixture.py, with a regression test for a bag that hasStreamInfoand 0 extra bytes.depth_unitson the sample (depth frames carry the scale, colour frames0.0).StreamInfoandCameraInfogo through the fallback trailer check.printin this path is replaced withlogging.Depth units API
ROSBag(..., depth_units=None | "auto" | float, invalid_is_nan=True), wheredepth_unitsis metres per native unit as in librealsense. The docstring notes that this is the reciprocal of the Open3D and TUM RGB-Ddepth_scale(1000 and 5000).The scale comes from, in order, a user float, the per message footer, the bag's
.../option/Depth_Units/valuetopic, the REP 118 encoding (16UC1is millimetres,32FC1is metres), then unknown.None(default) returns the native dtype unchanged withdepth_unitsattached as metadata."auto"or a float converts to float32 metres, and raw 0 becomes NaN wheninvalid_is_nanis true. For32FC1a user float acts as a gain.Type registration for bag connections now distinguishes ROS1
.msgfrom ROS2 IDL definitions, registers only missing types and skips incompatible typestore candidates during auto detection, so an unrelated or custom IDL type can't abort reading the images.Tests
301 tests pass in
tests/test_ros.pyand the full suite passes locally. Ruff reports no new findings in the changed files.One related thing I left alone because it behaves the same on
main. The per message handlers catchKeyErrorandAssertionErrorbut not rosbags'SerdeError, so a bag with an undecodable non image message still stops iteration. I can follow up in #150 if you want that handled.