CARLA ? C-Shenron based Simualtor for Sensor data generation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

22 lines
781 B

import carla
def get_pos():
client = carla.Client("localhost", 2000)
client.set_timeout(10.0)
world = client.get_world()
spectator = world.get_spectator()
t = spectator.get_transform()
loc = t.location
rot = t.rotation
print("\n" + "="*40)
print("CURRENT SPECTATOR POSITION")
print("="*40)
print(f"Location: x={loc.x:.3f}, y={loc.y:.3f}, z={loc.z:.3f}")
print(f"Rotation: pitch={rot.pitch:.3f}, yaw={rot.yaw:.3f}, roll={rot.roll:.3f}")
print("="*40)
print("\nCopy-paste this into your script:")
print(f"transform = carla.Transform(carla.Location(x={loc.x:.3f}, y={loc.y:.3f}, z={loc.z:.3f}), carla.Rotation(pitch={rot.pitch:.3f}, yaw={rot.yaw:.3f}, roll={rot.roll:.3f}))")
if __name__ == "__main__":
get_pos()