In your code, the main loop would be in function physics_step. Alternatively, you can sync up with the viewport update by subscribing to the timeline step:
def setup(self): #function where you set up your scene
self._app_update_sub = (
omni.kit.app.get_app().get_update_event_stream().create_subscription_to_pop(self._on_update_ui)
)
def _on_update_ui(self, step):
do_stuff()