67 Sent(
double _t, uint32_t _len) : t(_t), len(_len) { }
99 if (connection_header)
101 ros::M_string::const_iterator it = connection_header->find(
"latching");
102 if((it != connection_header->end()) && (it->second ==
"1"))
104 ROS_DEBUG(
"input topic is latched; latching output topic to match");
129 if((now - g_last_time) > g_period)
143 const double t = now.
toSec();
148 for (deque<Sent>::iterator i =
g_sent.begin(); i !=
g_sent.end(); ++i)
159 #define USAGE "\nusage: \n"\ 160 " throttle messages IN_TOPIC MSGS_PER_SEC [OUT_TOPIC]]\n"\ 162 " throttle bytes IN_TOPIC BYTES_PER_SEC WINDOW [OUT_TOPIC]]\n\n"\ 163 " This program will drop messages from IN_TOPIC so that either: the \n"\ 164 " average bytes per second on OUT_TOPIC, averaged over WINDOW \n"\ 165 " seconds, remains below BYTES_PER_SEC, or: the minimum inter-message\n"\ 166 " period is 1/MSGS_PER_SEC. The messages are output \n"\ 167 " to OUT_TOPIC, or (if not supplied), to IN_TOPIC_throttle.\n\n" 169 int main(
int argc,
char **argv)
179 std::string topic_name;
183 ros::init(argc, argv, topic_name +
string(
"_throttle"),
185 bool unreliable =
false;
188 pnh.
getParam(
"unreliable", unreliable);
194 if(!strcmp(argv[1],
"messages"))
196 else if(!strcmp(argv[1],
"bytes"))
227 g_bps = atoi(argv[3]);
TransportHints & reliable()
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
const boost::shared_ptr< M_string > & getConnectionHeaderPtr() const
const boost::shared_ptr< ConstMessage > & getConstMessage() const
TransportHints & unreliable()
void conn_cb(const ros::SingleSubscriberPublisher &)
uint32_t getNumSubscribers() const
bool getParam(const std::string &key, std::string &s) const
Sent(double _t, uint32_t _len)
void in_cb(const ros::MessageEvent< ShapeShifter > &msg_event)