Keep the colleague's microbu-esp32c5 tree in this repository
obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
#ifndef CONFIDENT_QUANTITY_HPP_B2XVJERI
|
||||
#define CONFIDENT_QUANTITY_HPP_B2XVJERI
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace vanetza
|
||||
{
|
||||
|
||||
/**
|
||||
* ConfidentQuantity combines a boost::quantity value with a confidence level.
|
||||
*
|
||||
* Usually, a confidence level of 95% is used in ITS specifications.
|
||||
* If no confidence level is explicitly given a worst case value is used, i.e.
|
||||
* the maximum value representable by the underlying type or infinity.
|
||||
*/
|
||||
template<typename T>
|
||||
class ConfidentQuantity
|
||||
{
|
||||
public:
|
||||
constexpr T worst_confidence() const
|
||||
{
|
||||
using value_type = typename T::value_type;
|
||||
return T::from_value(std::numeric_limits<value_type>::has_infinity ?
|
||||
std::numeric_limits<value_type>::infinity() :
|
||||
std::numeric_limits<value_type>::max());
|
||||
}
|
||||
|
||||
constexpr T default_value() const
|
||||
{
|
||||
using value_type = typename T::value_type;
|
||||
return T::from_value(std::numeric_limits<value_type>::has_quiet_NaN ?
|
||||
std::numeric_limits<value_type>::quiet_NaN() : value_type());
|
||||
}
|
||||
|
||||
constexpr bool is_nan(const T& t) const
|
||||
{
|
||||
return t.value() != t.value();
|
||||
}
|
||||
|
||||
ConfidentQuantity() :
|
||||
m_value(default_value()), m_confidence(worst_confidence()) {}
|
||||
ConfidentQuantity(const T& value) :
|
||||
m_value(value), m_confidence(worst_confidence()) {}
|
||||
ConfidentQuantity(const T& value, const T& confidence) :
|
||||
m_value(value), m_confidence(!is_nan(confidence) ? confidence : worst_confidence()) {}
|
||||
|
||||
ConfidentQuantity(const ConfidentQuantity&) = default;
|
||||
ConfidentQuantity& operator=(const ConfidentQuantity&) = default;
|
||||
ConfidentQuantity(ConfidentQuantity&&) = default;
|
||||
ConfidentQuantity& operator=(ConfidentQuantity&&) = default;
|
||||
|
||||
void assign(const T& value, const T& confidence)
|
||||
{
|
||||
m_value = value;
|
||||
m_confidence = !is_nan(confidence) ? confidence : worst_confidence();
|
||||
}
|
||||
|
||||
const T& value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
const T& confidence() const
|
||||
{
|
||||
return m_confidence;
|
||||
}
|
||||
|
||||
private:
|
||||
T m_value;
|
||||
T m_confidence;
|
||||
};
|
||||
|
||||
|
||||
} // namespace vanetza
|
||||
|
||||
#endif /* CONFIDENT_QUANTITY_HPP_B2XVJERI */
|
||||
|
||||
Reference in New Issue
Block a user