MCPcopy Create free account
hub / github.com/Improbable-AI/VisionProTeleop / update_sim

Method update_sim

avp_stream/streamer.py:3148–3198  ·  view source on GitHub ↗

Sync current simulation state to the VisionPro. Call this after each simulation step to update the 3D visualization. Works with both MuJoCo (configure_mujoco) and Isaac Lab (configure_isaac). Example (MuJoCo):: while True:

(self)

Source from the content-addressed store, hash-verified

3146 return bodies
3147
3148 def update_sim(self):
3149 """
3150 Sync current simulation state to the VisionPro.
3151
3152 Call this after each simulation step to update the 3D visualization.
3153 Works with both MuJoCo (configure_mujoco) and Isaac Lab (configure_isaac).
3154
3155 Example (MuJoCo)::
3156
3157 while True:
3158 mujoco.mj_step(model, data)
3159 streamer.update_sim()
3160
3161 Example (Isaac Lab)::
3162
3163 while simulation_app.is_running():
3164 sim.step()
3165 streamer.update_sim()
3166 """
3167 # Check which simulation backend is configured
3168 is_isaac = self._isaac_stage is not None
3169 is_mujoco = self._mujoco_model is not None and self._mujoco_data is not None
3170
3171 if not is_isaac and not is_mujoco:
3172 self._log("[SIM] Warning: No simulation configured. Call configure_mujoco() or configure_isaac() first.", force=True)
3173 return
3174
3175 if not self._pose_stream_running:
3176 # Pose streaming not started yet
3177 return
3178
3179 # Get current poses based on backend
3180 if is_isaac:
3181 poses = self._get_isaac_poses()
3182 qpos = [] # Isaac doesn't have a simple qpos equivalent
3183 ctrl = []
3184 else:
3185 poses = self._get_mujoco_poses()
3186 qpos = self._mujoco_data.qpos.tolist()
3187 ctrl = self._mujoco_data.ctrl.tolist()
3188
3189 timestamp = time.time()
3190
3191 # Update the current poses that the streaming thread will send
3192 with self._pose_stream_lock:
3193 self._current_poses = {
3194 "poses": poses,
3195 "qpos": qpos,
3196 "ctrl": ctrl,
3197 "timestamp": timestamp,
3198 }
3199
3200 def _get_mujoco_poses(self) -> Dict[str, Dict[str, Any]]:
3201 """Get current MuJoCo body poses as a dictionary.

Callers 14

run_frequency_sweepFunction · 0.95
run_body_count_sweepFunction · 0.95
run_continuous_testFunction · 0.95
run_roundtrip_testFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95
16_spot_demo.pyFile · 0.80
reset_simulationFunction · 0.80

Calls 3

_logMethod · 0.95
_get_isaac_posesMethod · 0.95
_get_mujoco_posesMethod · 0.95

Tested by 5

run_frequency_sweepFunction · 0.76
run_body_count_sweepFunction · 0.76
run_continuous_testFunction · 0.76
run_roundtrip_testFunction · 0.76