src/tools/benchmark_tool/benchmark_tool/time_estimator/time_estimator_header.py
def output_topic_callback(self, msg):
        """
        Compute a time difference on message reception.

        Callback function triggered by the reception of a message from the output topic.

        When a message is received, the time is computed using the difference between the actual
        receiving time and the time of the message header.
        After the computation, the speed is published on the publish topic.

        @param msg: The topic message
        @type  msg: The type can vary depending on the listened topic
        @return: None
        """
        # Get actual time from ROS
        time_now = self.node.get_clock().now().nanoseconds

        # Compute the amount of time elapsed from receiving this message and
        # the time written in the message header
        time_message = rclpy.time.Time()
        time_message = time_message.from_msg(msg.header.stamp)
        elapsed_ns = time_now - time_message.nanoseconds
        elapsed_us = elapsed_ns / 1e3

        publish_msg = Int64()
        publish_msg.data = int(elapsed_us)

        # Publish the measurement
        self._publisher.publish(publish_msg)

        Compute a time difference on message reception.

        Callback function triggered by the reception of a message from the output topic.

        When a message is received, the time is computed using the difference between the actual
        receiving time and the time of the message header.
        After the computation, the speed is published on the publish topic.

        @param msg: The topic message
        @type  msg: The type can vary depending on the listened topic
        @return: None
        
Compute a time difference on message reception.
Callback function triggered by the reception of a message from the output topic.

When a message is received, the time is computed using the difference between the actual
receiving time and the time of the message header.
After the computation, the speed is published on the publish topic.
Compute a time difference on message reception . Callback function triggered by the reception of a message from the output topic . When a message is received the time is computed using the difference between the actual receiving time and the time of the message header . After the computation the speed is published on the publish topic .
def output_topic_callback(self, msg):
        time_now = self.node.get_clock().now().nanoseconds
        time_message = rclpy.time.Time()
        time_message = time_message.from_msg(msg.header.stamp)
        elapsed_ns = time_now - time_message.nanoseconds
        elapsed_us = elapsed_ns / 1e3
        publish_msg = Int64()
        publish_msg.data = int(elapsed_us)
        self._publisher.publish(publish_msg)
def output_topic_callback ( self , msg ) : time_now = self . node . get_clock ( ) . now ( ) . nanoseconds time_message = rclpy . time . Time ( ) time_message = time_message . from_msg ( msg . header . stamp ) elapsed_ns = time_now - time_message . nanoseconds elapsed_us = elapsed_ns / 1e3 publish_msg = Int64 ( ) publish_msg . data = int ( elapsed_us ) self . _publisher . publish ( publish_msg )
Compute a time difference on message reception.
Compute a time difference on message reception .
"""
        Compute a time difference on message reception.

        Callback function triggered by the reception of a message from the output topic.

        When a message is received, the time is computed using the difference between the actual
        receiving time and the time of the message header.
        After the computation, the speed is published on the publish topic.

        @param msg: The topic message
        @type  msg: The type can vary depending on the listened topic
        @return: None
        """ # Get actual time from ROS # Compute the amount of time elapsed from receiving this message and # the time written in the message header # Publish the measurement
None
self
msg
The topic message
The topic message