How to randomize ground plane friction?

I am trying to apply domain randomization (DR) to elements of my simulation and I ran into some issues related to ground friction. It is not possible to add DR noise to the ground plane friction values in the config file as in other parameters.
I see there’s a parameter to randomize the friction inside rigid_shape_properties. As I understand, this should randomize the friction value of the rigid bodies of the loaded model, in which case the simulation will choose whatever value is smaller between two contacts (ground and model’s “feet”) during runtime, correct? However, changing this friction doesn’t seem to have any effect. I tried scaling by huge values or 0 and see no change in the simulation.
Changing the values during the creation of the ground plane does affect the simulation correctly. However, it is not possible to change the ground plane values during runtime? I tried re-creating the ground plane with the add_ground function to no effect.

TL;DR: How to randomize (DR) for ground friction?

1 Like

The best way to randomize friction would be to change robot model link friction. The resulting friction between 2 rigid bodies or a rigid body and plane is not min, but average between these 2 values, so it should work well for your case.

2 Likes

By “change the root model link friction” do you mean the friction parameter under rigid_shape_properties? I don’t notice any difference in the simulation when changing it, even using extreme values like 0 or huge numbers. I only see a difference in the simulation/behavior of the agent when changing static_friction and dynamic_friction of plane parameters. This is using PhysX backend if that’s relevant. Could you provide some clarification on this issue?

Thanks.

1 Like

Hi did you figure out how to randomize the friction between two rigid objects?

I tried to set the friction/rolling_friction/torsion_friction for both the object and the robot model’s link [by setting the rigid_shape_properties] but it doesn’t seem to make any difference.

1 Like

I am having this exact same issue. The rigid_shape_properties friction value does not seem to have any effect. Additionally, why is there not a different parameter for static and dynamic friction within rigid_shape_properties?

As mentioned above, “The resulting friction between 2 rigid bodies or a rigid body and plane is not min, but average between these 2 values,”. So I think if you only change either the friction coeff in rigid_shape_properties or the one in plane_params when calling add_ground(), it will not make distinct difference. Therefore, if you change the coeffs at both places to zero, I supposed that you will see the robot sliding then.

successful setting!
out
我认为这句话有问题:
The resulting friction between 2 rigid bodies or a rigid body and plane is not min, but average between these 2 values
我感觉应该是取地面摩擦和刚体摩擦的最大值
当初始化了env和actor之后再去设置rigid_shape_properties是没有用的,这个和set_actor_dof_properties以及set_actor_rigid_body_properties不一样,后面两个set是可以在actor初始化后进行设置
仅仅设置set_asset_rigid_shape_properties而不设置add_ground的static_friction和dynamic_friction也没用!
下面带**的代码是关键代码
my code:

**rigid_shape_props_asset = self.gym.get_asset_rigid_shape_properties(**
**            robot_asset)**
**for element in rigid_shape_props_asset:**
**            element.friction = 0.01 **
**self.gym.set_asset_rigid_shape_properties(robot_asset,rigid_shape_props_asset)**  
for i in range(self.num_envs):
            # create env instance
            env_handle = self.gym.create_env(self.sim, env_lower, env_upper,
                                             int(np.sqrt(self.num_envs)))
            pos = self.env_origins[i].clone()
            pos[:2] += torch_rand_float(-1., 1., (2, 1),
                                        device=self.device).squeeze(1)
            start_pose.p = gymapi.Vec3(*pos)
            if myglobal.get_value("hangon"):
                start_pose.p.z += 0.8  #悬挂测试
            actor_handle = self.gym.create_actor(
                env_handle, robot_asset, start_pose, self.cfg.asset.name, i,
                self.cfg.asset.self_collisions, 0)
            
            #set friction  USELESS!!!!!!
            #rigid_shape_props = self._process_rigid_shape_props(rigid_shape_props_asset, i)
            # self.gym.set_actor_rigid_shape_properties(env_handle, actor_handle,
            #                                   rigid_shape_props_asset)
            #设置关节 USEFUL
            dof_props = self._process_dof_props(dof_props_asset, i)
            self.gym.set_actor_dof_properties(env_handle, actor_handle,
                                              dof_props)
            #设置重量 USEFUL
            body_props = self.gym.get_actor_rigid_body_properties(
                env_handle, actor_handle)
            body_props = self._process_rigid_body_props(body_props, i)
            self.gym.set_actor_rigid_body_properties(
                env_handle, actor_handle, body_props,
                recomputeInertia=False)  # True

            self.envs.append(env_handle)
            self.actor_handles.append(actor_handle)