ros2_control - rolling
Loading...
Searching...
No Matches
statistic_data.hpp
1// Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// This file is a copy of the StatisticData struct from libstatistics_collector
16// (libstatistics_collector/moving_average_statistics/types.hpp), which is being removed from
17// ROS 2 Rolling onwards.
18
19#ifndef HARDWARE_INTERFACE__TYPES__STATISTIC_DATA_HPP_
20#define HARDWARE_INTERFACE__TYPES__STATISTIC_DATA_HPP_
21
22#include <cmath>
23#include <cstdint>
24#include <sstream>
25#include <string>
26
27namespace ros2_control
28{
29
34{
36 double average = std::nan("");
38 double min = std::nan("");
40 double max = std::nan("");
42 double standard_deviation = std::nan("");
44 uint64_t sample_count = 0;
45};
46
54inline std::string statistics_data_to_string(const StatisticData & results)
55{
56 std::stringstream ss;
57 ss << "avg=" << std::to_string(results.average) << ", min=" << std::to_string(results.min)
58 << ", max=" << std::to_string(results.max)
59 << ", std_dev=" << std::to_string(results.standard_deviation)
60 << ", count=" << std::to_string(results.sample_count);
61 return ss.str();
62}
63
64} // namespace ros2_control
65
66#endif // HARDWARE_INTERFACE__TYPES__STATISTIC_DATA_HPP_
Definition statistic_data.hpp:34
double min
min value of the observations
Definition statistic_data.hpp:38
double standard_deviation
standard_deviation of the observations
Definition statistic_data.hpp:42
double max
max value of the observations
Definition statistic_data.hpp:40
double average
average of the observations
Definition statistic_data.hpp:36
uint64_t sample_count
number of samples of the observation
Definition statistic_data.hpp:44