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

Full Reload of Sim without closing window? #25

Open
rohit-kumar-j opened this issue Sep 26, 2022 · 2 comments
Open

Full Reload of Sim without closing window? #25

rohit-kumar-j opened this issue Sep 26, 2022 · 2 comments

Comments

@rohit-kumar-j
Copy link
Contributor

This might be a breaking change:

# pass in the xml path to the viewer directly and upon KEY_BACKSPACE, reload the sim
viewer = viewer.MujocoViewer(xml_path="Projects/rjax_python/robots/humanoid/scene.xml")
while True:
        mujoco.mj_step(viewer.model, viewer.data)
        viewer.render()

Each time the model and data have to be accessed, they have to be done via viewer.model and viewer.data. The examples, etc need to change. Would this PR be okay? (Of course, the changes will be reflected in the README and examples)

Need for this/Use case:

No relaunching of the python script for .xml tweaking, no need to use simulate.cc for the same

Implementation Example:

mujoco_full_reload_method.mp4

(If the video stops in the middle, kindly scrub manually to the end. The video may be corrupted)

@rohanpsingh
Copy link
Owner

Thanks for the nice demo @rohit-kumar-j !
Yes, it's quite a big change (and I'm still looking at your other PR, sorry for the delay).

Don't you think it's better to let simulate.cc handle features like this? As far as I know, there are soon going to be python bindings for simulate.cc, which would make this a redundant feature.
What do you think?

@rohit-kumar-j
Copy link
Contributor Author

Yes, simualte.cc's python counterpart might most likely be able better to handle features like reloading simulation. Perhaps this would be only temporary.

I guess I haven't explained my reasoning for #23, especially in the context of the new simulate.cc viewer's implementation in python. I hope I can faithfully do so here:

I don't see this repo a replica of simulate.cc's. I see this as a more easy-to-use and functional viewer as opposed to feature loaded (like simulate). There are a few things that I have noticed when developing/preparing xml files (I guess this is more of a workflow thing than a number of features in thing, Hence all the PRs 😅)

  • simulate.cc has too many options which clutter the window(of course we can close this with Tab and turn features on or off by clicking on them), Not sure how this will be handled within the new simulate(.py?/.so?) .
  • When implementing/testing a Stable-PD strategy, It was necessary to use the force visualization and the graphing utilities to be able to see what happens especially at boundary conditions(eg: contact with the floor, force is applied but the end effector does not move).
  • It was also necesssary to graph multiple things including internally and exteranlly generated signals(like sinewaves), preferablly with a time-axis.
  • While editing the XML file, It was tedious to restart the script each time instead of just reloading the model and data. This was especially useful while attending to minor modifications required the robot file.(For example modifying the location of sites or joint limits and viewing while script executes) (This issue)
  • For launching multiple scripts, it made sense to pre-position the windows in a fixed location instead of manually repositioning them.(Will soon add a demo below)

PS: I have not seen the src code/used the python version of the simulate.cc. (perhaps it is this.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants