Repository navigation
Fix DisparityConverter: the baseline was divided by 100 twice - #806
Merged
asahtik merged 3 commits intoNov 18, 2026
Merged
Conversation
The constructor takes the baseline in centimeters and already converts it to meters, but toRosMsg divided it by 100 again when filling DisparityImage.t. For a 7.5 cm baseline t was published as 0.00075 m instead of 0.075 m, so any depth reconstructed from the message was 100 times too small. Publish the baseline as it is stored (meters), document the units of the constructor arguments and fix the unit test, which expected the wrong value (0.01 for a 100 cm baseline instead of 1.0).
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The ToRosMsgPtrTest baseline expectation remains 0.01f instead of 1.0f, causing the registered disparity-converter test target to fail after the conversion fix.
1 open issue
What changed in this PR
This PR corrects the baseline published by DisparityConverter, preventing consumers from reconstructing depths 100 times too small.
Changes:
- Publish the stored baseline in meters without converting it again.
- Document constructor argument units.
- Update the direct-conversion test to expect 1 meter for a 100 cm baseline.
| File | Description |
|---|---|
depthai_bridge/test/DisparityConverterTest.cpp |
Corrects the direct-conversion baseline expectation. |
depthai_bridge/src/DisparityConverter.cpp |
Removes the duplicate baseline conversion. |
depthai_bridge/include/depthai_bridge/DisparityConverter.hpp |
Documents focal length, baseline, and depth units. |
Review effort: Balanced
toRosMsgPtr() delegates to toRosMsg(), so with the 100 cm baseline used in this test the corrected conversion returns t = 1.0 (m) there too.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change's single unit fix is internally consistent with the updated documentation and corrected test expectations, leaving no outstanding issues to resolve.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
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.

The constructor takes the baseline in centimeters and already converts it to meters, but toRosMsg divided it by 100 again when filling DisparityImage.t. For a 7.5 cm baseline t was published as 0.00075 m instead of 0.075 m, so any depth reconstructed from the message was 100 times too small.
Publish the baseline as it is stored (meters), document the units of the constructor arguments and fix the unit test, which expected the wrong value (0.01 for a 100 cm baseline instead of 1.0).
Summary
DisparityConverter publishes stereo_msgs/DisparityImage.t (the baseline, in meters) 100 times too small. The constructor takes the baseline in centimeters and already converts it to meters (_baseline(baseline / 100.0)). toRosMsg then divides by 100 again (outDispImageMsg.t = _baseline / 100.0). With a 7.5 cm baseline, t is published as 0.00075 m instead of 0.075 m. Any depth reconstructed from the message (depth = f * t / disparity) is therefore 100 times too small. min_disparity and max_disparity use _baseline in meters and are not affected.
The fix is outDispImageMsg.t = _baseline;. The header now also documents the units (cm) of the constructor arguments.
The same two lines exist in every branch that has this converter (foxy, galactic, humble, iron, jazzy, kilted, develop). I'm opening the PRs for jazzy and develop first so the approach can be agreed. I can open the same PR for humble and kilted afterwards.
Related issues
Not part of this PR (it would be a separate issue): the converter divides the 16-bit disparity by 32 (5 fractional bits), but DepthAI uses 3 subpixel fractional bits by default.
Compatibility and configuration
No new topics, parameters or launch options. The value of DisparityImage.t changes to the documented meaning (meters). Consumers that compensated for the wrong value must remove that compensation.
Testing
tis 0.00075 m before and 0.07500 m after.t = 0.0749and the rectified focal length,depth_mm / (f * t * 1000 / disparity)has a median of 0.98. With the oldtit was about 97.6, which is the factor of 100.AI