]> rtime.felk.cvut.cz Git - hubacji1/py-carla.git/blobdiff - focus.py
Add focus script
[hubacji1/py-carla.git] / focus.py
diff --git a/focus.py b/focus.py
new file mode 100755 (executable)
index 0000000..c2276e7
--- /dev/null
+++ b/focus.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3.7
+"""Focus spectator at specific coordinates."""
+import carla
+import sys
+
+client = carla.Client("localhost", 2000)
+client.set_timeout(9999)
+world = client.get_world()
+settings = world.get_settings()
+
+
+if __name__ == "__main__":
+    if len(sys.argv) != 2:
+        print("specify 'x,y,h' as the first and only argument")
+        exit(1)
+    x, y, h = [float(i) for i in sys.argv[1].replace(" ", "").split(",")]
+    sr = carla.Rotation(yaw=h)
+    sl = carla.Location(x=x, y=y, z=10) - 20 * sr.get_forward_vector()
+    world.get_spectator().set_transform(carla.Transform(sl, sr))