Do I need TimeSynchronizer?

Hello,

While logging data from an Isaac application, I notice that the message pubtime and acqtime seem to be set to the application startup time (i.e. “app-clock” time?). I would like the time reflected to be system time in Unix epoch format, so that I can synchronize the data logged from the Isaac application with data being logged elsewhere on the same computer.

From the documentation, it seems that the isaac::alice::TimeSynchronizer is needed to translate from app-clock time to normal system time. Can I verify if this is true? In order to use it, should I simply add it as a component to all the nodes that I am logging from, in the JSON file?

I am relatively new to Isaac, so please do excuse an egregious misunderstandings of the system I have made.

Thanks!

You can use the isaac::alice::TimeSynchronizer to get resolve the epoch time of app timestamp. Both clocks are running in nanoseconds. First, you need to add the TimeSynchronizer component to your app graph within the same. This will ensure that the component is created and as part of its start() will snapshot the offset of the current epoch time - app time to get the epoch time of when the app started. From this, you need to get a handle to that component and call appToSyncTime() to resolve the app timestamp into a system epoch timestamp.
For example, you can take a look at //sdk/packages/ros_bridge/apps/ros_to_navigation_bridge.subgraph.json for how to add the component as shown here:

{
        "name": "ros_node",
        "components": [
          {
            "name": "RosNode",
            "type": "isaac::ros_bridge::RosNode"
          },
          {
            "name": "TimeSynchronizer",
            "type": "isaac::alice::TimeSynchronizer"
          }
        ],
        "disable_automatic_start": true
      },

You can then take a look here to see how to access the handle and call the function (//sdk/packages/ros_bridge/components/RosToProtoConverter.hpp)

time_synchronizer_ =
        node()->app()->getNodeComponentOrNull<alice::TimeSynchronizer>(ros_node_name);
    if (!time_synchronizer_) {
      reportFailure("No TimeSynchronizer component in '%s' node", ros_node_name.c_str());
      return;
    }

const int64_t app_time = time_synchronizer_->syncToAppTime(sync_time);

Hello! That was very helpful, appreciate it! I have just one more quick question: is there an example on how to do this in Python? I have tried looking for Python API for Application objects, but I’m having some difficulty locating it.

Thank you!

The Python API may not be rich enough to do this well but you could try using Application.clock().time() which will return the application time in seconds which you could subtract from a wall clock time to get the difference like TimeSynchronizer. Alternatively, you could add additional pybindings to engine components manually.