[rostopic delay error] msg does not have header

Hi everyone. I’m tring to test the delay and jitter of message transmission between two PCs running Melodic. Here are my testing steps:

  1. First I use linuxptp tool to synchronize two PCs through ethernet.
  2. Then I connect two PCs to the same hotspot so that they can ping each other. I let PC1 be the ROS master, and set the ROS_MASTER_URI in PC2 as the PC1’s IP address. PC2 is able to subscribe the topics published by PC1.
  3. Now let’s say PC1 publishes a topic named /cmd_vel_mux/input/teleop to PC2, which is well subscribed. I use rostopic delay /cmd_vel_mux/input/teleop command in PC2 to test the delay and jitter of message transmission.

The publisher code in PC1 is

#!/usr/bin/env python
#coding=utf-8
import rospy
from geometry_msgs.msg import Twist

def publisher():
    rospy.init_node('talker', anonymous=True)
    pub = rospy.Publisher('/cmd_vel_mux/input/teleop', Twist, queue_size=10)
    vel = Twist()
    rate = rospy.Rate(10)

    while not rospy.is_shutdown():
        t = rospy.get_time()
        vel.linear.x = 0.5
        vel.angular.z = 0.1
        pub.publish(vel)
        rate.sleep()

if __name__ == '__main__':
    publisher()`

The subscriber code in PC2 is

#!/usr/bin/env python
#coding=utf-8
import rospy
from geometry_msgs.msg import Twist

def callback(data):
    rospy.loginfo('vel:'+str(data.linear.x))

def listener():
    rospy.init_node('wifi_listener', anonymous-True)
    rospy.Subscriber('/cmd_vel_mux/input/teleop', Twist, callback)
    rospy.spin()

if __name__ == '__main__':
    listener()

But when I use rostopic delay /cmd_vel_mux/input/teleop command in PC2, I get an error saying msg does not have header. I’ve learned that rostopic delay computes the difference between the timestamps in the headers of the published msg and the subscribed one. But I have no idea why message doesn’t have a header. How can I use rostopic delay? Or how should I test the delay and jitter of the message transmission?

I really appreciate your help!

I realize that the Twist message itself doesn’t have a header. In this case how should I test the transmission delay and jitter of the Twist topic? Any tool recommended?

Or can I add a header containing timestamps to a Twist topic?

Hello @lightwish.wong,

there are two different types of Twist messages:

Regular Twist messages (do not contain headers):

https://docs.ros.org/en/melodic/api/geometry_msgs/html/msg/Twist.html

And Twist Messages with Headers:
http://docs.ros.org/en/melodic/api/geometry_msgs/html/msg/TwistStamped.html

So probably you need to modify your subscriber and publisher to work with TwistStamped messages.

Hope this helps,

Roberto

Many thanks! Your answer exactly solves my problem.

1 Like

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