Removes sensor packet period histogram. (#104)

master
Damon Kohler 2016-10-26 15:23:37 +02:00 committed by GitHub
parent 6e6d2decaa
commit 15f9244577
6 changed files with 0 additions and 187 deletions

View File

@ -26,38 +26,6 @@
namespace cartographer {
namespace common {
namespace {
string PaddedTo(string input, int new_length) {
CHECK_GE(new_length, input.size());
input.insert(input.begin(), new_length - input.size(), ' ');
return input;
}
} // namespace
void BucketHistogram::Hit(const string& bucket) { ++buckets_[bucket]; }
string BucketHistogram::ToString() const {
int64 sum = 0;
size_t max_bucket_name_length = 0;
for (const auto& pair : buckets_) {
sum += pair.second;
max_bucket_name_length =
std::max(pair.first.size(), max_bucket_name_length);
}
string result;
for (const auto& pair : buckets_) {
const float percent = 100.f * pair.second / std::max<int64>(1, sum);
result += PaddedTo(pair.first, max_bucket_name_length) + ": " +
PaddedTo(std::to_string(pair.second), 7) + " (" +
std::to_string(percent) + " %)\n";
}
result += "Total: " + std::to_string(sum);
return result;
}
void Histogram::Add(const float value) { values_.push_back(value); }
string Histogram::ToString(const int buckets) const {

View File

@ -26,15 +26,6 @@
namespace cartographer {
namespace common {
class BucketHistogram {
public:
void Hit(const string& bucket);
string ToString() const;
private:
std::map<string, int64> buckets_;
};
class Histogram {
public:
void Add(float value);

View File

@ -24,7 +24,6 @@ google_library(sensor_collator
common_time
sensor_data
sensor_ordered_multi_queue
sensor_sensor_packet_period_histogram_builder
)
google_library(sensor_compressed_point_cloud
@ -103,17 +102,6 @@ google_library(sensor_point_cloud
transform_transform
)
google_library(sensor_sensor_packet_period_histogram_builder
USES_GLOG
SRCS
sensor_packet_period_histogram_builder.cc
HDRS
sensor_packet_period_histogram_builder.h
DEPENDS
common_histogram
common_port
)
google_library(sensor_voxel_filter
SRCS
voxel_filter.cc

View File

@ -29,7 +29,6 @@
#include "cartographer/common/time.h"
#include "cartographer/sensor/data.h"
#include "cartographer/sensor/ordered_multi_queue.h"
#include "cartographer/sensor/sensor_packet_period_histogram_builder.h"
#include "glog/logging.h"
namespace cartographer {
@ -71,8 +70,6 @@ class Collator {
// order.
void AddSensorData(const int trajectory_id, const string& sensor_id,
std::unique_ptr<Data> data) {
sensor_packet_period_histogram_builder_.Add(
trajectory_id, common::ToUniversal(data->time), sensor_id);
queue_.Add(QueueKey{trajectory_id, sensor_id}, std::move(data));
}
@ -80,7 +77,6 @@ class Collator {
// AddSensorData may not be called after Flush.
void Flush() {
queue_.Flush();
sensor_packet_period_histogram_builder_.LogHistogramsAndClear();
}
// Returns the number of packets associated with 'trajectory_id' that are
@ -99,7 +95,6 @@ class Collator {
// Map of trajectory ID to all associated QueueKeys.
std::unordered_map<int, std::vector<QueueKey>> queue_keys_;
SensorPacketPeriodHistogramBuilder sensor_packet_period_histogram_builder_;
};
} // namespace sensor

View File

@ -1,84 +0,0 @@
/*
* Copyright 2016 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/sensor/sensor_packet_period_histogram_builder.h"
#include "glog/logging.h"
namespace cartographer {
namespace sensor {
namespace {
string ToBucket(int ticks) {
if (ticks < 1 * 10000) {
return "< 1ms";
} else if (ticks < 3 * 10000) {
return "< 3ms";
} else if (ticks < 5 * 10000) {
return "< 5ms";
} else if (ticks < 7 * 10000) {
return "< 7ms";
} else if (ticks < 10 * 10000) {
return "< 10ms";
} else if (ticks < 30 * 10000) {
return "< 30ms";
} else if (ticks < 100 * 10000) {
return "< 100ms";
} else if (ticks < 500 * 10000) {
return "< 500ms";
}
return "> 500ms";
}
} // namespace
void SensorPacketPeriodHistogramBuilder::Add(const int trajectory_id,
const int64 timestamp,
const string& frame_id) {
if (histograms_.count(trajectory_id) == 0) {
histograms_.emplace(trajectory_id,
std::unordered_map<string, common::BucketHistogram>());
}
if (histograms_.at(trajectory_id).count(frame_id) == 0) {
histograms_.at(trajectory_id).emplace(frame_id, common::BucketHistogram());
}
const Key key = std::make_pair(trajectory_id, frame_id);
if (last_timestamps_.count(key) != 0) {
const int64 previous_timestamp = last_timestamps_.at(key);
histograms_.at(trajectory_id)
.at(frame_id)
.Hit(ToBucket(timestamp - previous_timestamp));
}
last_timestamps_[key] = timestamp;
}
void SensorPacketPeriodHistogramBuilder::LogHistogramsAndClear() {
for (const auto& trajectory_map_entry : histograms_) {
LOG(INFO) << "Printing histograms for trajectory with id "
<< trajectory_map_entry.first;
for (const auto& frame_id_to_histogram_map : trajectory_map_entry.second) {
LOG(INFO) << "Sensor packet period histogram for '"
<< frame_id_to_histogram_map.first << "' from trajectory '"
<< trajectory_map_entry.first << "':\n"
<< frame_id_to_histogram_map.second.ToString();
}
}
histograms_.clear();
last_timestamps_.clear();
}
} // namespace sensor
} // namespace cartographer

View File

@ -1,45 +0,0 @@
/*
* Copyright 2016 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_SENSOR_SENSOR_PACKET_PERIOD_HISTOGRAM_BUILDER_H_
#define CARTOGRAPHER_SENSOR_SENSOR_PACKET_PERIOD_HISTOGRAM_BUILDER_H_
#include <map>
#include <unordered_map>
#include "cartographer/common/histogram.h"
#include "cartographer/common/port.h"
namespace cartographer {
namespace sensor {
class SensorPacketPeriodHistogramBuilder {
public:
void Add(int trajectory_id, int64 timestamp, const string& frame_id);
void LogHistogramsAndClear();
private:
using Key = std::pair<int, string>;
std::map<Key, int64> last_timestamps_;
std::unordered_map<int, std::unordered_map<string, common::BucketHistogram>>
histograms_;
};
} // namespace sensor
} // namespace cartographer
#endif // CARTOGRAPHER_SENSOR_SENSOR_PACKET_PERIOD_HISTOGRAM_BUILDER_H_