Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print text on viewer window #1864

Open
hanyang9 opened this issue Jul 30, 2024 · 5 comments
Open

Print text on viewer window #1864

hanyang9 opened this issue Jul 30, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers question Request for help or information

Comments

@hanyang9
Copy link

Hello, I'm using the mujoco pybinding 3.0.1 and it's passive viewer to do some RL tasks. Could someone tell me how to print text on it?
I tried mjr_overlay but I don't really understand the context and viewport part so it didn't work.
I would appreciate it a lot if anyone could help me.

@hanyang9 hanyang9 added the question Request for help or information label Jul 30, 2024
@yuvaltassa
Copy link
Collaborator

I'm not sure about the passive viewer, but it would be pretty easy to add this functionality to the regular mujoco.Renderer. Would that serve your needs?

@hanyang9
Copy link
Author

I'm not sure about the passive viewer, but it would be pretty easy to add this functionality to the regular mujoco.Renderer. Would that serve your needs?

Thanks for your reply ^^.
Actually I can do that using the other viewer like mujoco-python-viewer, but some of my codes are deeply related to the native passive viewer, so I want to implement this functionality on it.

@hanyang9 hanyang9 reopened this Jul 30, 2024
@hanyang9
Copy link
Author

Another choice for me is to use mujoco-python-viewer instead.
But when I use time.sleep in the simulation loop trying to make the animation slower, the mouse perturb in mujoco_python_viewer is also delayed while it's fine in the passive viewer.
Like this:

                # with mujoco_python_viewer
                for _ in range(int(self.mocap.dt/model.opt.timestep)):
                    mujoco.mj_step(model, data)
                    viewer.render()
                    time.sleep(model.opt.timestep * 10)
                # with passive_viewer
                for _ in range(int(self.mocap.dt/model.opt.timestep)):
                    mujoco.mj_step(model, data)
                    viewer.sync()
                    time.sleep(model.opt.timestep * 10)

So if someone could help me with this, it would be a very nice solution too.

@kevinzakka kevinzakka added enhancement New feature or request good first issue Good for newcomers labels Aug 30, 2024
@saran-t
Copy link
Member

saran-t commented Sep 19, 2024

Sorry for the late reply, I'm currently off work and just noticed this.

IIRC it should be possible to add text labels as mjvGeoms into user_scn in the passive viewer.

@hanyang9
Copy link
Author

Oh, I tried this, it's really nice! Through mujoco.mjtGeom.mjGEOM_LABEL, I can show text in the scene. Actually I was just going to print some text on the 2D UI in passive viewer, but this is also great.
Thanks very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers question Request for help or information
Projects
None yet
Development

No branches or pull requests

4 participants