Apollo  6.0
Open source self driving car software
probabilities.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 #pragma once
17 
18 #include <algorithm>
19 #include <vector>
20 
21 namespace apollo {
22 namespace perception {
23 namespace fusion {
24 
25 // @brief: bound given value within input range
26 // @return bounded value within input range
27 // @NOTE: original method name is bound
28 template <typename T>
29 T Bound(const T& value, const T& max_value, const T& min_value) {
30  return std::max(min_value, std::min(max_value, value));
31 }
32 
33 // @brief: scale input prob within input range
34 // @return bounded & scaled prob
35 // @NOTE: original method name is bound_scale_probability
36 double BoundedScalePositiveProbability(double p, double max_p, double min_p);
37 
38 // @brief: scale input prob
39 // @return sclaed prob
40 // @NOTE: original method name is scale_positive_probability
41 double ScalePositiveProbability(double p, double max_p, double th_p);
42 
43 // @brief: calculate the Welsh Loss
44 // @return Welsh Loss of input dist
45 // @NOTE: original method name is Welsh_var_loss_fun
46 double WelshVarLossFun(double dist, double th, double scale);
47 
48 // @brief: fuse two probabilities, fused prob is greater than 0.5, if
49 // the sum of input prob pair is greater than 1, otherwise, fused prob
50 // is less than 0.5.
51 // @return fused prob of input prob pair
52 // @NOTE: original method name is fused_tow_probabilities
53 double FuseTwoProbabilities(double prob1, double prob2);
54 
55 // @brief: fuse multiple probabilities
56 // @return fused probability of input multiple probabilities
57 // @NOTE: original method name is fused_multiple_probabilities
58 double FuseMultipleProbabilities(const std::vector<double>& probs);
59 
60 } // namespace fusion
61 } // namespace perception
62 } // namespace apollo
double WelshVarLossFun(double dist, double th, double scale)
T Bound(const T &value, const T &max_value, const T &min_value)
Definition: probabilities.h:29
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
double ScalePositiveProbability(double p, double max_p, double th_p)
double BoundedScalePositiveProbability(double p, double max_p, double min_p)
apollo::cyber::base::std value
double FuseTwoProbabilities(double prob1, double prob2)
double FuseMultipleProbabilities(const std::vector< double > &probs)