Start the visualizer server.
(self)
| 885 | last_slider_update = next_frame |
| 886 | |
| 887 | def run(self): |
| 888 | """Start the visualizer server.""" |
| 889 | self.server = viser.ViserServer(port=self.port) |
| 890 | |
| 891 | # Set up GUI |
| 892 | self._setup_gui() |
| 893 | |
| 894 | # Add checkerboard ground plane with alternating colored patches |
| 895 | cell_size = 2.5 # 2.5m cells (10x larger) |
| 896 | grid_extent = 15.0 # +/- 15m (10x larger) |
| 897 | color1 = (140, 140, 140) # Gray |
| 898 | color2 = (180, 180, 180) # Light gray |
| 899 | |
| 900 | # Create each cell as a separate mesh (allows different colors) |
| 901 | cell_idx = 0 |
| 902 | for i, x in enumerate(np.arange(-grid_extent, grid_extent, cell_size)): |
| 903 | for j, y in enumerate(np.arange(-grid_extent, grid_extent, cell_size)): |
| 904 | # Four corners of this cell |
| 905 | vertices = np.array([ |
| 906 | [x, y, -0.001], |
| 907 | [x + cell_size, y, -0.001], |
| 908 | [x + cell_size, y + cell_size, -0.001], |
| 909 | [x, y + cell_size, -0.001], |
| 910 | ], dtype=np.float32) |
| 911 | faces = np.array([[0, 1, 2], [0, 2, 3]], dtype=np.uint32) |
| 912 | |
| 913 | # Checkerboard pattern |
| 914 | color = color1 if (i + j) % 2 == 0 else color2 |
| 915 | |
| 916 | self.server.scene.add_mesh_simple( |
| 917 | f"/ground/cell_{cell_idx}", |
| 918 | vertices=vertices, |
| 919 | faces=faces, |
| 920 | color=color, |
| 921 | ) |
| 922 | cell_idx += 1 |
| 923 | |
| 924 | # Add grid lines on top for reference |
| 925 | self.server.scene.add_grid( |
| 926 | "/grid", |
| 927 | width=30.0, |
| 928 | height=30.0, |
| 929 | plane="xy", |
| 930 | position=(0, 0, 0), |
| 931 | cell_color=(120, 120, 120), # Gray grid lines |
| 932 | section_color=(100, 100, 100), # Darker section lines |
| 933 | cell_size=2.5, # Match cell size |
| 934 | section_size=5.0, # 5m sections |
| 935 | ) |
| 936 | |
| 937 | # Set up direction (Z-up for visualization, we convert from Y-up ARKit) |
| 938 | self.server.scene.set_up_direction("+z") |
| 939 | |
| 940 | # Initial scene |
| 941 | self._update_scene() |
| 942 | |
| 943 | # Start playback thread |
| 944 | playback_thread = threading.Thread(target=self._playback_loop, daemon=True) |
no test coverage detected