-
Notifications
You must be signed in to change notification settings - Fork 47
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
Inconsistent FOV & Aspect Ratio handling in ogre2 #763
Comments
OK I'm hitting a few problems when trying to fix this issue in an ABI stable way because:
Technically I could fix But while it would pass all the checks, it feels like morally I'm breaking the ABI due to Hyrum's Law:
So I began to question what is Aspect Ratio and why we need it? Aspect Ratio at low level makes senseAt OgreNext level (or anything lower level), AR makes sense. Cameras can be reused for multiple RenderTargets of varying resolutions. They may even be used to draw to only a portion of that target. In OgreNext we added setAutoAspectRatio because most users don't care and want the AR to match that of the Viewport. Aspect Ratio at Gazebo level doesn't make much senseGazebo seems to map 1 Camera == 1 physical camera in the real world. It's got its own feeds, its own render target resolution. Hence the AR should be tied to its RenderTarget resolution. But we have to admit, there's always "that one user", that needs a custom AR. Solution?As far as I can see, one approach I can try is to pretend to use Auto Aspect Ratio unless SetAspectRatio is explicitly called. This should fix it in the most sensible way without breaking everything for everyone. |
The old default Aspect Ratio would be 1.3333 Now it is 0.0 which indicates Gazebo should autocalculate the Aspect Ratio. This results in a nice backwards-compatible behavior while fixing various bugs mentioned in gazebosim#763 Fixes gazebosim#763 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
The old default Aspect Ratio would be 1.3333 Now it is 0.0 which indicates Gazebo should autocalculate the Aspect Ratio. This results in a nice backwards-compatible behavior while fixing various bugs mentioned in gazebosim#763 Fixes gazebosim#763 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar>
agreed |
The final solution I arrived turned out to be more elegant and simple than I could imagine: When you try to set an invalid value (i.e. AR <= 0.0) Gazebo starts autocalculating and Camera::AspectRatio will return the autocalculated ratio instead of 0.0 or the invalid negative value it was set. Thus if a user explicitly calls SetAspectRatio( 2.0 ) that value will be respected. The only case where my PR will break user code is if the user explicitly relied on calling SetAspectRatio with an invalid value (e.g. 0.0 or negative) which would have been a very, very bad practice. |
The old default Aspect Ratio would be 1.3333 Now it is 0.0 which indicates Gazebo should autocalculate the Aspect Ratio. This results in a nice backwards-compatible behavior while fixing various bugs mentioned in #763 Signed-off-by: Matias N. Goldberg <dark_sylinc@yahoo.com.ar> Co-authored-by: Ian Chen <ichen@osrfoundation.org>
Environment
Garden, probably others too.
Description
While creating Heightmap integration tests, I noticed Camera and DepthCamera produced quite different results; despite having the same parameters.
Tracking down the root of the problem, I nailed down on how gz-rendering handles Aspect Ratio inconsistently and very awkwardly.
Here are the problems:
Most Gazebo cameras call
Ogre::Camera::setAutoAspectRatio( true )
This looks undesirable because Gazebo has no toggle for auto aspect ratio; but instead asks for an explicit AspectRatio
When this is set; Ogre will overwrite calls to Camera::setAspectRatio during rendering; which means
gz::Ogre2Camera::AspectRatio
won't be honored (assuming the AR is different from the requested resolution)Some form of
gz::Ogre2Camera::AspectRatio
is still "honored" in some form because Gazebo asks for HFOV while Ogre asks for VFOV. And for the conversion the AR is still needed. This means Gazebo does:Hence calls to
gz::Camera::SetAspectRatio
will appear to make an impact, but it may be producing the wrong output.Ogre2Camera::AspectRatio
fallbacks toOgre::Camera::getAspectRatio
Because of the setAutoAspectRatio() call, the following will fail:
An integration test can be made for this due to its simplicity.
SetHFOV depends on AspectRatio
This means with the current API order matters and the following code is wrong:
And the following code is correct:
The most user-friendly solution would be to set the HFOV to Ogre every time in PreRender; this way initialization order won't matter.
Ogre2DepthCamera::HFOV
does not rely on Ogre::CameraThis is correct IMO, but inconsistent with Ogre2Camera.
Ogre2DepthCamera
only ever sets HFOV in CreateDepthTextureAgain calling order matters.
This fails:
This succeeds:
Steps to reproduce
Output
Output by normal Camera:
Output by normal DepthCamera:
Fix
I will be fixing this issue and submit a PR for it. So just assign this ticket to me.
The text was updated successfully, but these errors were encountered: