72 {
73
74 int64_t corner_index = 0;
75 float corner_velocity_gain = 0.0f;
76 std::vector<float> corner_velocity_gain_norms(4);
77 for (int i = 0; i < 4; ++i) {
78 corner_velocity_gain_norms[i] =
79 static_cast<float>((new_object->measured_corners_velocity[i] -
80 latest_object->belief_velocity)
81 .norm());
82 }
83 std::vector<float>::iterator corener_min_gain =
84 std::min_element(std::begin(corner_velocity_gain_norms),
85 std::end(corner_velocity_gain_norms));
86 corner_velocity_gain = *corener_min_gain;
87 corner_index = corener_min_gain - corner_velocity_gain_norms.begin();
88
89 std::vector<float> velocity_gain_norms(4);
90 velocity_gain_norms[0] = corner_velocity_gain;
91 velocity_gain_norms[1] =
92 static_cast<float>((new_object->measured_barycenter_velocity -
93 latest_object->belief_velocity)
94 .norm());
95 velocity_gain_norms[2] = static_cast<float>(
96 (new_object->measured_center_velocity - latest_object->belief_velocity)
97 .norm());
98 velocity_gain_norms[3] = static_cast<float>(
99 (new_object->measured_history_center_velocity -
100 latest_object->belief_velocity).norm());
101 std::vector<float>::iterator min_gain = std::min_element(
102 std::begin(velocity_gain_norms), std::end(velocity_gain_norms));
103 int64_t min_gain_pos = min_gain - velocity_gain_norms.begin();
104 if (min_gain_pos == 0) {
105 new_object->selected_measured_velocity =
106 new_object->measured_corners_velocity[corner_index];
107 }
108 if (min_gain_pos == 1) {
109 new_object->selected_measured_velocity =
110 new_object->measured_barycenter_velocity;
111 }
112 if (min_gain_pos == 2) {
113 new_object->selected_measured_velocity =
114 new_object->measured_center_velocity;
115 }
116 if (min_gain_pos == 3) {
117 new_object->selected_measured_velocity =
118 new_object->measured_history_center_velocity;
119 }
120 if (condition) {
121
122 std::vector<float> condition_velocity_norm(10);
123 for (int i = 0; i < 4; ++i) {
124 condition_velocity_norm[i] = static_cast<float>(
125 (new_object->measured_detection_history_corners_velocity[i] -
126 latest_object->belief_velocity).norm());
127 }
128
129 condition_velocity_norm[4] = static_cast<float>(
130 (new_object->measured_detection_history_center_velocity -
131 latest_object->belief_velocity).norm());
132 condition_velocity_norm[5] = static_cast<float>(
133 (new_object->measured_detection_center_velocity -
134 latest_object->belief_velocity).norm());
135
136 for (int i = 0; i < 4; ++i) {
137 condition_velocity_norm[i + 6] = static_cast<float>(
138 (new_object->measured_history_corners_velocity[i] -
139 latest_object->belief_velocity).norm());
140 }
141 std::vector<float>::iterator condition_min_diff =
142 std::min_element(std::begin(condition_velocity_norm),
143 std::end(condition_velocity_norm));
144 int min_pos = condition_min_diff - condition_velocity_norm.begin();
145 if (*condition_min_diff < *min_gain) {
146 if (min_pos <= 3 && min_pos >= 0) {
147 new_object->selected_measured_velocity =
148 new_object->measured_detection_history_corners_velocity[min_pos];
149 }
150 if (min_pos == 4) {
151 new_object->selected_measured_velocity =
152 new_object->measured_detection_history_center_velocity;
153 }
154 if (min_pos == 5) {
155 new_object->selected_measured_velocity =
156 new_object->measured_detection_center_velocity;
157 }
158 if (min_pos <= 9 && min_pos >= 6) {
159 new_object->selected_measured_velocity =
160 new_object->measured_history_corners_velocity[min_pos - 6];
161 }
162 }
163 }
164 ADEBUG <<
"[Measurement] track_id: " << track_data->track_id_
165 << " belief_velocity: " << latest_object->belief_velocity(0)
166 << ", " << latest_object->belief_velocity(1)
167 << " corner_velocity[0]: " << new_object->measured_corners_velocity[0](0)
168 << ", " << new_object->measured_corners_velocity[0](1)
169 << " corner_velocity[1]: " << new_object->measured_corners_velocity[1](0)
170 << ", " << new_object->measured_corners_velocity[1](1)
171 << " corner_velocity[2]: " << new_object->measured_corners_velocity[2](0)
172 << ", " << new_object->measured_corners_velocity[2](1)
173 << " corner_velocity[3]: " << new_object->measured_corners_velocity[3](0)
174 << ", " << new_object->measured_corners_velocity[3](1)
175 << " barycenter_velocity: " << new_object->measured_barycenter_velocity(0)
176 << ", " << new_object->measured_barycenter_velocity(1)
177 << " center_velocity: " << new_object->measured_center_velocity(0)
178 << ", " << new_object->measured_center_velocity(1)
179 << " history_velocity: "<< new_object->measured_history_center_velocity(0)
180 << ", " << new_object->measured_history_center_velocity(1)
181 << " detection_history_corner_velocity[0]: "
182 << new_object->measured_detection_history_corners_velocity[0](0) << ", "
183 << new_object->measured_detection_history_corners_velocity[0](1)
184 << " detection_history_corner_velocity[1]: "
185 << new_object->measured_detection_history_corners_velocity[1](0) << ", "
186 << new_object->measured_detection_history_corners_velocity[1](1)
187 << " detection_history_corner_velocity[2]: "
188 << new_object->measured_detection_history_corners_velocity[2](0) << ", "
189 << new_object->measured_detection_history_corners_velocity[2](1)
190 << " detection_history_corner_velocity[3]: "
191 << new_object->measured_detection_history_corners_velocity[3](0) << ", "
192 << new_object->measured_detection_history_corners_velocity[3](1)
193 << " detection_center_velocity: "
194 << new_object->measured_detection_center_velocity(0) << ", "
195 << new_object->measured_detection_center_velocity(1)
196 << " detection_history_center_velocity: "
197 << new_object->measured_detection_history_center_velocity(0) << ", "
198 << new_object->measured_detection_history_center_velocity(1)
199 << " history_corner_velocity[0]: "
200 << new_object->measured_history_corners_velocity[0](0) << ", "
201 << new_object->measured_history_corners_velocity[0](1)
202 << " history_corner_velocity[1]: "
203 << new_object->measured_history_corners_velocity[1](0) << ", "
204 << new_object->measured_history_corners_velocity[1](1)
205 << " history_corner_velocity[2]: "
206 << new_object->measured_history_corners_velocity[2](0) << ", "
207 << new_object->measured_history_corners_velocity[2](1)
208 << " history_corner_velocity[3]: "
209 << new_object->measured_history_corners_velocity[3](0) << ", "
210 << new_object->measured_history_corners_velocity[3](1)
211 << " selected: " << new_object->selected_measured_velocity(0) << ", "
212 << new_object->selected_measured_velocity(1);
213}