Page 1 of 1

Translate camera in debug visualizer

Posted: Mon Feb 01, 2021 5:54 am
by rli14
Currently in debug visualizer, I know I can drag the mouse to swivel the rotation of the camera. Additionally, I can use the mouse wheel to zoom in and out.

But what about translating the camera? Say, along the XYZ world frame axises. Or even along the XYZ camera frame axises. This would make focusing on my object much much easier in the visual debugger. Is this possible?

Re: Translate camera in debug visualizer

Posted: Mon Feb 01, 2021 5:16 pm
by SphericalCow
Here is the code I use for setting the visualiser camera to a given position, facing towards a given target.

def set_camera(pos=torch.ones(3), target=torch.zeros(3)):
disp = target - pos
dist = disp.norm()
yaw = np.arctan2(-disp[0],disp[1]) * 180/np.pi
pitch = np.arctan2(disp[2],np.sqrt(disp[0]**2+disp[1]**2)) * 180/np.pi
p.resetDebugVisualizerCamera(cameraDistance=dist, cameraYaw=yaw, cameraPitch=pitch, cameraTargetPosition=target.tolist())