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,
156 const std::string ¶meter_name,
204 const std::string &
name,
213 impl_ = boost::make_shared<SubscriberImpl>();
216 template<
class M ,
class T >
219 const std::string &topic,
227 nh, topic, queue_size, fp, obj, transport_hints));
233 const std::string &topic,
240 nh, topic, queue_size, callback, transport_hints));
246 const std::string &topic,
252 nh, topic, dest, transport_hints));
271 if (impl_->timeoutEnabled() && !other.
impl_->timeoutEnabled()) {
272 new_timeout = impl_->timeout();
276 impl_->setTimeout(new_timeout);
284 return impl_->unmappedTopic();
290 return impl_->mappedTopic();
296 return impl_->numPublishers();
302 impl_->resetStatistics();
308 return impl_->messageCount();
317 return impl_->age(now);
336 return impl_->meanLatency();
342 return impl_->minLatency();
348 return impl_->maxLatency();
372 return impl_->meanPeriod();
378 return impl_->meanFrequencyHz();
384 return impl_->minPeriod();
390 return impl_->maxPeriod();
414 impl_->setTimeout(time_out);
426 const std::string ¶meter_name,
427 const double default_value)
430 swri::param(nh, parameter_name, timeout, default_value);
437 return impl_->blockTimeouts(block);
443 return impl_->timeoutsBlocked();
449 return impl_->timeout();
455 return impl_->timeoutEnabled();
461 return impl_->timeout().toNSec() / 1.0e6;
467 return impl_->inTimeout();
473 return impl_->timeoutCount();
478 const std::string &
name,
482 typedef diagnostic_msgs::DiagnosticStatus
DS;
494 status.
mergeSummaryf(DS::WARN,
"Waiting for %s messages.", name.c_str());
496 status.
mergeSummaryf(DS::ERROR,
"%s timeout.", name.c_str());
498 status.
mergeSummaryf(DS::WARN,
"%s timeouts have occurred.", name.c_str());
505 status.
addf(name +
"topic name",
"%s -> %s",
517 status.
addf(name +
" timeouts count",
525 status.
add(name +
" latency",
526 "min: N/A us, mean: N/A us, max: N/A us");
528 status.
addf(name +
" latency",
529 "min: %.2f us, mean: %.2f us, max: %.2f us",
540 "min period: N/A ms, mean frequency: N/A hz, max period: N/A ms");
544 "min period: %.2f ms, mean frequency: %.2f hz, max period: %.2f ms",
552 #endif // SWRI_ROSCPP_SUBSCRIBER_H_
ros::Duration age(const ros::Time &now=ros::TIME_MIN) const
double ageMilliseconds(const ros::Time &now=ros::TIME_MIN) const
const std::string & mappedTopic() const
ros::Duration maxPeriod() const
bool blockTimeouts(bool block)
const Time TIME_MIN(0, 1)
double maxPeriodMilliseconds() const
Subscriber & operator=(const Subscriber &other)
void appendDiagnostics(diagnostic_updater::DiagnosticStatusWrapper &status, const std::string &name, const int flags)
double maxLatencyMicroseconds() const
ros::Duration minPeriod() const
const std::string & unmappedTopic() const
void addf(const std::string &key, const char *format,...)
ros::Duration timeout() const
void timeoutParam(const ros::NodeHandle &nh, const std::string ¶meter_name, const double default_value)
double meanLatencyMicroseconds() const
int numPublishers() const
bool timeoutsBlocked() const
ros::Duration meanPeriod() const
ros::Duration maxLatency() const
void param(swri::NodeHandle &nh, const std::string name, std::string &value, const std::string def, const std::string description)
ros::Duration meanLatency() const
void setTimeout(const ros::Duration &time_out)
boost::shared_ptr< SubscriberImpl > impl_
ros::Duration minLatency() const
double ageSeconds(const ros::Time &now=ros::TIME_MIN) const
double timeoutMilliseconds() const
double minPeriodMilliseconds() const
double minLatencyMicroseconds() const
bool timeoutEnabled() const
void mergeSummaryf(unsigned char lvl, const char *format,...)
void add(const std::string &key, const T &val)
double meanPeriodMilliseconds() const
diagnostic_msgs::DiagnosticStatus DS
double meanFrequencyHz() const