Incorrect forces are returned by RigidPrimView.get_net_contact_forces()

I modified the “Hello World” Isaac Example to give the cube a mass of 1.0 kg and to add a RigidPrimView that I can call get_net_contact_forces() on, following advice from here. Gravity is set to 9.81 m/s^2, so the contact force should be 9.81 N. However 1.635e-01 N is reported by Isaac Sim. Code and output below.

class HelloWorld(BaseSample):
    def __init__(self) -> None:
        super().__init__()
        return

    def setup_scene(self):

        world = self.get_world()
        world.scene.add_default_ground_plane()
        fancy_cube = world.scene.add(
            DynamicCuboid(
                prim_path="/World/random_cube",
                name="fancy_cube", 
                position=np.array([0, 0, 1.0]), 
                scale=np.array([0.5015, 0.5015, 0.5015]),
                color=np.array([0, 0, 1.0]),
                mass=1.0
            ))
        self._cube_contact = RigidPrimView(
            prim_paths_expr="/World/random_cube",
            name="cube_vew",
            reset_xform_properties=False,
            track_contact_forces=True,
            prepare_contact_sensors=True,
        )
        world.scene.add(self._cube_contact)
        return

    async def setup_post_load(self):
        self._world = self.get_world()
        self._cube = self._world.scene.get_object("fancy_cube")
        self._world.add_physics_callback("sim_step", callback_fn=self.print_cube_info) 
        return

    def print_cube_info(self, step_size):
        print(self._cube_contact.get_net_contact_forces())

image

I figured this out. get_net_contact_forces() returns a contact impulse and you have to set the parameter dt to convert it to a force. For example:

contact_force = my_rigid_prim_view.get_net_contact_forces(dt=sim_dt)
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.