Skip to content
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

Update Camera FoV as well when using simSetCameraFoV API #3278

Merged
merged 2 commits into from
May 20, 2021

Conversation

rajat2004
Copy link
Contributor

@rajat2004 rajat2004 commented Jan 6, 2021

Fixes #2977

About

  • Fixes camera FoV not being updated when using the API
  • Adds example script for usage of API

Currently, only Render texture FoVs are being updated. This results in an incorrect FoV in the Camera info. Note that this is a behavioural change, previously when changing the FoV, the main viewport did not change, only the rendered images were affected. This change will cause the viewport to also change if the camera is the main one, such as the front center camera

How Has This Been Tested?

Using the script added in this PR, and the output -

Output
$ python fov_change.py
Connected!
Client Ver:1 (Min Req: 1), Server Ver:1 (Min Req: 1)

Saving images to /tmp/airsim_cv_mode
Camera: front_center
Press any key to get camera parameters
<CameraInfo> {   'fov': 90.0,
    'pose': <Pose> {   'orientation': <Quaternionr> {   'w_val': 1.0,
    'x_val': -0.0,
    'y_val': 0.0,
    'z_val': 0.0},
    'position': <Vector3r> {   'x_val': 0.0,
    'y_val': 0.0,
    'z_val': -0.0}},
    'proj_mat': <ProjectionMatrix> {   'matrix': [   [   0.0,
                      1.0,
                      0.0,
                      0.0],
                  [   0.0,
                      0.0,
                      -1.7777777910232544,
                      0.0],
                  [   0.0,
                      0.0,
                      0.0,
                      10.0],
                  [   -1.0,
                      0.0,
                      0.0,
                      0.0]]}}
Press any key to get images, saving to /tmp/airsim_cv_mode
Type 0, size 41957, pos <Vector3r> {   'x_val': 0.0,
    'y_val': 0.0,
    'z_val': -0.0}
Type 3, size 1488, pos <Vector3r> {   'x_val': 0.0,
    'y_val': 0.0,
    'z_val': -0.0}
Press any key to change FoV and get images
Type 0, size 41314, pos <Vector3r> {   'x_val': 0.0,
    'y_val': 0.0,
    'z_val': -0.0}
Type 3, size 1656, pos <Vector3r> {   'x_val': 0.0,
    'y_val': 0.0,
    'z_val': -0.0}
<CameraInfo> {   'fov': 120.0,
    'pose': <Pose> {   'orientation': <Quaternionr> {   'w_val': 1.0,
    'x_val': -0.0,
    'y_val': 0.0,
    'z_val': 0.0},
    'position': <Vector3r> {   'x_val': 0.0,
    'y_val': 0.0,
    'z_val': -0.0}},
    'proj_mat': <ProjectionMatrix> {   'matrix': [   [   0.0,
                      0.5773502588272095,
                      0.0,
                      0.0],
                  [   0.0,
                      0.0,
                      -1.0264004468917847,
                      0.0],
                  [   0.0,
                      0.0,
                      0.0,
                      10.0],
                  [   -1.0,
                      0.0,
                      0.0,
                      0.0]]}}
Old FOV: 90.0, New FOV: 120.0

Earlier, the second CameraInfo FoV would be 90.0

Screenshots (if appropriate):

Old FoV viewport -
old_fov_viewport

After FoV update -
new_fov_viewport

Recorded images -
airsim_cv_mode.zip

@MikeJamesWhite
Copy link

This works for us.

@jonyMarino
Copy link
Collaborator

Shouldn't be #3573 be added now to the fixes list?

@rajat2004
Copy link
Contributor Author

@jonyMarino I had added it earlier but later on removed it since #3573 deals with the FOV set in settings.json rather than the API. It's a bit of a separate issue that isn't affected by this PR

@zimmy87
Copy link
Contributor

zimmy87 commented May 20, 2021

Thanks for making this fix @rajat2004! Tested on my side and it appears to work just fine

@zimmy87 zimmy87 merged commit d2c8c3a into microsoft:master May 20, 2021
@rajat2004 rajat2004 deleted the fix-camera-fov branch May 22, 2021 03:22
@kishanpb
Copy link

Is this only fixed for SimMode="ComputerVision"?
I am still getting fov 90 from simGetCameraInfo for SimMode="Multirotor" when I have fov 150 in the settings.

@rajat2004
Copy link
Contributor Author

This PR only affects the API call simSetCameraFoV, there's a separate issue #3573 for FoV in settings

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

Successfully merging this pull request may close these issues.

Incorrect FOV in simGetCameraInfo call
5 participants