Can not change camera pose

Hello,I’m tring to use rep.distribution.uniform to change the camera pose, but the pose it generate never change, how to change the camera pose when using the replicator? my code is as follow:

with rep.new_layer():
    plane = rep.create.plane(scale=100, visible=True)
    port = rep.create.from_usd(path, semantics=[("class", "port")])
    camera = rep.create.camera(
        # position=(1,0.5,36),
        position=rep.distribution.uniform((0.9, 0.4, 10), (1.1, 0.6, 40)),
        rotation=(-90, -90, 0), 
        focus_distance=rep.distribution.normal(400.0, 100),
        f_stop=0,
        look_at=port
    )

def get_CameraDR():
    with camera:
        rep.modify.pose(
             position=rep.distribution.uniform((-5, -5, 0), (5, 5, 0)),
             #rotation=rep.distribution.uniform((0, -90, 0), (0, -90, 180)),
             look_at=port
        )
    return camera.node


def start(name):
    rep.randomizer.register(get_CameraDR)
    with rep.trigger.on_frame(num_frames=30):
        rep.randomizer.get_CameraDR()

if __name__ == '__main__':
    start('PyCharm')

whether in the create function or in the randomizer , the pose never change. My isaac sim version is 2022.2.0,and the code is run in script editor

Hi there,

the following script worked from my side. Once you press Replicator → Step the Xform of the camera changes location.

import omni.replicator.core as rep

with rep.new_layer():
    plane = rep.create.plane(scale=100, visible=True)
    camera = rep.create.camera(
        position=rep.distribution.uniform((0.9, 0.4, 10), (1.1, 0.6, 40)),
        rotation=(-90, -90, 0), 
        focus_distance=rep.distribution.normal(400.0, 100),
        f_stop=0,
    )

def get_CameraDR():
    with camera:
        rep.modify.pose(
             position=rep.distribution.uniform((-5, -5, 0), (5, 5, 0)),
        )
    return camera.node


def start(name):
    rep.randomizer.register(get_CameraDR)
    with rep.trigger.on_frame(num_frames=30):
        rep.randomizer.get_CameraDR()
        
if __name__ == '__main__':
    start('PyCharm')

Let me know if you still have issues.

1 Like

Hi, I have tested your code,It can work in 2022.2.0 ,maybe it’s the ‘look_at’ in my code affect the program.

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