Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Proper way to implement domain randomization on actuator gains? #1604

Open
sdfzz opened this issue Dec 27, 2024 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@sdfzz
Copy link

sdfzz commented Dec 27, 2024

Hi,

I'm trying to implement domain randomization on Unitree G1 robot.

To randomize actuator gains, I've added the following to '/manager_based/locomotion/velocity/config/g1/flat_env_cfg.py':

@configclass
class G1Events(EventCfg):    
    actuator_gain = EventTerm(
        func=mdp.randomize_actuator_gains,
        mode="startup",
        params={
            "asset_cfg": SceneEntityCfg("robot", joint_names=".*"),
            "stiffness_distribution_params": (0., 0.),
            "damping_distribution_params": (0., 0.),
            "operation": "add",  
            "distribution": "uniform" 
        },
    )

It is my understanding that this should NOT affect the training since I'm adding zero to actuator stiffness and damping gains.

However, when I run the training, with this added randomization, I get:

Learning iteration 243/3000
Mean reward: -10.49

Without this randomization:

Learning iteration 243/3000
Mean reward: 16.69

So, the new randomization is affecting the training somehow...I've tried this multiple times, and got the same result.

Unless this is a bug, I feel like I'm missing something

Can anyone help?

Any help would be appreciated

Regards,

Steve

@sdfzz
Copy link
Author

sdfzz commented Dec 27, 2024

Hmm, after looking at events.py, I've noticed that (line 338-345):

  # Randomize stiffness
     if stiffness_distribution_params is not None:
         stiffness = actuator.stiffness[env_ids].clone()
         stiffness[:, actuator_indices] = asset.data.default_joint_stiffness[env_ids][:, global_indices].clone()
         randomize(stiffness, stiffness_distribution_params)
         actuator.stiffness[env_ids] = stiffness
         if isinstance(actuator, ImplicitActuator):
             asset.write_joint_stiffness_to_sim(stiffness, joint_ids=actuator.joint_indices, env_ids=env_ids)

Why are we loading default_joint_stiffness before applying randomization?

It seems that this overwrites the stiffness/damping defined in the asset, thus affecting the training

Regards,

Steve

@kellyguo11
Copy link
Contributor

Thanks for the feedback, I think it makes sense to separate the default values from the randomizations, similar to the proposal in #1416.

@kellyguo11 kellyguo11 added the enhancement New feature or request label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants