29 #ifndef SWRI_ROSCPP_SUBSCRIBER_H_ 30 #define SWRI_ROSCPP_SUBSCRIBER_H_ 75 template<
class M ,
class T >
77 const std::string &topic,
86 const std::string &topic,
98 const std::string &topic,
152 const std::string ¶meter_name,
153 const double default_value);
200 const std::string &
name,
209 impl_ = boost::make_shared<SubscriberImpl>();
212 template<
class M ,
class T >
215 const std::string &topic,
223 nh, topic, queue_size, fp, obj, transport_hints));
229 const std::string &topic,
236 nh, topic, queue_size, callback, transport_hints));
242 const std::string &topic,
248 nh, topic, dest, transport_hints));
267 if (impl_->timeoutEnabled() && !other.
impl_->timeoutEnabled()) {
268 new_timeout = impl_->timeout();
272 impl_->setTimeout(new_timeout);
280 return impl_->unmappedTopic();
286 return impl_->mappedTopic();
292 return impl_->numPublishers();
298 impl_->resetStatistics();
304 return impl_->messageCount();
313 return impl_->age(now);
332 return impl_->meanLatency();
338 return impl_->minLatency();
344 return impl_->maxLatency();
368 return impl_->meanPeriod();
374 return impl_->meanFrequencyHz();
380 return impl_->minPeriod();
386 return impl_->maxPeriod();
410 impl_->setTimeout(time_out);
422 const std::string ¶meter_name,
423 const double default_value)
426 swri::param(nh, parameter_name, timeout, default_value);
433 return impl_->blockTimeouts(block);
439 return impl_->timeoutsBlocked();
445 return impl_->timeout();
451 return impl_->timeoutEnabled();
457 return impl_->timeout().toNSec() / 1.0e6;
463 return impl_->inTimeout();
469 return impl_->timeoutCount();
474 const std::string &
name,
478 typedef diagnostic_msgs::DiagnosticStatus
DS;
490 status.
mergeSummaryf(DS::WARN,
"Waiting for %s messages.", name.c_str());
492 status.
mergeSummaryf(DS::ERROR,
"%s timeout.", name.c_str());
494 status.
mergeSummaryf(DS::WARN,
"%s timeouts have occurred.", name.c_str());
501 status.
addf(name +
"topic name",
"%s -> %s",
513 status.
addf(name +
" timeouts count",
521 status.
add(name +
" latency",
522 "min: N/A us, mean: N/A us, max: N/A us");
524 status.
addf(name +
" latency",
525 "min: %.2f us, mean: %.2f us, max: %.2f us",
536 "min period: N/A ms, mean frequency: N/A hz, max period: N/A ms");
540 "min period: %.2f ms, mean frequency: %.2f hz, max period: %.2f ms",
548 #endif // SWRI_ROSCPP_SUBSCRIBER_H_
ros::Duration meanPeriod() const
ros::Duration minPeriod() const
bool blockTimeouts(bool block)
double ageMilliseconds(const ros::Time &now=ros::TIME_MIN) const
double meanFrequencyHz() const
const Time TIME_MIN(0, 1)
bool timeoutsBlocked() const
ros::Duration maxPeriod() const
Subscriber & operator=(const Subscriber &other)
void appendDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &status, const std::string &name, const int flags)
double maxLatencyMicroseconds() const
double minPeriodMilliseconds() const
void addf(const std::string &key, const char *format,...)
const std::string & unmappedTopic() const
int numPublishers() const
void timeoutParam(const ros::NodeHandle &nh, const std::string ¶meter_name, const double default_value)
const std::string & mappedTopic() const
ros::Duration minLatency() const
static void param(const ros::NodeHandle &nh, const std::string &name, int &variable, const int default_value)
bool timeoutEnabled() const
ros::Duration maxLatency() const
void setTimeout(const ros::Duration &time_out)
boost::shared_ptr< SubscriberImpl > impl_
double meanPeriodMilliseconds() const
double timeoutMilliseconds() const
double meanLatencyMicroseconds() const
ros::Duration meanLatency() const
ros::Duration timeout() const
void mergeSummaryf(unsigned char lvl, const char *format,...)
void add(const std::string &key, const T &val)
ros::Duration age(const ros::Time &now=ros::TIME_MIN) const
double ageSeconds(const ros::Time &now=ros::TIME_MIN) const
double minLatencyMicroseconds() const
double maxPeriodMilliseconds() const
diagnostic_msgs::DiagnosticStatus DS