Applying measurable perturbations on key presses #2214
Replies: 2 comments
-
I somewhat managed to implement it by applying the force in the void PhysicsLoop(mj::Simulate& sim) function in app.cc in MJPC instead of on button presses, and applying a force in the opposite direction after a certain delay. |
Beta Was this translation helpful? Give feedback.
-
What you're doing is reasonable. Another way to do it is to do what you did earlier, but upon keypress, save a local variable that means the time at which you want to clear the force, and then clear it yourself in the physics loop. The general issue that you are facing is that what you want to do is a stateful thing, while this API is stateless by design (well, besides mjData.qfrc_applied). So it is indeed up to you to stop applying the force at your discretion. Another solution is to do |
Beta Was this translation helpful? Give feedback.
-
Intro
Hi!
I am a graduate student at TU Delft, and I use MuJoCo to develop controllers that are robust against perturbations for bipedal robots.
My setup
I'm using mujoco 3.2.4 on Ubuntu 22.04 with the C API. I'm also using MJPC to develop and test the MPCs.
My question
I want to implement forces that have a consistent direction and magnitude. For this I'm trying to use the mj_applyFT as mentioned in this discussion, when pressing on a certain key. This (very likely because of the way I implemented it) is a persistent force that doesn't stop acting on the body. I've also looked at mjv_applyperturbforce but I'm unsure how this can be used to implement this. I've looked at using force sensors and using the base right click and drag implementation but I can't consistently recreate the same force every time.
My question is:
Is there a better way to implement this so that it acts as a perturbation rather than a consistent force?
Minimal model and/or code that explain my question
Currently I'm implementing this in the UIEvent function in simulate.cc, using different key press events for different forces. For example:
Confirmations
Beta Was this translation helpful? Give feedback.
All reactions