mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

simulating joint backlash

Open le-horizon opened this issue 2 years ago • 2 comments

Hi mujoco gurus,

I'm an engineer and I'm trying to use MuJoCo for sim2real transfer in Go1 quadruped.

I'm looking for some help with backlash simulation.

Here is a model that we created to simulate the backlash following this page as well as joint equality:

<xml>
    <default>
        <joint damping="1.0" armature="0.01" frictionloss="0.2" />

        <default class="backlash">
            <joint damping="0.0" armature="0.0" frictionloss="0.0"
                   limited="true" range="-0.04 0.04"/>
        </default>

        <equality solref=".1 1" solimp="0.1 0.99 0.04 0.5 3.0" />        
    </default>


    <worldbody>
        <joint name="FR_calf_joint" pos="0 0 0" axis="0 1 0" limited="true" range="-2.69653 -0.916298" />
        <joint name="FR_calf_joint_b" pos="0 0 0" axis="0 1 0" class="backlash" />
    </worldbody>

    <equality>
        <joint joint1="FR_calf_joint_b"/>
    </equality>
    
</xml>

However, we are not able to create the backlash effect in simulation (blue curve). Green is physical readings from a step response (dashed line is the command, and each tick in x-axis is 5ms). See screenshot: img_v2_a4c0d93c-d177-447c-b6f1-8875ca3a897g

We confirmed with the manufacturer that the sensor readings are from the output gears, but there could be mechanical interference from other parts (e.g. a lever after the output gear) causing this move-stop-move effect (which looks like pre-gear backlash). The plotted simulation curves are from sensor readings of the joint. In such a case, what parameters can we tweak to simulate this "backlash" effect?

Is it possible to have the sensor read out the pre-gear readings, so it's similar to the real backlash?

We've also tried plotting the sensor readings as well as the qpos of the two joints (original and shadow), they do not seem to make sense to us. Sensor reading != qpos + qpos_b. Could someone explain what's going on? How is sensor reading computed, is it based on qpos and qpos_b?

2023-07-19 15:14:54.288 | INFO | foxy.mujoco_agent:read:180 - -------------------- 2023-07-19 15:14:54.288 | INFO | foxy.mujoco_agent:read:181 - sensor = -1.7749549857460385 2023-07-19 15:14:54.288 | INFO | foxy.mujoco_agent:read:182 - qpos = -1.769121879011308 2023-07-19 15:14:54.288 | INFO | foxy.mujoco_agent:read:183 - qpos_b = -0.04833542130998575 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:180 - -------------------- 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:181 - sensor = -1.769121879011308 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:182 - qpos = -1.76386839600179 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:183 - qpos_b = -0.04874816118409169 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:180 - -------------------- 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:181 - sensor = -1.76386839600179 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:182 - qpos = -1.7592229302175098 2023-07-19 15:14:54.307 | INFO | foxy.mujoco_agent:read:183 - qpos_b = -0.04923959357205287 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:180 - -------------------- 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:181 - sensor = -1.7592229302175098 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:182 - qpos = -1.7552189310423365 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:183 - qpos_b = -0.049796946315089664 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:180 - -------------------- 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:181 - sensor = -1.7552189310423365 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:182 - qpos = -1.751879114829859 2023-07-19 15:14:54.308 | INFO | foxy.mujoco_agent:read:183 - qpos_b = -0.05040694388060367 2023-07-19 15:14:54.327 | INFO | foxy.mujoco_agent:read:180 - -------------------- 2023-07-19 15:14:54.327 | INFO | foxy.mujoco_agent:read:181 - sensor = -1.751879114829859 2023-07-19 15:14:54.327 | INFO | foxy.mujoco_agent:read:182 - qpos = -1.7492145623362705 2023-07-19 15:14:54.327 | INFO | foxy.mujoco_agent:read:183 - qpos_b = -0.05105544032121813

Thanks, Le

Ps, the backlash happens during the step response of the quadruped standing up, not when crouching down. This is very counter intuitive, as one would think that backlash should happen in the reverse direction of the gears' tension, so should happen when it is crouching down. This strange behavior is observed in both calf and thigh joints. We're following up with the manufacture for this.

le-horizon avatar Jul 20 '23 16:07 le-horizon

Any luck with this? I'm stuck in the same boat here :(

Cobular avatar Dec 12 '23 01:12 Cobular

We stopped using joint velocity as input, relying only on frame stacked joint position. This, plus all the domain randomizations reduces the policy's sim2real gap.

le-horizon avatar Dec 12 '23 03:12 le-horizon