17 #ifndef CARTOGRAPHER_MAPPING_PROBABILITY_VALUES_H_ 18 #define CARTOGRAPHER_MAPPING_PROBABILITY_VALUES_H_ 25 #include "glog/logging.h" 32 inline uint16 BoundedFloatToValue(
const float float_value,
33 const float lower_bound,
34 const float upper_bound) {
37 (
common::Clamp(float_value, lower_bound, upper_bound) - lower_bound) *
38 (32766.f / (upper_bound - lower_bound))) +
42 DCHECK_LE(value, 32767);
48 inline float Odds(
float probability) {
49 return probability / (1.f - probability);
53 return odds / (odds + 1.f);
57 return 1.f - probability;
61 return 1.f - correspondence_cost;
71 return common::Clamp(probability, kMinProbability, kMaxProbability);
76 return common::Clamp(correspondence_cost, kMinCorrespondenceCost,
77 kMaxCorrespondenceCost);
86 return BoundedFloatToValue(correspondence_cost, kMinCorrespondenceCost,
87 kMaxCorrespondenceCost);
92 return BoundedFloatToValue(probability, kMinProbability, kMaxProbability);
101 return (*kValueToProbability)[value];
108 return (*kValueToCorrespondenceCost)[value];
112 uint16 probability_value) {
113 if (probability_value == kUnknownProbabilityValue) {
116 bool update_carry =
false;
117 if (probability_value > kUpdateMarker) {
128 uint16 correspondence_cost_value) {
129 if (correspondence_cost_value == kUnknownCorrespondenceValue)
131 bool update_carry =
false;
132 if (correspondence_cost_value > kUpdateMarker) {
148 #endif // CARTOGRAPHER_MAPPING_PROBABILITY_VALUES_H_
const std::vector< float > *const kValueToCorrespondenceCost
uint16 ProbabilityValueToCorrespondenceCostValue(uint16 probability_value)
float ClampProbability(const float probability)
std::vector< uint16 > ComputeLookupTableToApplyOdds(const float odds)
std::vector< uint16 > ComputeLookupTableToApplyCorrespondenceCostOdds(float odds)
float ProbabilityFromOdds(const float odds)
float ValueToCorrespondenceCost(const uint16 value)
int RoundToInt(const float x)
constexpr float kMinProbability
constexpr float kMaxCorrespondenceCost
float ValueToProbability(const uint16 value)
constexpr float kMaxProbability
float CorrespondenceCostToProbability(const float correspondence_cost)
float ClampCorrespondenceCost(const float correspondence_cost)
uint16 CorrespondenceCostValueToProbabilityValue(uint16 correspondence_cost_value)
float Odds(float probability)
const std::vector< float > *const kValueToProbability
constexpr uint16 kUnknownProbabilityValue
float ProbabilityToCorrespondenceCost(const float probability)
uint16 ProbabilityToValue(const float probability)
T Clamp(const T value, const T min, const T max)
uint16 CorrespondenceCostToValue(const float correspondence_cost)
constexpr uint16 kUpdateMarker
constexpr uint16 kUnknownCorrespondenceValue
constexpr float kMinCorrespondenceCost