what is the max frequency for a ros::Publisher to publish message
hello,
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
Update
my test code:
#include "ros/ros.h"
#include <std_msgs/Float32.h>
class myTimer{
public:
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);
}
~myTimer(){}
void callback(const ros::TimerEvent& ev){
static ros::Time start = ros::Time::now();
ROS_INFO("callback 1 triggered");
std_msgs::Float32 ii;
ii.data = 1000000.0000;
pub.publish(ii);
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! ");
}
private:
ros::NodeHandle nh;
ros::Publisher pub;
ros::Timer t1;
//ros::Timer t2;
};
int main(int argc, char *argv[])
{
ros::init(argc,argv,"myTimer_class");
//ros::Time begin = ros::Time::now();
myTimer mt;
ros::spin();
return 0;
}
Asked by 942951641@qq.com on 2019-03-15 01:28:19 UTC
Answers
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.
Asked by ahendrix on 2019-03-15 02:42:46 UTC
Comments