ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

what is the max frequency for a ros::Publisher to publish message

asked 2019-03-15 01:28:19 -0600 gravatar image

updated 2019-03-15 02:24:50 -0600

jayess gravatar image


I try to use a timer to trigger to publish a std_msg/Floot32 msg to test how much frequency that Publish could be. When the timer is set to 0.001, i use

rostopic hz /pub

to test frequency, result is1000;

when the timer is set to 0.0008,

rostopic hz /pub

result is 1250;

when the timer is set to 0.0005,

rostopic hz /pub

result is only 1720;

So I think the max frequency for a publisher is limited, The max frequency might be 1000 - 1500 hz


my test code:

#include "ros/ros.h"
#include <std_msgs/Float32.h>

class myTimer{
        pub = nh.advertise<std_msgs::Float32>("/pub",1000);
        t1 = nh.createTimer(ros::Duration(0.0005),&myTimer::callback,this);

        //t2 = nh.createTimer(ros::Duration(1),&myTimer::callback2,this);
    void callback(const ros::TimerEvent& ev){
        static ros::Time start = ros::Time::now();
        ROS_INFO("callback 1 triggered");
        std_msgs::Float32  ii; = 1000000.0000;

        ros::Time end =ros::Time::now();
        ROS_INFO("___%f",(end.toSec() - start.toSec()));
        start = end;
    void callback2(const ros::TimerEvent& ev){
        ROS_INFO("++1 s callback trigered! ");
    ros::NodeHandle nh;
    ros::Publisher pub;
    ros::Timer t1;
    //ros::Timer t2;

int main(int argc, char *argv[])
    //ros::Time begin = ros::Time::now();
    myTimer mt;
    return 0;
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-03-15 02:42:46 -0600

ahendrix gravatar image

Measured topic frequency will depend on your CPU speed, memory bandwidth, queue sizes, message size, OS internal network buffer size, and whether you're using the C++ or python client for ROS.

At some point, publication and subscription will be limited by serialization speed, deserialization speed, or dropped messages in the publisher, or subscriber queues.

I've seen reported topic rates as high as 10k messages per second, mostly from users who are trying to benchmark ROS for small messages using C++ on both the publisher and subscriber.

I've seen users run standard x86 and ARM CPUs with message rates between 100 and 1000 messages per second in real applications without issues.

If you push ROS you will find limits, but it's kind of pointless unless you put those limits in the context of a real application.

Overall, know your application, develop appropriate requirements, and benchmark ROS on your desired computer system to determine whether it does or does not meet your requirements.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-03-15 01:28:19 -0600

Seen: 4,124 times

Last updated: Mar 15 '19