# Stereo camera setup with the replicator

**URL:** <https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345>\
**Category:** Isaac Sim\
**Tags:** synthetic-data\
**Created:** [July 29, 2022, 2:46pm UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345 "2022-07-29T14:46:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.lindemeier2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@thomas.lindemeier2](https://forums.developer.nvidia.com/u/thomas.lindemeier2)\
**Post date:** [July 29, 2022, 2:46pm UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/1 "2022-07-29T14:46:49Z")

</div>

Hey there,

how would I implement a stereo camera setup with the replicator SDK? I’ve implemented already something similar for Isaac Sim using pure USD. I want to make use of the awesome features of the replicator SDK, but I am not sure how to implement it.

My current guess is to create a parent Xform with something like this:

```python
def stereo_camera(position, look_at):
    return rep.create._create_prim(prim_type="Xform", position=position, look_at=look_at)

rep.create.register(stereo_camera)

```

This parent Xform would then be randomized and the stereo cams should just stay static relative to this Xform. The parent/child transformation is clear to me, since I’ve already implemented something similar in USD already, as already mentioned. The question that I have is, how do I attach the two cameras to this Xform while also using them to create the render products:

```python
render_product = rep.create.render_product(camera, (1024, 768))

```

The parameters of the camera may be constant for each run for now. Only the parent transformation should be randomized.

Any info and details would be very welcome.

Thx in advance,

Thomas

---

<div class="post-metadata">

**Author:** ![thomas.lindemeier2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@thomas.lindemeier2](https://forums.developer.nvidia.com/u/thomas.lindemeier2)\
**Post date:** [August 1, 2022, 11:00am UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/2 "2022-08-01T11:00:36Z")

</div>

I think I’ve figured out how to approach this. I just use my USD implementation of the stereo cam attached to an XForm and then use the replicator to randomize the position and rotation using the `modify.pose`. Then I attach a RenderProduct to each camera via sdf path and create a basic writer for each render product (a list of cameras is not supported yet by the basic writer).

```python
camera_rig = CameraStereo(Sdf.Path("/World/CameraStereo")
with rep.trigger.on_frame(num_frames=5):
                rep.modify.pose(position=rep.distribution.uniform(
                    lower=(-80, 150, 80), upper=(80, 200, 150)),
                                look_at="/World/Cube",
                                input_prims=[camera_rig.get_path()])

```

If I run this through my extension, I get the following errors:

```nohighlight
2022-08-01 10:57:09 [59,899ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,917ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,917ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,918ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,918ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,919ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,919ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,919ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,920ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,920ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,921ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,921ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,922ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [59,925ms] [Warning] [carb.flatcache.plugin] Error: array of rel not yet supported
2022-08-01 10:57:09 [59,925ms] [Error] [carb.flatcache.plugin] Error: /World/CameraStereo/CameraLeft.xformOpOrder UsdRelationship not supported in GetPrimArrayAttr

2022-08-01 10:57:09 [59,941ms] [Info] [omni.kit.menu.utils.scripts.utils] omni.kit.menu.utils.refresh_menu_items Window False
2022-08-01 10:57:09 [59,949ms] [Info] [omni.kit.menu.utils.scripts.utils] omni.kit.menu.utils.refresh_menu_items Window False
2022-08-01 10:57:09 [59,950ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order

2022-08-01 10:57:09 [59,975ms] [Info] [omni.replicator.core.scripts.backends.log] [tid 140514243839808][backends][disk.py] Writing data to /tmp/revip_out/camera_0
2022-08-01 10:57:09 [59,986ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [60,001ms] [Info] [omni.kit.window.viewport.plugin] AOV LdrColorSD already added to viewport window
2022-08-01 10:57:09 [60,007ms] [Info] [omni.kit.window.viewport.plugin] AOV DistanceToImagePlaneSD already added to viewport window
2022-08-01 10:57:09 [60,019ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order

2022-08-01 10:57:09 [60,031ms] [Info] [omni.replicator.core.scripts.backends.log] [tid 140514243839808][backends][disk.py] Writing data to /tmp/revip_out/camera_1
2022-08-01 10:57:09 [60,040ms] [Info] [carb] Plugin omni.hydra.scene_delegate.plugin already has a dependency relationship on omni.stageupdate.plugin; not changing unload order
2022-08-01 10:57:09 [60,052ms] [Info] [omni.kit.window.viewport.plugin] AOV LdrColorSD already added to viewport window
2022-08-01 10:57:09 [60,059ms] [Info] [omni.kit.window.viewport.plugin] AOV DistanceToImagePlaneSD already added to viewport window
2022-08-01 10:57:09 [60,081ms] [Error] [omni.graph.core.plugin] Tried to end scheduler for a sync scope which does not exist.
2022-08-01 10:57:09 [60,081ms] [Error] [omni.graph.core.plugin] Tried to end scheduler for a sync scope which does not exist.
2022-08-01 10:57:09 [60,081ms] [Error] [omni.usd] HydraEngine::render failed to end the compute graph: error code 6
2022-08-01 10:57:09 [60,094ms] [Info] [rtx.multigpumanager.plugin] View 1 (/Render/RenderProduct_Viewport_2) assigned to device 0
2022-08-01 10:57:09 [60,094ms] [Info] [rtx.multigpumanager.plugin] View 1 (/Render/RenderProduct_Viewport_2) switching to 1x1 layout
2022-08-01 10:57:09 [60,124ms] [Info] [rtx.multigpumanager.plugin] View 0 (/Render/RenderProduct_Viewport) assigned to device 0
2022-08-01 10:57:09 [60,124ms] [Info] [rtx.multigpumanager.plugin] View 0 (/Render/RenderProduct_Viewport) switching to 1x1 layout
2022-08-01 10:57:09 [60,168ms] [Info] [rtx.multigpumanager.plugin] View 0 (/Render/RenderProduct_Viewport) assigned to device 0
2022-08-01 10:57:09 [60,168ms] [Info] [rtx.multigpumanager.plugin] View 0 (/Render/RenderProduct_Viewport) switching to 1x1 layout
2022-08-01 10:57:09 [60,186ms] [Info] [rtx.multigpumanager.plugin] View 0 (/Render/RenderProduct_Viewport) assigned to device 0
2022-08-01 10:57:09 [60,186ms] [Info] [rtx.multigpumanager.plugin] View 0 (/Render/RenderProduct_Viewport) switching to 1x1 layout
2022-08-01 10:57:09 [60,186ms] [Info] [rtx.multigpumanager.plugin] View 1 (/Render/RenderProduct_Viewport_2) assigned to device 0
2022-08-01 10:57:09 [60,186ms] [Info] [rtx.multigpumanager.plugin] View 1 (/Render/RenderProduct_Viewport_2) switching to 1x1 layout

```

There is no randomization of the pose and rotation at all when previewing and running the replicator. Any ideas what could be wrong here?

---

<div class="post-metadata">

**Author:** ![thomas.lindemeier2](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@thomas.lindemeier2](https://forums.developer.nvidia.com/u/thomas.lindemeier2)\
**Post date:** [August 2, 2022, 7:02am UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/3 "2022-08-02T07:02:34Z")

</div>

I found a solution by creating the parent Xform of the two cams using the replicator as follows:

```python
self.node = rep.create._create_prim(prim_type="Xform",
                                            position=world_translation,
                                            rotation=orientation)

```

Now, I can use the replicator functionality. The only thing that i haven’t figured out, yet, is how the sdf path of a `ReplicatorItem`can be retrieved.  
I just hardcode if for now to what is done in the `_create_prim` function:

```python
self.camera_rig_path = Sdf.Path("/Replicator/Xform")

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [August 21, 2022, 6:17pm UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/5 "2022-08-21T18:17:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hammad\_M](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/hammad_m/32/14047_2.png) [@Hammad\_M](https://forums.developer.nvidia.com/u/Hammad_M)\
**Post date:** [August 26, 2022, 4:38pm UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/6 "2022-08-26T16:38:13Z")

</div>



---

<div class="post-metadata">

**Author:** ![jiehanw](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@jiehanw](https://forums.developer.nvidia.com/u/jiehanw)\
**Post date:** [August 26, 2022, 5:21pm UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/7 "2022-08-26T17:21:55Z")

</div>

Hi @thomas.lindemeier2 , as of the newest version of replicator, there is a function that can create a stereo camera pair:

```auto
rep.create.stereo_camera(stereo_basline=0.2)

```

It will create an `xform` that contains two cameras as its children.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [April 5, 2024, 3:37pm UTC](https://forums.developer.nvidia.com/t/stereo-camera-setup-with-the-replicator/222345/8 "2024-04-05T15:37:14Z")

</div>


