23 lines
786 B
Python
23 lines
786 B
Python
"""
|
|
Viewpoint inspector — prints position, orientation and FOV to the console
|
|
once per second. Attach as the controller of a dummy supervisor robot to
|
|
copy-paste exact camera values into field.wbt.
|
|
"""
|
|
|
|
from controller import Supervisor
|
|
|
|
robot = Supervisor()
|
|
timestep = int(robot.getBasicTimeStep())
|
|
vp = robot.getFromDef("VIEWPOINT")
|
|
|
|
step = 0
|
|
while robot.step(timestep) != -1:
|
|
if step % 60 == 0:
|
|
pos = vp.getField("position").getSFVec3f()
|
|
ori = vp.getField("orientation").getSFRotation()
|
|
fov = vp.getField("fieldOfView").getSFFloat()
|
|
print(f"position: {pos[0]:.3f} {pos[1]:.3f} {pos[2]:.3f}")
|
|
print(f"orientation: {ori[0]:.3f} {ori[1]:.3f} {ori[2]:.3f} {ori[3]:.3f}")
|
|
print(f"fieldOfView: {fov:.3f}\n")
|
|
step += 1
|