Replies: 1 comment
-
Your fix is solid, and I can see how for some PD controllers the current off-by-1 design is an issue. Another way of doing it would be to pull out the actuators from Using MuJoCo's own callbacks (e.g., The way it can be made to work right now: you write the callback in C/C++ and add an "assignment" function in this module that assigns the callback function pointer to the MuJoCo library's global callback variable (e.g., |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm really impressed with the state of the Unity Plugin! I've been having trouble with the stability of PD controllers even at moderate gains. Futhermore, I tried implementing my own update law.
I'm still building my understanding of the simulation loop, with help from the guidance on the Programming page of the docs. In the Unity plugin are the inputs of actuators through the
Control
property only sent to the simulation whenMjScene
callsSyncUnityToMjState()
? If so, could the instability be related to that since then the control is updated aftermj_step()
has fully finished as opposed to in between ofmj_step1
andmj_step2
?I tried some ad-hoc changes in
MjScene.StepScene()
and added anEventHandler
that C# scripts can hook into (calledctrlCallback
below).MjStepArgs
is anEventArgs
that has the Model and Data pointers, with which the control laws can be evaluated.Here's the edited method (with calls to the profiler omitted)
From early tests this seems to lead to more stable evaluation for custom PD control. Is this an appropriate approach to implement control laws with the Unity Plugin? Or am I misinterpreting/abusing the plugin?
I know something similar exists with
mjcb_control
, but I couldn't find how to use it in the plugin.Beta Was this translation helpful? Give feedback.
All reactions