Data logger never calls frame_logging_func

I’m working on logging the position of a 4-wheeled holonomic robot, but I’m having trouble with the data logger as it does not call the frame_logging_func(task, scene) function which is added using data_logger.add_data_frame_logging_func(frame_logging_func).

My code is based on the Follow Target example from the tutorials, however the output file always end up empty. It is possible to manually add data to the data logger using data_logger.add_data(...) and this is stored successfully in the output file, but the function passed to the data_logger.add_data_frame_logging_func() seems to never be called (this has been checked by printing within the function)

The code below shows the function triggered when the start logging button is clicked. The repo for the extension can be found here (The project is still under development and I’m relatively new to omniverse)

def _on_logging_event(self, val):
        world = self.get_world()
        data_logger = world.get_data_logger()
        if not world.get_data_logger().is_started():
            def frame_logging_func(tasks, scene):
                return {
                    "joint_positions": 0
                }

            data_logger.add_data_frame_logging_func(frame_logging_func)
            data_logger.add_data({"joint_positions": 0}, 1.0, 1.0)
        if val:
            data_logger.start()
        else:
            data_logger.pause()
        return

I’ve still not found a solution to the problem, but will try to provide some more context for the problem here.

This ui part of the extension inherits from BaseSampleExtension and is located in pose_logger_extension.py

class PoseLoggerExtension(BaseSampleExtension):
    def on_startup(self, ext_id: str):
        super().on_startup(ext_id)
        super().start_extension(
            menu_name="",
            submenu_name="",
            name="Pose logger",
            title="Pose logger example standalone",
            doc_link="",
            overview="Pose logger extension",
            file_path=os.path.abspath(__file__),
            sample=PoseLogger(),
            number_of_extra_frames=2,
        )
        #more code...
        frame = self.get_frame(index=1)
        self.build_data_logging_ui(frame)
        return

The function build_data_loggin_ui is defined as

def build_data_logging_ui_new(self, frame):
    with frame:
        with ui.VStack(spacing=5):
            frame.title = "Data Logging"
            frame.visible = True
            # More code ...
            dict = {
                "label": "Start Logging",
                "type": "button",
                "a_text": "START",
                "b_text": "PAUSE",
                "tooltip": "Start Logging",
                "on_clicked_fn": self._on_logging_button_event,
            }
            self.ui_elements["Start Logging"] = state_btn_builder(**dict)
            # Some more code...

The function being called on click is defined as this

def _on_logging_button_event(self, val):
        self.sample._on_logging_event(val)
        self.ui_elements["Save Data"].enabled = True
        return

self.sample is the logic part of the extension and the _on_logging_event function is defined as below in pose_logger.py

class PoseLogger(BaseSample):
    # Some more code...
    def _on_logging_event(self, val):
            world = self.get_world()
            data_logger = world.get_data_logger()
            if not world.get_data_logger().is_started():
                def frame_logging_func(tasks, scene):
                    return {
                        "joint_positions": 0
                    }

                data_logger.add_data_frame_logging_func(frame_logging_func)
            if val:
                data_logger.start()
            else:
                data_logger.pause()
            return

There are still no problem saving the logged data and it is possible to manually add data to the datalogger and view it in the saved file. Hope someone have a clue of where the error might be.

If someone know of an extension logging the pose of a prim that would also be of great interest :)

Problem solved. World never called its step function as no other callback function was added to the world. In the “Follow Target” example a callback for the task was added and the datalogger was called as the world stepped. The solution was just to add a callback

world.add_physics_callback("my_step", world.step_async)

This seems to solve the problem

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