5 #include <gtest/gtest.h> 6 #include <rosgraph_msgs/TopicStatistics.h> 7 #include <boost/thread.hpp> 8 #include <std_msgs/Int8MultiArray.h> 14 void cb(
const rosgraph_msgs::TopicStatistics& msg) {
15 topic_period_mean_map_[msg.topic] = msg.period_mean;
19 float errorMargin = 0.1;
20 float foundFreq = 1.f / topic_period_mean_map_[topic].toSec();
21 return std::fabs(foundFreq - expected) / expected <= errorMargin;
34 TEST(TopicStatisticFrequency, statisticFrequency)
59 int main(
int argc,
char** argv)
61 testing::InitGoogleTest(&argc, argv);
62 ros::init(argc, argv,
"topic_statistic_frequency");
64 return RUN_ALL_TESTS();
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TEST(TopicStatisticFrequency, statisticFrequency)
int main(int argc, char **argv)
void cb(const rosgraph_msgs::TopicStatistics &msg)
bool frequencyAcceptable(const std::string &topic, float expected)
void assertEventuallyHasTopic(const Aggregator &agg, const std::string &topic)
std::map< std::string, ros::Duration > topic_period_mean_map_
ROSCPP_DECL void shutdown()