Get Viewport FPS in python

Hi @rthaker @ahaidu @Ayush_G

Is there a way to fetch viewport FPS through a script ? I’m planning to publish sensors at different publishing times (Isaac sim 2023.1.1), based on FPS so that it automatically doesn’t try to publish at the maximum fps rate . This is an intuition I think that can enhance the fps speed since publishing at lower rates compared to resolution can save up speed . (Especially cameras). Or is it not possible at all to publish camera topic at fixed rate , until an unless fps drops to a threshold ?

bumping this up by tagging @toni.sm as well…

Hi @vyachu07

You can use the following code to get the viewport FPS:

import omni.kit.viewport.utility
fps = omni.kit.viewport.utility.get_active_viewport().fps

Hi @toni.nv
Thanks for the solution. Is there a way I can customize the camera publishing rate and make it constant?


    if simulator_fps is not None:
        info_step_size = min(simulator_fps, 30)  # Limit to 30 FPS
        if info_step_size == simulator_fps:
            rgb_step_size=1
        else:
            rgb_step_size = 2
        print("Step_size",info_step_size)
    
        # og.Controller.attribute(camera_info_gate_path + ".inputs:step").set(info_step_size)
        # rgb_step_size = info_step_size   
        depth_step_size = 60
        info_step_size = 1

        og.Controller.attribute(rgb_camera_gate_path + ".inputs:step").set(rgb_step_size)
        og.Controller.attribute(depth_camera_gate_path + ".inputs:step").set(depth_step_size)
        og.Controller.attribute(camera_info_gate_path + ".inputs:step").set(info_step_size)


    # Rotate camera
    if simulation_context.is_playing():
        xform_api.SetRotate((90, 0, frame / 4.0), UsdGeom.XformCommonAPI.RotationOrderXYZ)
        frame += 1

Im trying to do custom publishing based on FPS. Any input to this would be really helpful