blob: 8bd2824e30d09330c011d4c40f8a4a8453e4b108 [file] [log] [blame]
Patrick Ventureaadb30d2020-08-10 09:17:11 -07001#pragma once
2
Patrick Ventureef1f8862020-08-17 09:34:35 -07003#include <stdexcept>
Patrick Venture84c188f2020-08-10 12:39:12 -07004#include <string>
Patrick Ventureaadb30d2020-08-10 09:17:11 -07005
6namespace pid_control
7{
8
9struct VariantToDoubleVisitor
10{
11 template <typename T>
12 std::enable_if_t<std::is_arithmetic<T>::value, double>
13 operator()(const T& t) const
14 {
15 return static_cast<double>(t);
16 }
17
18 template <typename T>
19 std::enable_if_t<!std::is_arithmetic<T>::value, double>
20 operator()(const T& t) const
21 {
22 throw std::invalid_argument("Cannot translate type to double");
23 }
24};
25
Patrick Venture84c188f2020-08-10 12:39:12 -070026std::string getSensorPath(const std::string& type, const std::string& id);
27std::string getMatch(const std::string& type, const std::string& id);
28void scaleSensorReading(const double min, const double max, double& value);
29bool validType(const std::string& type);
30
Patrick Ventureaadb30d2020-08-10 09:17:11 -070031} // namespace pid_control