27 ft_config_manager_ptr_ = FTConfigManager::Instance();
29 score_params_ = ft_config_manager_ptr_->
fusion_params_.params.score_params();
32 m_matched_dis_limit_ = std::sqrt(4.605);
35 m_matched_dis_limit_ = std::sqrt(5.991);
38 m_matched_dis_limit_ = std::sqrt(7.378);
41 m_matched_dis_limit_ = std::sqrt(9.210);
49 last_timestamp_ = -1.0;
54 const std::vector<std::vector<base::Object>> &input_objectlists,
56 fusion_result_.clear();
57 updated_objects_.clear();
58 for (
unsigned int i = 0; i < input_objectlists.size(); ++i) {
69 const std::vector<base::Object> &new_objects,
70 std::vector<base::Object> *fused_objects,
71 std::vector<std::vector<base::Object>> *fusion_result) {
72 if (new_objects.empty()) {
75 if (fused_objects->size() < 1) {
76 fused_objects->assign(new_objects.begin(), new_objects.end());
77 for (
unsigned int j = 0; j < new_objects.size(); ++j) {
78 std::vector<base::Object> matched_objects;
79 matched_objects.push_back(new_objects[j]);
80 fusion_result->push_back(matched_objects);
84 int u_num = fused_objects->size();
85 int v_num = new_objects.size();
86 Eigen::MatrixXf association_mat(u_num, v_num);
87 ComputeAssociateMatrix(*fused_objects, new_objects, &association_mat);
88 std::vector<std::pair<int, int>> match_cps;
90 km_matcher_.
GetKMResult(association_mat.transpose(), &match_cps,
true);
92 km_matcher_.
GetKMResult(association_mat, &match_cps,
false);
94 for (
auto it = match_cps.begin(); it != match_cps.end(); it++) {
95 if (it->second != -1) {
96 if (it->first == -1) {
97 fused_objects->push_back(new_objects[it->second]);
98 std::vector<base::Object> matched_objects;
99 matched_objects.push_back(fused_objects->back());
100 fusion_result->push_back(matched_objects);
102 (*fusion_result)[it->first].push_back(new_objects[it->second]);
110 const std::vector<std::vector<base::Object>> &fusion_result,
111 std::vector<base::Object> *fused_objects) {
112 for (
const auto &objects : fusion_result) {
113 if (objects.size() == 1) {
114 fused_objects->push_back(objects.at(0));
115 if (objects.at(0).frame_id ==
"V2X") {
121 fused_objects->push_back(objects.at(0));
122 host_vehicle_ =
false;
123 zom_vehicle_ =
false;
124 for (
const auto &
object : objects) {
126 host_vehicle_ =
true;
131 if (zom_vehicle_ ==
true) {
134 if (host_vehicle_ ==
true) {
142double Fusion::CheckOdistance(
const base::Object &in1_ptr,
148 double distance = std::hypot(xi - xj, yi - yj);
152bool Fusion::CheckDisScore(
const base::Object &in1_ptr,
153 const base::Object &in2_ptr,
double *score) {
154 double dis = CheckOdistance(in1_ptr, in2_ptr);
159bool Fusion::CheckTypeScore(
const base::Object &in1_ptr,
160 const base::Object &in2_ptr,
double *score) {
161 double same_prob = 0;
162 if (in1_ptr.sub_type == in2_ptr.sub_type) {
164 1 - (1 - in1_ptr.sub_type_probs[0]) * (1 - in2_ptr.sub_type_probs[0]);
165 }
else if (in1_ptr.type == in2_ptr.type ||
166 in1_ptr.type == v2x::ft::base::ObjectType::UNKNOWN ||
167 in2_ptr.type == v2x::ft::base::ObjectType::UNKNOWN) {
169 (1 - in1_ptr.sub_type_probs.at(0)) * in2_ptr.sub_type_probs.at(0) +
170 (1 - in2_ptr.sub_type_probs.at(0)) * in1_ptr.sub_type_probs.at(0);
177bool Fusion::ComputeAssociateMatrix(
178 const std::vector<base::Object> &in1_objects,
179 const std::vector<base::Object> &in2_objects,
180 Eigen::MatrixXf *association_mat) {
181 for (
unsigned int i = 0; i < in1_objects.size(); ++i) {
182 for (
unsigned int j = 0; j < in2_objects.size(); ++j) {
183 const base::Object &obj1_ptr = in1_objects[i];
184 const base::Object &obj2_ptr = in2_objects[j];
186 if (!CheckDisScore(obj1_ptr, obj2_ptr, &score)) {
187 AERROR <<
"V2X Fusion: check dis score failed";
190 !CheckTypeScore(obj1_ptr, obj2_ptr, &score)) {
191 AERROR <<
"V2X Fusion: check type failed";
193 (*association_mat)(i, j) =
194 (score >= score_params_.
min_score()) ? score : 0;
201 std::vector<unsigned int> to_be_deleted;
202 for (
unsigned int i = 0; i < objects->size(); ++i) {
203 for (
unsigned int j = i + 1; j < objects->size(); ++j) {
204 double distance = CheckOdistance(objects->at(i), objects->at(j));
206 to_be_deleted.push_back(j);
210 for (
auto iter = to_be_deleted.rbegin(); iter != to_be_deleted.rend();
212 objects->erase(objects->begin() + *iter);
214 return to_be_deleted.size();
FusionParams fusion_params_
bool CombineNewResource(const std::vector< base::Object > &new_objects, std::vector< base::Object > *fused_objects, std::vector< std::vector< base::Object > > *fusion_result)
int DeleteRedundant(std::vector< base::Object > *objects)
bool GetV2xFusionObjects(const std::vector< std::vector< base::Object > > &fusion_result, std::vector< base::Object > *fused_objects)
bool Proc(const std::vector< std::vector< base::Object > > &input_objectlists, double timestamp)
bool GetKMResult(const T &association_mat, std::vector< std::pair< int, int > > *match_cps, bool need_reverse=false)
optional double prob_scale
optional ConfidenceLevel confidence_level
optional double max_match_distance
optional double min_score