Reset camera orientation after leaving track_visual mode

#2744 Merged at 0110572
Repository
osrf
Branch
default
Author
  1. Olivier Crave
Reviewers
Description

Currently, after leaving the track_visual mode, the camera keeps its orientation determined by Ogre setAutoTracking method. With this pull request, the camera orientation is set to zero after leaving the track_visual mode to make sure that it can still be easily manipulated by the user.

Comments (14)

  1. Shane Loretz

    @ocrave Thanks for the PR! It feels jarring to exit follow mode and have the view reset. Is there a way to fix the bug and keep the camera at its current position/direction?

    For others, steps to make camera get stuck rolled on gazebo default without this patch

    • enter follow mode on a stationary object
    • changing the pitch of the camera so that it is looking down at the object
    • exit follow mode
    • Bring the camera down to its previous pitch
    • The camera has now rolled, and cannot be unrolled.
    1. Ian Chen

      the problem is that with auto tracking enabled, the orientation of the ogre camera object itself will change (as opposed to its parent scene node). Typically, the ogre camera orientation remains fixed at the orientation when it's first created. Later pose operations are done to its parent scene node. I believe the solution for exiting the follow mode will involve resetting the ogre camera's orientation to the initial state and correcting its parent scenenode's orientation to keep the camera facing the current direction.

      1. Olivier Crave author

        This pull request has been modified to implement your solution. A call to Camera::SetWorldPose is mandatory to reinitialize the view controller in UserCamera. I also removed some calls to deprecated Ogre methods but calls to deprecated Ogre::Camera::yaw and Ogre::Camera::roll still remain and must be canceled out before entering track_visual mode. Ideally, we should remove calls to Ogre::Camera::yaw and Ogre::Camera::roll, but in order to do that, we may have to add another Ogre::SceneNode in-between Camera::sceneNode and Camera::camera.

        1. Ian Chen

          great thanks, the camera pose stays the same now after leaving the follow mode.

          I noticed however that while in the camera follow mode, the orbit view controller wasn't moving the camera correctly, maybe because camera auto tracking was fighting with the pose changes made by the view controller. I tested adding an intermediate scene node like you mentioned and it seems to work well now. Here's a snippet showing a diff on top of your changes:

          https://bitbucket.org/snippets/iche033/bneEdk

          1. Olivier Crave author

            I still have not figured out why but your snippet does not fix the original issue anymore: The derived camera's rotation is OK after leaving the auto tracking mode but, as soon as you rotate the camera with your mouse, the camera jumps to another orientation. I tried to modify your code by setting the auto tracking on the sceneNode instead of on the cameraNode but it still does not work. The only thing that works for me is the latest commit without cameraNode.

            1. Ian Chen

              I'll try to get the PR merged soon.

              I am trying to reproduce the problem described below after merging with default and applying my patch

              as soon as you rotate the camera with your mouse, the camera jumps to another orientation.

              Here’s what I’m doing

              1. Insert box into empty world
              2. Right click on box, and select Follow
              3. Orbit the camera with right click (e.g. pitch the camera so it’s looking at the box from above)
              4. Press ESC to exit Follow mode → Camera orientation stays the way it was before leaving Follow mode so all good
              5. Right click on the box and orbit the camera again → camera orbit behavior seems fine and no jumps.

              Maybe I’m missing some steps?

              1. Olivier Crave author

                After merging with the default branch, I could not reproduce the issue anymore with your patch. So, I pushed a new version that contains your changes. It seems to be working now. Thanks!

                  1. Ian Chen

                    jenkins caught a couple of unexpected test failures related to cameras. I’ll look into it

                    1. Ian Chen

                      I made some changes that should fix the two failing tests INTEGRATION_camera and INTEGRATION_track_visual.

                      Please take a look and apply the diff if the changes look good to you. I’ll run another jenkins build afterwards, thanks.

  2. Olivier Crave author

    Unfortunately, I have not found a way to both keep the camera's pose and fix the bug.

  3. Stefan Kohlbrecher

    I believe #2550 shows the effect discussed in this PR.

    (On a side-note: Why doesn’t Bitbucket bidirectionally mention links between issue tickets and PRs? This is fairly annoying for complete referencing)