Balint-H / mj-unity-tutorial

Introductory set of tutorials for using the Unity plugin of MuJoCo with the ML-Agents framework.
33 stars 0 forks source link

General questions #2

Closed DinoDany closed 1 year ago

DinoDany commented 1 year ago

Great tutorial! I just have some general questions about how the mujoco-unity interface works. So,

do we need to create the data structures in an "unsafe" mode so both Mujoco and Unity and access it? When I was trying different memory sizes, my clipboard stopped working (it will copy random things) . Was that because of the unsafe access to memory?

In the RL Basics 3/7, is brain Parameters and behavior parameter the same?

Balint-H commented 1 year ago

The unsafe keyword in this project is required when accessing fields from MjScene.Data or MjScene.Model. You are right this is because this is shared memory between the two processes (so some third process may try to interfere/modify the same data before its accessed, or you may accidentally access the wrong parts of the memory, which are some of the reasons its unsafe). A good amount of c++ code would be considered "unsafe" by c# standards. By adding this keyword you are telling the compiler that you are aware of whats going on, and happy to mess around with pointers.

By memory sizes do you mean different values for the size fields in MjGlobalSettings? Also do you mean your actual system clipboard that you use to copy text? That should not be affected by Mujoco or Unity. Maybe if you set it too high an you were running short on RAM?

A handy set of extension methods can be created that can expose the data you need frequently (I plan to release some I have in a heper class, but wanted to keep the codebase as small as possible for now).

I'll get back to you on the last question soon

Balint-H commented 1 year ago

I see, indeed BrainParameters was the old name of the BehaviorParameters component, but that now refers to something else in ML-Agents. So that was a typo on my part, I'll fix it in my next push! Thanks for finding it (lets keep this issue open until then).

DinoDany commented 1 year ago

Hi! Yes, I mean the size value in MjGlobal Settings and the actual clipboard used on my computer to copy and paste. I see, yeah, it was weird, but it is not happening anymore.

Yes, sharing the methods to expose data will be incredibly valuable! Thank you so much