Skip to content

Commit

Permalink
Add static rendering in MujocoVisualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
flferretti committed Feb 14, 2024
1 parent 0ea14af commit d3514da
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/jaxsim/mujoco/visualizer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import contextlib
import pathlib
from typing import ContextManager
from typing import ContextManager, Sequence, Union

import mediapy as media
import mujoco as mj
Expand Down Expand Up @@ -150,3 +150,18 @@ def open(
yield handle
finally:
handle.close() if close_on_exit else None

def render_static(
self,
height: int = 240,
width: int = 320,
) -> Union[Sequence[npt.NDArray], npt.NDArray]:
""""""

renderer = mujoco.Renderer(model=self.model, height=height, width=width)

data = mujoco.MjData(self.model) or self.data

mujoco.mj_forward(self.model, data)
renderer.update_scene(data, camera_name)
return renderer.render()

0 comments on commit d3514da

Please sign in to comment.