Dynamic modification of "solref" has no effect in MuJoCo engine

Typically: "How do I... ", "How can I... " questions
Post Reply
Marty
Posts: 5
Joined: 08 Jul 2025, 08:13

Dynamic modification of "solref" has no effect in MuJoCo engine

Post by Marty »

Hello everyone,

I’m facing a perplexing issue with MuJoCo’s solref parameters in a robotic arm force-control scenario, and I hope to clarify the contradiction I’ve observed to get targeted help.

Background
I’m simulating a scenario where:
    A robotic arm whose end effector maintains stable constant-force contact with a wall.
      The arm moves at a constant velocity along the X-axis while preserving this contact force

      What I Did
      I tested two scenarios for setting the wall’s MuJoCo "solref" parameters—with drastically different results:
        Static solref Setup (At Simulation Start)
        If I set the wall’s "solref" to my target values before starting the simulation, the behavior matches my expectation:
        The arm’s end effector loses stable contact once the simulation runs. Oscillations occur (as intended), confirming the solref values themselves are effective at disrupting constant-force stability.
          Dynamic solref Adjustment (Mid-Simulation)
          However, if I first let the simulation run normally (establishing stable constant-force contact for ~5 seconds), then use sim.setFloatArrayProperty() to adjust the wall’s "solref" to the exact same values as the static setup:
          The simulation shows no change whatsoever.
          The end effector continues to maintain stable constant-force contact, with no oscillations or force deviations—even though the parameter values are identical to the static scenario.

          What I’ve Verified So Far
            Engine & Object Validity: Confirmed the physics engine is set to MuJoCo (not ODE/Bullet), and the wall is a valid collision object (both Collisionable and Respondable enabled).
              Parameter Update Check: Used sim.getFloatArrayProperty() post-adjustment to confirm the wall’s solref values are updated to the target values mid-simulation.
                Force Control Logic: No changes were made to the arm’s force-control code between the two scenarios—only the timing of "solref" setup differs.

                System Info
                CoppeliaSim Version: 4.10
                Operating System: Windows 11
                Physics Engine: MuJoCo

                I can’t figure out why the "solref" adjustment isn’t affecting the simulation. Has anyone encountered a similar issue, or does anyone know potential reasons?

                Any suggestions or troubleshooting tips would be greatly appreciated. Thank you!
                coppelia
                Site Admin
                Posts: 10804
                Joined: 14 Dec 2012, 00:25

                Re: Dynamic modification of "solref" has no effect in MuJoCo engine

                Post by coppelia »

                Hello,

                firs make sure that the XML file generated reflects the SOLREF change you made. You can inspect the generated XML files in the folder you get with this command:

                Code: Select all

                sim.getStringProperty(sim.handle_app, 'mujocoPath')
                I suspect that your XML file simply isn't re-generated. A re-generation happens when e.g. you add/remove and object, change the scene hierarchy, inject XML code, or set the dynamic refresh flag. See also the following int property:

                Code: Select all

                sim.getIntProperty(sim.handle_scene, 'mujoco.rebuildTrigger')
                In your case, the easiest would be to call sim.resetDynamicObject upon the modified object.

                Cheers
                Marty
                Posts: 5
                Joined: 08 Jul 2025, 08:13

                Re: Dynamic modification of "solref" has no effect in MuJoCo engine

                Post by Marty »

                Thank you for your reply! Your suggestions really address my problems—I really appreciate it!
                Post Reply