shupx / swarm_ros_bridge

A lightweight middle interface that enables specified ROS message transmission among swarm robots through socket communication

Home Page:https://wiki.ros.org/swarm_ros_bridge

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The max_freq limit needs improvement

shupx opened this issue · comments

In the config/ros_topics.yaml, the max_freq only guarantees the sending frequency is lower than that but not be that. If the send_topics frequency is larger than max_freq, the node will decrease it by 2x, 3x, ... until it satisfies the max_freq.

This is because the bridge_node will check if the time interval between two sends is larger than 1/max_freq. If it is larger, this sending message will be discarded. However, the sending freq is not stable which leads to some abnormal discardings of messages.

/* uniform callback functions for ROS subscribers */
template <typename T, int i>
void sub_cb(const T &msg)
{
/* frequency control */
ros::Time t_now = ros::Time::now();
if ((t_now - sub_t_last[i]).toSec() * sendTopics[i].max_freq < 1.0)
{return;}
sub_t_last[i] = t_now;

It brings problems especially when the sending frequency is near max_freq, the sending freq will decrease by about 2 times as well.

So the sending freq limiting mechanism needs improvement.

This bug has been fixed by commit 45e1b07. Now the max_freq will actually limit the frequency to it as the freq_control logic controls the average sending frequency in each second.