87 m_azimuth_histogram[echo_idx][segment_idx][elevationToInt(elevation)][azimuthToInt(azimuth)] += 1;
127 std::vector<std::string> messages;
129 for(AzimuthHistogramPerElevationPerSegmentPerEcho::const_iterator iter_echos = m_azimuth_histogram.cbegin(); iter_echos != m_azimuth_histogram.cend(); iter_echos++)
131 int echo_idx = iter_echos->first;
133 for(AzimuthHistogramPerElevationPerSegment::const_iterator iter_segment = azimuth_histogram_elevation_segment.cbegin(); iter_segment != azimuth_histogram_elevation_segment.cend(); iter_segment++)
135 int segment_idx = iter_segment->first;
137 for(AzimuthHistogramPerElevation::const_iterator iter_elevation = azimuth_histogram_elevation.cbegin(); iter_elevation != azimuth_histogram_elevation.cend(); iter_elevation++)
139 float elevation_rad = intToElevation(iter_elevation->first);
141 float azimuth_min = azimuth_histogram.empty() ? 0 : FLT_MAX;
142 float azimuth_max = azimuth_histogram.empty() ? 0 : -FLT_MAX;
143 for(AzimuthHistogram::const_iterator iter_azimuth = azimuth_histogram.cbegin(); iter_azimuth != azimuth_histogram.cend(); iter_azimuth++)
145 float azimuth_rad = intToAzimuth(iter_azimuth->first);
146 int azimuth_cnt = iter_azimuth->second;
149 azimuth_min = std::min(azimuth_min, azimuth_rad);
150 azimuth_max = std::max(azimuth_max, azimuth_rad);
154 s <<
"MsgPackValidatorData[echo=" << echo_idx <<
"][segment=" << segment_idx <<
"][elevation=" <<
rad2deg(elevation_rad) <<
"]: azimuth=[" <<
rad2deg(azimuth_min) <<
", " <<
rad2deg(azimuth_max) <<
"] [deg]" ;
155 messages.push_back(
s.str());
189 const std::vector<int>& segments,
const std::vector<int>& layer_filter,
int verbose)
190 : m_echos_required(echos), m_azimuth_start(azimuth_start), m_azimuth_end(azimuth_end), m_elevation_start(elevation_start), m_elevation_end(elevation_end),
191 m_valid_segments(segments), m_layer_filter(layer_filter), m_verbose(
verbose)
216 for(MsgPackValidatorData::AzimuthHistogramPerElevationPerSegmentPerEcho::const_iterator iter_echos = azimuth_histogram.cbegin(); iter_echos != azimuth_histogram.cend(); iter_echos++)
218 int echo_idx = iter_echos->first;
220 for(MsgPackValidatorData::AzimuthHistogramPerElevationPerSegment::const_iterator iter_segment = azimuth_histogram_elevation_segment.cbegin(); iter_segment != azimuth_histogram_elevation_segment.cend(); iter_segment++)
222 int segment_idx = iter_segment->first;
224 for(MsgPackValidatorData::AzimuthHistogramPerElevation::const_iterator iter_elevation = azimuth_histogram_elevation.cbegin(); iter_elevation != azimuth_histogram_elevation.cend(); iter_elevation++)
226 int elevation_idx = iter_elevation->first;
229 std::vector<float> out_of_bounds_azimuth_angles;
230 for(MsgPackValidatorData::AzimuthHistogram::const_iterator iter_azimuth = azimuth_histogram.cbegin(); iter_azimuth != azimuth_histogram.cend(); iter_azimuth++)
232 float azimuth_rad = msgpack_data_received.
azimuthIndexToRad(iter_azimuth->first);
233 int azimuth_cnt = iter_azimuth->second;
236 if (std::find(m_echos_required.begin(), m_echos_required.end(), echo_idx) == m_echos_required.end())
239 ROS_WARN_STREAM(
"## WARNING MsgPackValidator: echo = " << echo_idx <<
" unexpected (expected echo: [ "
240 << listVector(m_echos_required) <<
" ]");
243 if (std::find(m_valid_segments.begin(), m_valid_segments.end(), segment_idx) == m_valid_segments.end())
246 ROS_WARN_STREAM(
"## WARNING MsgPackValidator: segment = " << segment_idx <<
" (echo " << echo_idx <<
") unexpected (valid segments: [ "
247 << listVector(m_valid_segments) <<
" ]");
250 if (elevation_rad < m_elevation_start || elevation_rad > m_elevation_end)
253 ROS_WARN_STREAM(
"## WARNING MsgPackValidator: elevation = " << (elevation_rad * 180.0 / M_PI) <<
" deg (echo " << echo_idx <<
", segment " << segment_idx
254 <<
") out of limits [ " << (m_elevation_start * 180.0 / M_PI) <<
", " << (m_elevation_end * 180.0 / M_PI) <<
" ] deg.");
257 if (azimuth_rad < m_azimuth_start || azimuth_rad > m_azimuth_end)
260 out_of_bounds_azimuth_angles.push_back(azimuth_rad * (
float)(180.0 / M_PI));
264 if(!out_of_bounds_azimuth_angles.empty())
266 ROS_WARN_STREAM(
"## WARNING MsgPackValidator: azimuth angles = [ " << listVector(out_of_bounds_azimuth_angles) <<
" ] deg (echo " << echo_idx <<
", segment " << segment_idx <<
", elevation "
267 << (elevation_rad * 180.0 / M_PI) <<
" deg) out of limits [ " << (m_azimuth_start * 180.0 / M_PI) <<
", " << (m_azimuth_end * 180.0 / M_PI) <<
" ] deg.");
273 ROS_WARN_STREAM(
"## WARNING MsgPackValidator::validateNotOutOfBound() finished with error.");
274 else if (m_verbose > 1)
275 ROS_INFO_STREAM(
"MsgPackValidator::validateNotOutOfBound() finished successful.");
281 int echo_idx,
int segment_idx,
int elevation_idx,
int azimuth_idx)
const
283 MsgPackValidatorData::AzimuthHistogramPerElevationPerSegmentPerEcho::const_iterator collected_echo = azimuth_histogram.find(echo_idx);
284 if (collected_echo != azimuth_histogram.cend())
286 int collected_echo_idx = collected_echo->first;
287 const MsgPackValidatorData::AzimuthHistogramPerElevationPerSegment::const_iterator collected_segment = collected_echo->second.find(segment_idx);
288 if (collected_segment != collected_echo->second.cend())
290 int collected_segment_idx = collected_segment->first;
291 const MsgPackValidatorData::AzimuthHistogramPerElevation::const_iterator collected_elevation = collected_segment->second.find(elevation_idx);
292 if (collected_elevation != collected_segment->second.cend())
294 int collected_elevation_idx = collected_elevation->first;
295 const MsgPackValidatorData::AzimuthHistogram::const_iterator collected_azimuth = collected_elevation->second.find(azimuth_idx);
296 if (collected_azimuth != collected_elevation->second.cend())
298 int collected_azimuth_idx = collected_azimuth->first;
299 int collected_azimuth_hist_cnt = collected_azimuth->second;
300 if(collected_echo_idx == echo_idx && collected_segment_idx == segment_idx && collected_elevation_idx == elevation_idx && collected_azimuth_idx == azimuth_idx)
302 return collected_azimuth_hist_cnt;
316 for (
int msg_cnt = 0; msg_cnt < messages.size(); msg_cnt++)
340 bool azimuth_values_missing =
false;
341 bool elevation_values_missing =
false;
345 for (std::vector<int>::const_iterator iter_echo = m_echos_required.cbegin(); iter_echo != m_echos_required.cend(); iter_echo++)
347 int echo_idx = (*iter_echo);
349 MsgPackValidatorData::AzimuthHistogramPerElevationPerSegmentPerEcho::const_iterator collected_echo = azimuth_histogram.find(echo_idx);
350 if (collected_echo == azimuth_histogram.cend() || collected_echo->first != echo_idx || collected_echo->second.empty())
352 ROS_WARN_STREAM(
"## WARNING MsgPackValidator::validateNoMissingScandata() failed: no scan data found in echo " << echo_idx <<
":");
353 printMissingHistogramData(msgpack_data_collected.
print());
359 for (std::vector<int>::const_iterator iter_segment = m_valid_segments.cbegin(); iter_segment != m_valid_segments.cend(); iter_segment++)
361 int segment_idx = (*iter_segment);
362 const MsgPackValidatorData::AzimuthHistogramPerElevationPerSegment::const_iterator collected_segment = collected_echo->second.find(segment_idx);
364 if (collected_segment == collected_echo->second.cend() || collected_segment->first != segment_idx || collected_segment->second.empty())
372 for(MsgPackValidatorData::AzimuthHistogramPerElevation::const_iterator collected_elevation = collected_segment->second.cbegin(); collected_elevation != collected_segment->second.cend(); collected_elevation++)
374 int collected_elevation_idx = collected_elevation->first;
375 for(MsgPackValidatorData::AzimuthHistogram::const_iterator collected_azimuth = collected_elevation->second.cbegin(); collected_azimuth != collected_elevation->second.cend(); collected_azimuth++)
377 int collected_azimuth_idx = collected_azimuth->first;
378 int collected_azimuth_hist_cnt = collected_azimuth->second;
379 collected_azimuth_histogram_per_elevation[collected_elevation_idx][collected_azimuth_idx] += collected_azimuth_hist_cnt;
385 int num_layer_required = 0;
386 for (
int layer_idx = 0; layer_idx < m_layer_filter.size(); layer_idx++)
388 if(m_layer_filter[layer_idx])
389 num_layer_required++;
391 int num_layer_collected = 0;
392 for(MsgPackValidatorData::AzimuthHistogramPerElevation::const_iterator collected_elevation = collected_azimuth_histogram_per_elevation.begin(); collected_elevation != collected_azimuth_histogram_per_elevation.end(); collected_elevation++)
394 num_layer_collected++;
396 if(num_layer_required != num_layer_collected)
398 ROS_WARN_STREAM(
"## WARNING MsgPackValidator::validateNoMissingScandata() failed: " << num_layer_required <<
" layer expected, but " << num_layer_collected <<
" layer collected.");
399 printMissingHistogramData(msgpack_data_collected.
print());
404 for(MsgPackValidatorData::AzimuthHistogramPerElevation::iterator collected_elevation = collected_azimuth_histogram_per_elevation.begin(); collected_elevation != collected_azimuth_histogram_per_elevation.end(); collected_elevation++)
406 int elevation_idx = collected_elevation->first;
408 if (collected_azimuth_histogram.empty())
412 ROS_WARN_STREAM(
"## WARNING MsgPackValidator::validateNoMissingScandata() failed: no scan data found for elevation " << msgpack_data_collected.
elevationIndexToDeg(elevation_idx)
413 <<
" [deg] (echo " << echo_idx <<
")");
414 elevation_values_missing =
true;
420 int azimuth_idx_start = msgpack_data_collected.
azimuthRadToIndex(m_azimuth_start + azimuth_res);
421 int azimuth_idx_end = msgpack_data_collected.
azimuthRadToIndex(m_azimuth_end - azimuth_res);
422 for (
int azimuth_idx = azimuth_idx_start + 1; azimuth_idx < azimuth_idx_end; azimuth_idx++)
424 if(collected_azimuth_histogram[azimuth_idx] <= 0)
428 ROS_WARN_STREAM(
"## WARNING MsgPackValidator::validateNoMissingScandata() failed: no scan data found for azimuth " << msgpack_data_collected.
azimuthIndexToDeg(azimuth_idx)
429 <<
" [deg] (echo " << echo_idx <<
", elevation " << msgpack_data_collected.
elevationIndexToDeg(elevation_idx) <<
")");
430 azimuth_values_missing =
true;
444 ROS_WARN_STREAM(
"## WARNING MsgPackValidator::validateNoMissingScandata(): msgpack validation for missing scan data finished with error " << (elevation_values_missing ?
"elevation values missing ":
"") << (azimuth_values_missing ?
"azimuth values missing " :
"") );
445 printMissingHistogramData(msgpack_data_collected.
print());
447 else if (m_verbose > 0)
449 ROS_INFO_STREAM(
"MsgPackValidator::validateNoMissingScandata() finished successful.");