@@ -61,13 +61,6 @@ def send_cam_pose(sock: zmq.Socket, M: np.ndarray):
6161 return sock .recv ()
6262
6363
64- def cmd_clean (sock : zmq .Socket ):
65- """Clean the robot from the renderer. Equivalent to `viz.clean()` on the synchronous `Visualizer` class."""
66- assert sock .socket_type == zmq .REQ
67- sock .send_multipart ([b"cmd_clean" , b"" ])
68- return sock .recv ()
69-
70-
7164class AsyncVisualizer (BaseVisualizer ):
7265 """A visualizer-like client for the candlewick runtime."""
7366
@@ -111,6 +104,11 @@ def rebuildData(self):
111104 def setCameraPose (self , pose : np .ndarray ):
112105 send_cam_pose (self .sync_sock , pose )
113106
107+ def resetCamera (self ):
108+ self .sync_sock .send_multipart ([b"reset_camera" , b"" ])
109+ response = self .sync_sock .recv ().decode ()
110+ assert response == "ok"
111+
114112 def display (self , q : np .ndarray , v : Optional [np .ndarray ] = None ):
115113 """Publish the robot state."""
116114 assert q .size == self .model .nq
@@ -119,7 +117,10 @@ def display(self, q: np.ndarray, v: Optional[np.ndarray] = None):
119117 send_state (self .publisher , q , v )
120118
121119 def clean (self ):
122- cmd_clean (self .sync_sock )
120+ """Clean the robot from the renderer. Equivalent to `viz.clean()` on the synchronous `Visualizer` class."""
121+ self .sync_sock .send_multipart ([b"cmd_clean" , b"" ])
122+ response = self .sync_sock .recv ().decode ()
123+ assert response == "ok"
123124
124125 def close (self ):
125126 self .clean ()
@@ -155,3 +156,19 @@ def enableCameraControl(self):
155156
156157 def drawFrameVelocities (self , * args , ** kwargs ):
157158 raise NotImplementedError ()
159+
160+ def startRecording (self , filename : str ):
161+ """Open a recording to a given file."""
162+ self .sync_sock .send_multipart ([b"start_recording" , filename .encode ("utf-8" )])
163+ response = self .sync_sock .recv ().decode ("utf-8" )
164+ if response != "ok" :
165+ print (f"Visualizer runtime error: { response } " )
166+
167+ def stopRecording (self ):
168+ """
169+ Stop the recording if it's running.
170+
171+ :returns: Whether a recording was actually stopped.
172+ """
173+ self .sync_sock .send_multipart ([b"stop_recording" , b"" ])
174+ return bool (self .sync_sock .recv ())
0 commit comments