Creating Random Camera Movement in Replicator's Python API for SDG Graph: Need Help with Branch Nodes

Hello everyone, I’m currently trying to create an SDG (System Dependency Graph) graph using Replicator’s Python API. My goal is to randomly move the camera’s position in every odd-numbered frame, while keeping the camera’s position unchanged in even-numbered frames. To achieve this, my approach involves checking the remainder when dividing the frame number by 2 in the on_frame event, and only applying a random camera movement when the remainder is 1.

However, I’m facing a challenge because it’s not straightforward to use the with context in Branch nodes within the Replicator API. I’m uncertain about how to implement this with the Replicator API.

I’d appreciate any guidance or suggestions on how to achieve this. Thank you for your assistance.

from omni.replicator.core import utils
import omni.replicator.core as rep

with rep.new_layer():
    camera =,f_stop=0.5)
    with rep.trigger.on_frame(num_frames=10) as event:
        n_frames = utils.create_node("omni.graph.nodes.ConstantInt")
        modulo = utils.create_node("omni.graph.nodes.Modulo")
        event.node.get_attribute("outputs:frameNumber").connect(modulo.get_attribute("inputs:a"), True)
        n_frames.get_attribute("inputs:value").connect(modulo.get_attribute("inputs:b"), True)
        branch = utils.create_node("omni.graph.action.Branch")

        event.node.get_attribute("outputs:execOut").connect(branch.get_attribute("inputs:execIn"), True)
        modulo.get_attribute("outputs:result").connect(branch.get_attribute("inputs:condition"), True)
        with branch:
            cam_position_edit = rep.modify.pose(position=rep.distribution.uniform((-500, 200, -500), (500, 500, 500)), look_at=(0,0,0))

Before you try something complicated, it might just be as easy as setting the interval to 2, so your frames only execute on odd frames. Let me know if this doesn’t suit what you’re trying to do.

On a related note, its really great to see you’re using the omnigraph nodes explicitly. If you have thoughts on how pure node workflows could be better I’d love to hear them. Its a workflow I’m working on and encouraging internally for the replicator team.