-
Notifications
You must be signed in to change notification settings - Fork 486
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
Distortion normalization improvement + fix "folding" on large distortions #3009
Distortion normalization improvement + fix "folding" on large distortions #3009
Conversation
One comment on the test we've added: We've added a more extreme barrel and pin cushion distortion to an existing test for distortion. This test is not very rigorous and may pass even before this PR or if the results are incorrect, for example because of parameter leaking #2527. I think after #2527 is fixed, it would be good to add a stronger test to check that behavior is as expected. A possible work around for #2527 is to make environments with one camera per world and test their expected behavior individually. |
I have run this test without the fixes in this branch and confirmed that it does not fail, reducing its usefulness.
I believe that parameter leaking does not occur in this test because the individual cameras are each added dynamically using the |
We took them in Gazebo by placing a checkerboard directly in front of a camera with significant distortion ( |
this is a behavior change, so I think we should use a namespaced SDFormat parameter to opt-in to it, to keep existing camera parameters functioning the same way. Something like
|
I agree with this approach. Something that indicates that it will use the provided distortion coefficients directly would be ideal. Maybe
I am in favor of disabling cropping with this implementation since cropping invalidates the distortion parameters (and therefore defeats the purpose of using the tag). |
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
47ad970
to
77bb479
Compare
@scpeters and @kjeppesen1, I've added a |
I'll think about a better test to add. |
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
I've applied the feedback from yesterday and added a test that I believe checks the feature. Changes:
I spawned cameras in the test environment to get around #2527. |
distortedIdx = distortedRow * this->dataPtr->distortionTexWidth + distortedCol; | ||
|
||
// check if the index has already been set | ||
if (this->dataPtr->distortionMap[distortedIdx] != unsetPixelVector) |
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 logic block looks new. should we add && !this->dataPtr->legacyMode
to the if statement? or we could reverse it:
if (this->dataPtr->legacyMode)
{
this->dataPtr->distortionMap[distortedIdx] = normalizedLocation;
}
// check if the index has already been set
else if (this->dataPtr->distortionMap[distortedIdx] != unsetPixelVector)
{
...
}
if not, then we should clarify that this is a bug fix that applies in all cases
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.
I think this can be considered a bug fix, since there will be the wrapping behavior shown in #3009 (comment) on very large barrel distortions with the legacy method.
I'm not sure what would be the best place to mention this. I can alter the PR to mention the bug fix and add a comment in this part of the code. Anywhere else?
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.
I added a comment in the code (below) and modified the PR title and description. https://github.com/osrf/gazebo/blob/406b65e634b3ee6d45ffbd6f77d136caa048ca3a/gazebo/rendering/Distortion.cc#L240-L243
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
This reverts commit ba51bac. # Conflicts: # test/integration/camera_sensor.cc
Signed-off-by: Audrow Nash <audrow@hey.com>
1d51120
to
861f8eb
Compare
worlds/test/issue_3003_distortion_implementation_correction.world
Outdated
Show resolved
Hide resolved
worlds/test/issue_3003_distortion_implementation_correction.world
Outdated
Show resolved
Hide resolved
worlds/test/issue_3003_distortion_implementation_correction.world
Outdated
Show resolved
Hide resolved
worlds/test/issue_3003_distortion_implementation_correction.world
Outdated
Show resolved
Hide resolved
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
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.
the new test looks good. I think you've matched the style of other tests, though there is a fair bit of repeated code. Some lambda functions could probably reduce some code duplication, but it's fine as is
Signed-off-by: Audrow Nash <audrow@hey.com>
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 think this is almost there. I just have one minor nit, and I noticed some lines are longer than 80 characters. Our CI is not currently reporting style errors due to gazebo-tooling/release-tools#446, but I think avoiding trailing whitespace and long lines should be enough
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
I think that it should be good now. |
I've tested with libgazebo_ros_camera, and I think the logic is working properly now |
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.
I just noticed some new clang warnings, but aside from that I approve
Signed-off-by: Audrow Nash <audrow@hey.com>
double _cx = 0.5, double _cy = 0.5); | ||
double _cx = 0.5, double _cy = 0.5, | ||
bool _legacyMode = true, | ||
double _horizontalFov = 0.78539816339744828); |
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.
I think this breaks ABI?
ABI checker didn't show any issue here but I'm not sure if that's because it's not testing the ServerFixture
library.
Also add \param[in]
for _horizontalFov
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.
I think this breaks ABI?
ABI checker didn't show any issue here but I'm not sure if that's because it's not testing the
ServerFixture
library.
I was wondering the same thing, but we only distribute ServerFixture
in a static library, and I believe ABI is only a concern for dynamically loaded libraries
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
Signed-off-by: Audrow Nash <audrow@hey.com>
Windows CI failed for an unrelated reason, and the failures in the other jobs look unrelated to me. Merging now... |
Fixes #3003.
Modifies how Brown's distortion equations are applied to better reflect real distortion. Image is projected from image plane to camera plane to apply distortion equations, then projected back to image plane.
Before/after focal scaling implementation:
Before/after extreme distortion edge case fix:
We use a tag
<ignition:legacy_mode>
in a distortion context to select this new behavior.Regardless of if the new mode or legacy mode are used, this PR adds a bug fix for heavy distortions that prevents the distorted image from "folding back" on itself, as seen in the image above.