bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

Question About p.get/setDebugVisualizerCamera and changing the target position

Open fishbotics opened this issue 1 year ago • 0 comments

Hi,

I have a question about the debug visualizer camera and how the parameters are calculated. Here is an example.

import pybullet as p
import numpy as np
p.connect(p.GUI)
camera_info = p.getDebugVisualizerCamera()
yaw = camera_info[8]    
pitch = camera_info[9]
distance = camera_info[10]
target = camera_info[11]
view_matrix = np.asarray(camera_info[2]).reshape(4, 4).T  # Switch to column-major format

# Keeps everything the same
p.resetDebugVisualizerCamera(    
    distance, yaw, pitch, target,
)

assert np.allclose((np.linalg.inv(view_matrix) @ np.array([0, 0, -distance, 1]))[:3], target, atol=1e-6)
new_target = tuple((np.linalg.inv(view_matrix)  @ np.array([0, 0, -2 * distance, 1]))[:3])
# This moves the camera
p.resetDebugVisualizerCamera(    
    2 * distance, yaw, pitch, new_target,
)

Why does changing the target along the same ray affect the camera position? My only guess would be that yaw and pitch are relative to the horizontal plane with the target?

fishbotics avatar Sep 17 '22 01:09 fishbotics