• ROS
  • Get time stamp from oak-d camera rather than ros time?

How do I get the time stamp from the image published over ros using the depathai_ros_driver in with respect to my hostmachine clock rather than ROS time? Can I still use a form of this:

# 1. Capture "monotonic now" (time since host PC boot, unaffected by system clock changes)
monotonic_ref = dai.Clock.now()        # Returns datetime.timedelta
# 2. Capture "UTC now" at the same instant
utc_ref = datetime.now(timezone.utc) # A naive datetime in UTC
# 3. Compute offset:  (UTC time) - (monotonic time)
offset = utc_ref - monotonic_ref

with dai.Device(pipeline) as device:
        q_rgb = device.getOutputQueue("rgb")
        while True:
            in_rgb = q_rgb.tryGet()
            if in_rgb is not None:
                frame = in_rgb.getCvFrame()
                cam_deltatime = in_rgb.getTimestamp()
                cam_time = cam_deltatime + offset

    Hi, what is the issue you are experiencing? If it is related to unreliable timestamps in ROS, this was corrected in this PR and for depthai_ros_driver it can be enabled by setting i_update_ros_base_time_on_ros_msg: true parameter for given sensor

    Ok so setting i_update_ros_base_time_on_ros_msg: true will make it so the timestamps in the Header of my ros messages from my camera will match my host machine time clock rather than ROS's timestamp? Also are these timestamps when the sensor took the picture or when ROS received the message?

    Hi, AFAIK ROS clock should be synchronized to your system clock, if that is not the case please check your setup. As mentioned above in some cases that clock might not be deterministic, setting i_update_ros_base_time_on_ros_msg: true allows to check for those errors as we also have a steady_clock source for those reasons. You can find how timestamps are set in source in following links:
    luxonis/depthai-rosblob/cf71d9d2ad1a08bb39127ab5303f94f016e95a4d/depthai_bridge/src/ImageConverter.cpp#L33

    luxonis/depthai-rosblob/cf71d9d2ad1a08bb39127ab5303f94f016e95a4d/depthai_bridge/src/ImageConverter.cpp#L77

    luxonis/depthai-rosblob/cf71d9d2ad1a08bb39127ab5303f94f016e95a4d/depthai_bridge/include/depthai_bridge/depthaiUtility.hpp#L79

    Also are these timestamps when the sensor took the picture or when ROS received the message?

    Timestamps are sensor based and are shifted to match ROS Clock domain