rohanpsingh / mujoco-python-viewer

Simple renderer for use with MuJoCo (>=2.1.2) Python Bindings.
BSD 2-Clause "Simplified" License
163 stars 24 forks source link

Code simplification, kinematic loop example #5

Closed rohit-kumar-j closed 1 year ago

rohit-kumar-j commented 2 years ago

Added a Kinematic Loop example Simplified the mujoco_viewer.py with callbacks in another file. Auto creates a root/tmp (unless root/tmp exists) to save screen captures in it.

TODO: No.2 in #4

rohanpsingh commented 2 years ago

Hi @rohit-kumar-j Thanks for the PR.

I have several comments and some questions.

rohit-kumar-j commented 2 years ago

Why do you want to put the callbacks in another file? The code is pretty straightforward as-is and easy to follow. Unless the callbacks are needed to be used in another place, I'm not sure if breaking the file into 2 has any use.

I was adding graphs, and thought it would be easier to restructure the code to reduce the cluttering up a single file

It might be better to save the screencap frames under $HOME/.mujoco-viewer, so a new directory is not created each time the user changes to a new os.getcwd()

This is a better idea. will do.

The Kinematic Loop example may be useful for other users too. Can you create a separate PR for the example?

Certainly

rohit-kumar-j commented 2 years ago

Graphing example in examples/graphs.py in a dev branch. not ready or pr yet.

Preview: The sinewave is a custom data_stream with math.sin(x) Rest of them are sensor data

https://user-images.githubusercontent.com/37873142/171003530-540fbb9a-ac88-435f-894d-69febb817b36.mp4

rohanpsingh commented 2 years ago

Looks good, I will take a look at your branch in a few days!