habitat-sim icon indicating copy to clipboard operation
habitat-sim copied to clipboard

Image extractor quaternions are incorrect

Open smorad opened this issue 2 years ago • 1 comments

Habitat-Sim version

latest docker release

🐛 Bug

The ImageExtractor will flip the Y-axis direction if the rotation is close to 180 degrees. This means the agent flips upside-down and takes images from underneath the floor. There's already a code comment that refers to this:

https://github.com/facebookresearch/habitat-sim/blob/5fb04078b0b8432dc4a88ec186a2b7af74163be1/src_python/habitat_sim/utils/data/pose_extractor.py#L274

This can be fixed by rewriting the _compute_quat function to force the rotation about a specific axis (the y axis in our case):

    # Fixed implementation
    def _compute_quat(self, cam_normal: np.ndarray) -> qt.quaternion:
        v0 = habitat_sim.geo.FRONT
        v1 = cam_normal / np.linalg.norm(cam_normal)
        # Only care about y rotation
        theta = np.arccos(np.dot(v0, v1))
        return quat_from_angle_axis(theta, np.array([0, 1.0, 0]))

cc @janblumenkamp

smorad avatar Mar 16 '23 15:03 smorad

Thanks for finding this. Would you mind sending a PR to fix it? And @mpiseno -- perhaps you could review the PR?

dhruvbatra avatar Mar 20 '23 02:03 dhruvbatra