Hi everyone. I’m tring to test the delay and jitter of message transmission between two PCs running Melodic. Here are my testing steps:
- First I use linuxptp tool to synchronize two PCs through ethernet.
- 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. - Now let’s say PC1 publishes a topic named
/cmd_vel_mux/input/teleop
to PC2, which is well subscribed. I userostopic 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!