Spaces:
Running
on
Zero
Running
on
Zero
fix simulation camera
Browse files- visualization/logger.py +25 -3
visualization/logger.py
CHANGED
@@ -18,6 +18,12 @@ class SimulationLogger:
|
|
18 |
def __init__(self):
|
19 |
rr.init("camera_simulation")
|
20 |
rr.log("world", rr.ViewCoordinates.RIGHT_HAND_Y_UP, timeless=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def log_metadata(self, instructions: List[Dict[str, Any]]) -> None:
|
23 |
if not instructions:
|
@@ -86,6 +92,20 @@ class SimulationLogger:
|
|
86 |
),
|
87 |
timeless=True
|
88 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
except Exception as e:
|
90 |
print(f"Error logging camera trajectory: {str(e)}")
|
91 |
|
@@ -95,11 +115,12 @@ class SimulationLogger:
|
|
95 |
|
96 |
for frame_idx, camera_frame in enumerate(camera_frames):
|
97 |
try:
|
98 |
-
rr.set_time_sequence("
|
99 |
|
100 |
position = vector3_to_numpy(camera_frame['position'])
|
101 |
rotation_q = euler_to_quaternion(camera_frame['angle'])
|
102 |
|
|
|
103 |
rr.log(
|
104 |
"world/camera",
|
105 |
rr.Transform3D(
|
@@ -108,10 +129,11 @@ class SimulationLogger:
|
|
108 |
)
|
109 |
)
|
110 |
|
|
|
111 |
rr.log(
|
112 |
-
"world/camera/
|
113 |
rr.Pinhole(
|
114 |
-
|
115 |
width=1920,
|
116 |
height=1080
|
117 |
)
|
|
|
18 |
def __init__(self):
|
19 |
rr.init("camera_simulation")
|
20 |
rr.log("world", rr.ViewCoordinates.RIGHT_HAND_Y_UP, timeless=True)
|
21 |
+
# Default camera intrinsics
|
22 |
+
self.K = np.array([
|
23 |
+
[500, 0, 960], # adjusted for 1920x1080
|
24 |
+
[0, 500, 540], # adjusted for 1920x1080
|
25 |
+
[0, 0, 1]
|
26 |
+
])
|
27 |
|
28 |
def log_metadata(self, instructions: List[Dict[str, Any]]) -> None:
|
29 |
if not instructions:
|
|
|
92 |
),
|
93 |
timeless=True
|
94 |
)
|
95 |
+
|
96 |
+
# Add trajectory line
|
97 |
+
if len(camera_positions) > 1:
|
98 |
+
lines = np.stack(
|
99 |
+
[camera_positions[:-1], camera_positions[1:]], axis=1)
|
100 |
+
rr.log(
|
101 |
+
"world/camera_trajectory/line",
|
102 |
+
rr.LineStrips3D(
|
103 |
+
lines,
|
104 |
+
colors=[(0.0, 0.8, 0.8, 1.0)]
|
105 |
+
),
|
106 |
+
timeless=True
|
107 |
+
)
|
108 |
+
|
109 |
except Exception as e:
|
110 |
print(f"Error logging camera trajectory: {str(e)}")
|
111 |
|
|
|
115 |
|
116 |
for frame_idx, camera_frame in enumerate(camera_frames):
|
117 |
try:
|
118 |
+
rr.set_time_sequence("frame_idx", frame_idx)
|
119 |
|
120 |
position = vector3_to_numpy(camera_frame['position'])
|
121 |
rotation_q = euler_to_quaternion(camera_frame['angle'])
|
122 |
|
123 |
+
# Log camera transform
|
124 |
rr.log(
|
125 |
"world/camera",
|
126 |
rr.Transform3D(
|
|
|
129 |
)
|
130 |
)
|
131 |
|
132 |
+
# Log camera image plane with intrinsics
|
133 |
rr.log(
|
134 |
+
"world/camera/image",
|
135 |
rr.Pinhole(
|
136 |
+
image_from_camera=self.K,
|
137 |
width=1920,
|
138 |
height=1080
|
139 |
)
|