Generating communication delay and timing it with ROS subscriber and publisher
I am subscribing to the /odom topic of my turtlebot3 in ROS melodic and Gazebo simulation. I want to do testing on the communication delay with ROS with a constant delay of 50 ms with subscriber and publisher. What are some ways I could do this in my C++ ROS node? Say I want to first subscribe to the /odom topic, then publish a Twist message with a delay of 50ms in addition to the computation time, how would I achieve this? I also want to time the time it takes between first receiving the subscribed /odom topic message, then doing some computation, and then to the time where it gets publish to the cmd_vel topic in the form of a Twist message. What code would I use to time this reliably in my C++ node?
Edit after suggestion in comments: I want to benchmark ROS network performance (ie: inside nodes), or performance of computation (ie: between nodes) via nodes that I created.
Quick note: I would suggest to look at using the
tc
command (should be part ofiproute
) instead of doing this at the application level.@gvdhoorn where can I find out more about the tc command from iproute? I tried searching for iproute with ROS and this was the only thing I could find: https://index.ros.org/d/iproute2/
It's not a ROS package.
iproute
is an Ubuntu package. Information abouttc
can be found in many places, for instance theman
page oftc
. But there are also many blogs/forum posts detailing how to usetc
to introduce artificial latency, package loss, etc to network connections.I would suggest to clarify whether you want to benchmark your own code, whether you are interested in generic benchmarking of a whole ROS application and whether you want to benchmark ROS network performance (ie: inside nodes), or performance of computation (ie: between nodes).