How Can I use On Physics Step Node?

I would like to use a contact sensor at physics step.
So I create the Omni Graph below.
But It didn’t work.

I get the Error below.

2024-08-18 08:01:40  [Error] [omni.isaac.core_nodes] Physics OnSimulationStep node detected in a non on-demand Graph. Node will only trigger events if the parent Graph is set to compute on-demand. (/World/sample_robot_1/armor1_link/Contact_Graph/on_physics_step))

How can I use On Physics Step Node?

I need to set the Graph to on-demand Graph.
Below is my script.

import omni.graph.core as og
from omni.graph.core import GraphPipelineStage

keys = og.Controller.Keys
(ros_contact_graph, _, _, _) = og.Controller.edit(
    {
        "graph_path": prim_path + "/Contact_Graph",
        "evaluator_name": "execution",
        "pipeline_stage": GraphPipelineStage.GRAPH_PIPELINE_STAGE_ONDEMAND,
    },
    {
        keys.CREATE_NODES: [
            ("OnPhysicsStep", "omni.isaac.core_nodes.OnPhysicsStep"),
            ("readContactSensor", "omni.isaac.sensor.IsaacReadContactSensor"),
            ("publishSensorValue", "omni.isaac.ros2_bridge.ROS2Publisher"),
        ],
        keys.CONNECT: [
            ("OnPhysicsStep.outputs:step", "readContactSensor.inputs:execIn"),
            ("readContactSensor.outputs:execOut", "publishSensorValue.inputs:execIn"),
        ],
        keys.SET_VALUES: [
            ("readContactSensor.inputs:csPrim", prim_path + "/Contact_Sensor"),
            ("publishSensorValue.inputs:messageName", "Bool"),
            ("publishSensorValue.inputs:messagePackage", "std_msgs"),
            ("publishSensorValue.inputs:topicName", prim_path + "/" + child.find("topic").text),
        ],
    },
)
og.Controller.connect(prim_path + "/Contact_Graph/readContactSensor.outputs:inContact", prim_path + "/Contact_Graph/publishSensorValue.inputs:data")

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