Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_ROS_METRICS_INTERNAL_HISTOGRAM_H
00018 #define CARTOGRAPHER_ROS_METRICS_INTERNAL_HISTOGRAM_H
00019
00020 #include <map>
00021 #include <vector>
00022
00023 #include "absl/synchronization/mutex.h"
00024 #include "cartographer/metrics/histogram.h"
00025 #include "cartographer_ros_msgs/Metric.h"
00026
00027 namespace cartographer_ros {
00028 namespace metrics {
00029
00030 constexpr double kInfiniteBoundary = std::numeric_limits<double>::infinity();
00031
00032 using BucketBoundaries = ::cartographer::metrics::Histogram::BucketBoundaries;
00033
00034 class Histogram : public ::cartographer::metrics::Histogram {
00035 public:
00036 explicit Histogram(const std::map<std::string, std::string>& labels,
00037 const BucketBoundaries& bucket_boundaries);
00038
00039 void Observe(double value) override;
00040
00041 std::map<double, double> CountsByBucket();
00042
00043 double Sum();
00044
00045 double CumulativeCount();
00046
00047 cartographer_ros_msgs::Metric ToRosMessage();
00048
00049 private:
00050 absl::Mutex mutex_;
00051 const std::map<std::string, std::string> labels_;
00052 const BucketBoundaries bucket_boundaries_;
00053 std::vector<double> bucket_counts_ GUARDED_BY(mutex_);
00054 double sum_ GUARDED_BY(mutex_);
00055 };
00056
00057 }
00058 }
00059
00060 #endif // CARTOGRAPHER_ROS_METRICS_INTERNAL_HISTOGRAM_H