How to change camera renderer in headless mode

Hi there, I am trying to use IsaacLab to render some image through camera in headless mode, the problem I have is that the default RTX renderer is not accurate enough and in headless mode I cannot switch renderer to ‘RTX-interactive(Path Tracing)’ in the interface, so I want to ask how to change camera renderer with python code

At first I tried SImulationContext.set_setting(“rtx/rendermode”, “PathTracing”) and it works when there is no camera, I can verify that because when I enter the interface the renderer is already changed.

However, if I add any camera into the scene, the above code will not solve the problem(the renderer is still default and rendered image is not accurate enough) and I didn’t find any API for changing camera renderer. Do all cameras share one renderer of the scene? Do I need to use some specific kind of camera? Any help would be appreciated, below I attach my code.

@configclass
class BouncingCfg(InteractiveSceneCfg):
    # ground plane
    ground = AssetBaseCfg(prim_path="/World/defaultGroundPlane", 
                          spawn=sim_utils.GroundPlaneCfg(visible=False, 
                            physics_material=sim_utils.RigidBodyMaterialCfg(
                                static_friction=0,
                                dynamic_friction=0,
                                restitution=1.0,
                                friction_combine_mode="average",
                                restitution_combine_mode="average",),
                            size=(200, 200),
                        ))

    # lights
    dome_light = AssetBaseCfg(
        prim_path="/World/Light", spawn=sim_utils.DomeLightCfg(intensity=3000.0, color=(0.75, 0.75, 0.75))
    )

    # Prim
    sphere = RigidObjectCfg(
        prim_path="{ENV_REGEX_NS}/Sphere",
        # sim_utils.UsdFileCfg()
        spawn=sim_utils.SphereCfg(
        # UsdFileCfg(usd_path="/home/xinyili/IsaacLab/Sphere.usd",
            radius=1,
            rigid_props=sim_utils.RigidBodyPropertiesCfg(linear_damping=0, angular_damping=0),
            mass_props=sim_utils.MassPropertiesCfg(mass=1.0),
            collision_props=sim_utils.CollisionPropertiesCfg(),
            visual_material=sim_utils.PreviewSurfaceCfg(diffuse_color=(0.5, 0.5, 0.5)),
            physics_material=sim_utils.RigidBodyMaterialCfg(
                static_friction=0,
                dynamic_friction=0,
                restitution=1.0,
                friction_combine_mode="average",
                restitution_combine_mode="average",
            ),
        ),
        init_state=RigidObjectCfg.InitialStateCfg(pos=[0, 0, 1], lin_vel=[10, 0.3, 0]),
    )
 
    camera = CameraCfg(
        prim_path="{ENV_REGEX_NS}/front_cam", # "/World/defaultGroundPlane/front_cam",
        # update_period=0.02,
        height=64,
        width=64,
        data_types=["rgb"],
        spawn=sim_utils.PinholeCameraCfg(
            focal_length=24.0, focus_distance=400.0, horizontal_aperture=20.955, clipping_range=(0.1, 1.0e5)
        ),
        offset=CameraCfg.OffsetCfg(pos=(0.0, 0.0, 20), rot=(1, 0.0, 0.0, 0.0), convention="opengl"),
    )


def run_simulator(sim: sim_utils.SimulationContext, scene: InteractiveScene):
    sphere = scene["sphere"]
    sim_dt = sim.get_physics_dt()
    count = 0
    scene.reset()
    
    # Simulation loop
    while simulation_app.is_running():
        if count == 0:
            root_state = sphere.data.default_root_state.clone()
            root_state[:, :3] += scene.env_origins
            root_state[:, 7:9] = (torch.rand_like(root_state[:, 7:9]) - 0.5) * 20
            sphere.write_root_state_to_sim(root_state)
            scene.reset()
        scene.write_data_to_sim()
        sim.step()
        count += 1
        scene.update(sim_dt)

def main():
    sim_cfg = sim_utils.SimulationCfg(device=args_cli.device, dt=0.01)
    sim = SimulationContext(sim_cfg)
    sim.set_camera_view([5, 0.0, 8], [0.0, 0.0, 2.0])
    scene_cfg = BouncingCfg(num_envs=args_cli.num_envs, env_spacing=20)
    scene = InteractiveScene(scene_cfg)
    sim.set_setting("rtx/rendermode", "PathTracing")
    # print("{}: {}".format("rtx/rendermode", sim.get_setting("rtx/rendermode")))
    sim.reset()
    run_simulator(sim, scene)


if __name__ == "__main__":
    main()
    simulation_app.close()
1 Like

Or is there a way to save the renderer setting in the GUI and then launch the program in headless mode, using the previously saved render setting?

Any help would be appreciated

1 Like