Fix ClangTidy warnings. (#455)
parent
11dbdf91b9
commit
ba6f782949
|
@ -45,7 +45,7 @@ ThreadPool::~ThreadPool() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadPool::Schedule(std::function<void()> work_item) {
|
void ThreadPool::Schedule(const std::function<void()>& work_item) {
|
||||||
MutexLocker locker(&mutex_);
|
MutexLocker locker(&mutex_);
|
||||||
CHECK(running_);
|
CHECK(running_);
|
||||||
work_queue_.push_back(work_item);
|
work_queue_.push_back(work_item);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ThreadPool {
|
||||||
ThreadPool(const ThreadPool&) = delete;
|
ThreadPool(const ThreadPool&) = delete;
|
||||||
ThreadPool& operator=(const ThreadPool&) = delete;
|
ThreadPool& operator=(const ThreadPool&) = delete;
|
||||||
|
|
||||||
void Schedule(std::function<void()> work_item);
|
void Schedule(const std::function<void()>& work_item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoWork();
|
void DoWork();
|
||||||
|
|
|
@ -28,7 +28,7 @@ HybridGridPointsProcessor::HybridGridPointsProcessor(
|
||||||
|
|
||||||
std::unique_ptr<HybridGridPointsProcessor>
|
std::unique_ptr<HybridGridPointsProcessor>
|
||||||
HybridGridPointsProcessor::FromDictionary(
|
HybridGridPointsProcessor::FromDictionary(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* const dictionary,
|
common::LuaParameterDictionary* const dictionary,
|
||||||
PointsProcessor* const next) {
|
PointsProcessor* const next) {
|
||||||
return common::make_unique<HybridGridPointsProcessor>(
|
return common::make_unique<HybridGridPointsProcessor>(
|
||||||
|
|
|
@ -33,7 +33,7 @@ class HybridGridPointsProcessor : public PointsProcessor {
|
||||||
delete;
|
delete;
|
||||||
|
|
||||||
static std::unique_ptr<HybridGridPointsProcessor> FromDictionary(
|
static std::unique_ptr<HybridGridPointsProcessor> FromDictionary(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
||||||
|
|
||||||
~HybridGridPointsProcessor() override {}
|
~HybridGridPointsProcessor() override {}
|
||||||
|
|
|
@ -41,18 +41,18 @@ OutlierRemovingPointsProcessor::OutlierRemovingPointsProcessor(
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutlierRemovingPointsProcessor::Process(
|
void OutlierRemovingPointsProcessor::Process(
|
||||||
std::unique_ptr<PointsBatch> points) {
|
std::unique_ptr<PointsBatch> batch) {
|
||||||
switch (state_) {
|
switch (state_) {
|
||||||
case State::kPhase1:
|
case State::kPhase1:
|
||||||
ProcessInPhaseOne(*points);
|
ProcessInPhaseOne(*batch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State::kPhase2:
|
case State::kPhase2:
|
||||||
ProcessInPhaseTwo(*points);
|
ProcessInPhaseTwo(*batch);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State::kPhase3:
|
case State::kPhase3:
|
||||||
ProcessInPhaseThree(std::move(points));
|
ProcessInPhaseThree(std::move(batch));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ void WriteBinaryPlyPointColor(const Uint8Color& color,
|
||||||
|
|
||||||
std::unique_ptr<PlyWritingPointsProcessor>
|
std::unique_ptr<PlyWritingPointsProcessor>
|
||||||
PlyWritingPointsProcessor::FromDictionary(
|
PlyWritingPointsProcessor::FromDictionary(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* const dictionary,
|
common::LuaParameterDictionary* const dictionary,
|
||||||
PointsProcessor* const next) {
|
PointsProcessor* const next) {
|
||||||
return common::make_unique<PlyWritingPointsProcessor>(
|
return common::make_unique<PlyWritingPointsProcessor>(
|
||||||
|
|
|
@ -25,11 +25,11 @@ namespace io {
|
||||||
class PlyWritingPointsProcessor : public PointsProcessor {
|
class PlyWritingPointsProcessor : public PointsProcessor {
|
||||||
public:
|
public:
|
||||||
constexpr static const char* kConfigurationFileActionName = "write_ply";
|
constexpr static const char* kConfigurationFileActionName = "write_ply";
|
||||||
PlyWritingPointsProcessor(std::unique_ptr<FileWriter> file,
|
PlyWritingPointsProcessor(std::unique_ptr<FileWriter> file_writer,
|
||||||
PointsProcessor* next);
|
PointsProcessor* next);
|
||||||
|
|
||||||
static std::unique_ptr<PlyWritingPointsProcessor> FromDictionary(
|
static std::unique_ptr<PlyWritingPointsProcessor> FromDictionary(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
||||||
|
|
||||||
~PlyWritingPointsProcessor() override {}
|
~PlyWritingPointsProcessor() override {}
|
||||||
|
|
|
@ -48,7 +48,7 @@ void RegisterPlainPointsProcessor(
|
||||||
|
|
||||||
template <typename PointsProcessorType>
|
template <typename PointsProcessorType>
|
||||||
void RegisterFileWritingPointsProcessor(
|
void RegisterFileWritingPointsProcessor(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
PointsProcessorPipelineBuilder* const builder) {
|
PointsProcessorPipelineBuilder* const builder) {
|
||||||
builder->Register(
|
builder->Register(
|
||||||
PointsProcessorType::kConfigurationFileActionName,
|
PointsProcessorType::kConfigurationFileActionName,
|
||||||
|
@ -63,7 +63,7 @@ void RegisterFileWritingPointsProcessor(
|
||||||
template <typename PointsProcessorType>
|
template <typename PointsProcessorType>
|
||||||
void RegisterFileWritingPointsProcessorWithTrajectories(
|
void RegisterFileWritingPointsProcessorWithTrajectories(
|
||||||
const std::vector<mapping::proto::Trajectory>& trajectories,
|
const std::vector<mapping::proto::Trajectory>& trajectories,
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
PointsProcessorPipelineBuilder* const builder) {
|
PointsProcessorPipelineBuilder* const builder) {
|
||||||
builder->Register(
|
builder->Register(
|
||||||
PointsProcessorType::kConfigurationFileActionName,
|
PointsProcessorType::kConfigurationFileActionName,
|
||||||
|
@ -77,7 +77,7 @@ void RegisterFileWritingPointsProcessorWithTrajectories(
|
||||||
|
|
||||||
void RegisterBuiltInPointsProcessors(
|
void RegisterBuiltInPointsProcessors(
|
||||||
const std::vector<mapping::proto::Trajectory>& trajectories,
|
const std::vector<mapping::proto::Trajectory>& trajectories,
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
PointsProcessorPipelineBuilder* builder) {
|
PointsProcessorPipelineBuilder* builder) {
|
||||||
RegisterPlainPointsProcessor<CountingPointsProcessor>(builder);
|
RegisterPlainPointsProcessor<CountingPointsProcessor>(builder);
|
||||||
RegisterPlainPointsProcessor<FixedRatioSamplingPointsProcessor>(builder);
|
RegisterPlainPointsProcessor<FixedRatioSamplingPointsProcessor>(builder);
|
||||||
|
@ -104,7 +104,7 @@ void PointsProcessorPipelineBuilder::Register(const std::string& name,
|
||||||
FactoryFunction factory) {
|
FactoryFunction factory) {
|
||||||
CHECK(factories_.count(name) == 0) << "A points processor named '" << name
|
CHECK(factories_.count(name) == 0) << "A points processor named '" << name
|
||||||
<< "' has already been registered.";
|
<< "' has already been registered.";
|
||||||
factories_[name] = factory;
|
factories_[name] = std::move(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
PointsProcessorPipelineBuilder::PointsProcessorPipelineBuilder() {}
|
PointsProcessorPipelineBuilder::PointsProcessorPipelineBuilder() {}
|
||||||
|
|
|
@ -37,9 +37,9 @@ void WriteGrid(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Image image(cell_limits.num_x_cells, cell_limits.num_y_cells);
|
Image image(cell_limits.num_x_cells, cell_limits.num_y_cells);
|
||||||
for (auto xy_index :
|
for (const auto& xy_index :
|
||||||
cartographer::mapping_2d::XYIndexRangeIterator(cell_limits)) {
|
cartographer::mapping_2d::XYIndexRangeIterator(cell_limits)) {
|
||||||
auto index = xy_index + offset;
|
const auto index = xy_index + offset;
|
||||||
uint8 value = compute_color_value(index);
|
uint8 value = compute_color_value(index);
|
||||||
image.SetPixel(xy_index.x(), xy_index.y(), {{value, value, value}});
|
image.SetPixel(xy_index.x(), xy_index.y(), {{value, value, value}});
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ ProbabilityGridPointsProcessor::ProbabilityGridPointsProcessor(
|
||||||
std::unique_ptr<ProbabilityGridPointsProcessor>
|
std::unique_ptr<ProbabilityGridPointsProcessor>
|
||||||
ProbabilityGridPointsProcessor::FromDictionary(
|
ProbabilityGridPointsProcessor::FromDictionary(
|
||||||
const std::vector<mapping::proto::Trajectory>& trajectories,
|
const std::vector<mapping::proto::Trajectory>& trajectories,
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* const dictionary,
|
common::LuaParameterDictionary* const dictionary,
|
||||||
PointsProcessor* const next) {
|
PointsProcessor* const next) {
|
||||||
const auto draw_trajectories = (!dictionary->HasKey("draw_trajectories") ||
|
const auto draw_trajectories = (!dictionary->HasKey("draw_trajectories") ||
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ProbabilityGridPointsProcessor : public PointsProcessor {
|
||||||
|
|
||||||
static std::unique_ptr<ProbabilityGridPointsProcessor> FromDictionary(
|
static std::unique_ptr<ProbabilityGridPointsProcessor> FromDictionary(
|
||||||
const std::vector<mapping::proto::Trajectory>& trajectories,
|
const std::vector<mapping::proto::Trajectory>& trajectories,
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
||||||
|
|
||||||
~ProbabilityGridPointsProcessor() override {}
|
~ProbabilityGridPointsProcessor() override {}
|
||||||
|
|
|
@ -27,7 +27,7 @@ XyzWriterPointsProcessor::XyzWriterPointsProcessor(
|
||||||
|
|
||||||
std::unique_ptr<XyzWriterPointsProcessor>
|
std::unique_ptr<XyzWriterPointsProcessor>
|
||||||
XyzWriterPointsProcessor::FromDictionary(
|
XyzWriterPointsProcessor::FromDictionary(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* const dictionary,
|
common::LuaParameterDictionary* const dictionary,
|
||||||
PointsProcessor* const next) {
|
PointsProcessor* const next) {
|
||||||
return common::make_unique<XyzWriterPointsProcessor>(
|
return common::make_unique<XyzWriterPointsProcessor>(
|
||||||
|
|
|
@ -36,7 +36,7 @@ class XyzWriterPointsProcessor : public PointsProcessor {
|
||||||
XyzWriterPointsProcessor(std::unique_ptr<FileWriter>, PointsProcessor* next);
|
XyzWriterPointsProcessor(std::unique_ptr<FileWriter>, PointsProcessor* next);
|
||||||
|
|
||||||
static std::unique_ptr<XyzWriterPointsProcessor> FromDictionary(
|
static std::unique_ptr<XyzWriterPointsProcessor> FromDictionary(
|
||||||
FileWriterFactory file_writer_factory,
|
const FileWriterFactory& file_writer_factory,
|
||||||
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
common::LuaParameterDictionary* dictionary, PointsProcessor* next);
|
||||||
|
|
||||||
~XyzWriterPointsProcessor() override {}
|
~XyzWriterPointsProcessor() override {}
|
||||||
|
|
|
@ -41,7 +41,7 @@ void GlobalTrajectoryBuilder::AddRangefinderData(
|
||||||
insertion_result->time, insertion_result->tracking_to_tracking_2d,
|
insertion_result->time, insertion_result->tracking_to_tracking_2d,
|
||||||
insertion_result->range_data_in_tracking_2d,
|
insertion_result->range_data_in_tracking_2d,
|
||||||
insertion_result->pose_estimate_2d, trajectory_id_,
|
insertion_result->pose_estimate_2d, trajectory_id_,
|
||||||
std::move(insertion_result->insertion_submaps));
|
insertion_result->insertion_submaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalTrajectoryBuilder::AddImuData(const sensor::ImuData& imu_data) {
|
void GlobalTrajectoryBuilder::AddImuData(const sensor::ImuData& imu_data) {
|
||||||
|
|
|
@ -174,7 +174,7 @@ LocalTrajectoryBuilder::AddAccumulatedRangeData(
|
||||||
// Querying the active submaps must be done here before calling
|
// Querying the active submaps must be done here before calling
|
||||||
// InsertRangeData() since the queried values are valid for next insertion.
|
// InsertRangeData() since the queried values are valid for next insertion.
|
||||||
std::vector<std::shared_ptr<const Submap>> insertion_submaps;
|
std::vector<std::shared_ptr<const Submap>> insertion_submaps;
|
||||||
for (std::shared_ptr<Submap> submap : active_submaps_.submaps()) {
|
for (const std::shared_ptr<Submap>& submap : active_submaps_.submaps()) {
|
||||||
insertion_submaps.push_back(submap);
|
insertion_submaps.push_back(submap);
|
||||||
}
|
}
|
||||||
active_submaps_.InsertRangeData(
|
active_submaps_.InsertRangeData(
|
||||||
|
|
|
@ -58,7 +58,8 @@ class LocalTrajectoryBuilder {
|
||||||
std::unique_ptr<InsertionResult> AddHorizontalRangeData(
|
std::unique_ptr<InsertionResult> AddHorizontalRangeData(
|
||||||
common::Time, const sensor::RangeData& range_data);
|
common::Time, const sensor::RangeData& range_data);
|
||||||
void AddImuData(const sensor::ImuData& imu_data);
|
void AddImuData(const sensor::ImuData& imu_data);
|
||||||
void AddOdometerData(common::Time time, const transform::Rigid3d& pose);
|
void AddOdometerData(common::Time time,
|
||||||
|
const transform::Rigid3d& odometer_pose);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<InsertionResult> AddAccumulatedRangeData(
|
std::unique_ptr<InsertionResult> AddAccumulatedRangeData(
|
||||||
|
|
|
@ -38,7 +38,7 @@ bool PerformGlobalLocalization(
|
||||||
const sensor::PointCloud filtered_point_cloud =
|
const sensor::PointCloud filtered_point_cloud =
|
||||||
voxel_filter.Filter(point_cloud);
|
voxel_filter.Filter(point_cloud);
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (matchers.size() == 0) {
|
if (matchers.empty()) {
|
||||||
LOG(WARNING) << "Map not yet large enough to localize in!";
|
LOG(WARNING) << "Map not yet large enough to localize in!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ void SparsePoseGraph::AddScan(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparsePoseGraph::AddWorkItem(std::function<void()> work_item) {
|
void SparsePoseGraph::AddWorkItem(const std::function<void()>& work_item) {
|
||||||
if (scan_queue_ == nullptr) {
|
if (scan_queue_ == nullptr) {
|
||||||
work_item();
|
work_item();
|
||||||
} else {
|
} else {
|
||||||
|
@ -432,6 +432,10 @@ void SparsePoseGraph::RunOptimization() {
|
||||||
if (optimization_problem_.submap_data().empty()) {
|
if (optimization_problem_.submap_data().empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No other thread is accessing the optimization_problem_, constraints_ and
|
||||||
|
// frozen_trajectories_ when executing the Solve. Solve is time consuming, so
|
||||||
|
// not taking the mutex before Solve to avoid blocking foreground processing.
|
||||||
optimization_problem_.Solve(constraints_, frozen_trajectories_);
|
optimization_problem_.Solve(constraints_, frozen_trajectories_);
|
||||||
common::MutexLocker locker(&mutex_);
|
common::MutexLocker locker(&mutex_);
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ class SparsePoseGraph : public mapping::SparsePoseGraph {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles a new work item.
|
// Handles a new work item.
|
||||||
void AddWorkItem(std::function<void()> work_item) REQUIRES(mutex_);
|
void AddWorkItem(const std::function<void()>& work_item) REQUIRES(mutex_);
|
||||||
|
|
||||||
// Grows the optimization problem to have an entry for every element of
|
// Grows the optimization problem to have an entry for every element of
|
||||||
// 'insertion_submaps'. Returns the IDs for the 'insertion_submaps'.
|
// 'insertion_submaps'. Returns the IDs for the 'insertion_submaps'.
|
||||||
|
|
|
@ -111,7 +111,7 @@ void ConstraintBuilder::NotifyEndOfScan() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstraintBuilder::WhenDone(
|
void ConstraintBuilder::WhenDone(
|
||||||
const std::function<void(const ConstraintBuilder::Result&)> callback) {
|
const std::function<void(const ConstraintBuilder::Result&)>& callback) {
|
||||||
common::MutexLocker locker(&mutex_);
|
common::MutexLocker locker(&mutex_);
|
||||||
CHECK(when_done_ == nullptr);
|
CHECK(when_done_ == nullptr);
|
||||||
when_done_ =
|
when_done_ =
|
||||||
|
@ -124,7 +124,7 @@ void ConstraintBuilder::WhenDone(
|
||||||
|
|
||||||
void ConstraintBuilder::ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
void ConstraintBuilder::ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
||||||
const mapping::SubmapId& submap_id, const ProbabilityGrid* const submap,
|
const mapping::SubmapId& submap_id, const ProbabilityGrid* const submap,
|
||||||
const std::function<void()> work_item) {
|
const std::function<void()>& work_item) {
|
||||||
if (submap_scan_matchers_[submap_id].fast_correlative_scan_matcher !=
|
if (submap_scan_matchers_[submap_id].fast_correlative_scan_matcher !=
|
||||||
nullptr) {
|
nullptr) {
|
||||||
thread_pool_->Schedule(work_item);
|
thread_pool_->Schedule(work_item);
|
||||||
|
|
|
@ -102,7 +102,7 @@ class ConstraintBuilder {
|
||||||
|
|
||||||
// Registers the 'callback' to be called with the results, after all
|
// Registers the 'callback' to be called with the results, after all
|
||||||
// computations triggered by MaybeAddConstraint() have finished.
|
// computations triggered by MaybeAddConstraint() have finished.
|
||||||
void WhenDone(std::function<void(const Result&)> callback);
|
void WhenDone(const std::function<void(const Result&)>& callback);
|
||||||
|
|
||||||
// Returns the number of consecutive finished scans.
|
// Returns the number of consecutive finished scans.
|
||||||
int GetNumFinishedScans();
|
int GetNumFinishedScans();
|
||||||
|
@ -121,7 +121,7 @@ class ConstraintBuilder {
|
||||||
// construction and queues the 'work_item'.
|
// construction and queues the 'work_item'.
|
||||||
void ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
void ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
||||||
const mapping::SubmapId& submap_id, const ProbabilityGrid* submap,
|
const mapping::SubmapId& submap_id, const ProbabilityGrid* submap,
|
||||||
std::function<void()> work_item) REQUIRES(mutex_);
|
const std::function<void()>& work_item) REQUIRES(mutex_);
|
||||||
|
|
||||||
// Constructs the scan matcher for a 'submap', then schedules its work items.
|
// Constructs the scan matcher for a 'submap', then schedules its work items.
|
||||||
void ConstructSubmapScanMatcher(const mapping::SubmapId& submap_id,
|
void ConstructSubmapScanMatcher(const mapping::SubmapId& submap_id,
|
||||||
|
|
|
@ -158,7 +158,7 @@ class SparsePoseGraphTest : public ::testing::Test {
|
||||||
point_cloud_,
|
point_cloud_,
|
||||||
transform::Embed3D(current_pose_.inverse().cast<float>()));
|
transform::Embed3D(current_pose_.inverse().cast<float>()));
|
||||||
std::vector<std::shared_ptr<const Submap>> insertion_submaps;
|
std::vector<std::shared_ptr<const Submap>> insertion_submaps;
|
||||||
for (auto submap : active_submaps_->submaps()) {
|
for (const auto& submap : active_submaps_->submaps()) {
|
||||||
insertion_submaps.push_back(submap);
|
insertion_submaps.push_back(submap);
|
||||||
}
|
}
|
||||||
const sensor::RangeData range_data{
|
const sensor::RangeData range_data{
|
||||||
|
@ -170,7 +170,7 @@ class SparsePoseGraphTest : public ::testing::Test {
|
||||||
|
|
||||||
sparse_pose_graph_->AddScan(
|
sparse_pose_graph_->AddScan(
|
||||||
common::FromUniversal(0), transform::Rigid3d::Identity(), range_data,
|
common::FromUniversal(0), transform::Rigid3d::Identity(), range_data,
|
||||||
pose_estimate, kTrajectoryId, std::move(insertion_submaps));
|
pose_estimate, kTrajectoryId, insertion_submaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveRelative(const transform::Rigid2d& movement) {
|
void MoveRelative(const transform::Rigid2d& movement) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ TEST(SubmapsTest, TheRightNumberOfScansAreInserted) {
|
||||||
for (int i = 0; i != 1000; ++i) {
|
for (int i = 0; i != 1000; ++i) {
|
||||||
submaps.InsertRangeData({Eigen::Vector3f::Zero(), {}, {}});
|
submaps.InsertRangeData({Eigen::Vector3f::Zero(), {}, {}});
|
||||||
// Except for the first, maps should only be returned after enough scans.
|
// Except for the first, maps should only be returned after enough scans.
|
||||||
for (auto submap : submaps.submaps()) {
|
for (const auto& submap : submaps.submaps()) {
|
||||||
all_submaps.insert(submap);
|
all_submaps.insert(submap);
|
||||||
}
|
}
|
||||||
if (submaps.matching_index() != 0) {
|
if (submaps.matching_index() != 0) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ void GlobalTrajectoryBuilder::AddRangefinderData(
|
||||||
sparse_pose_graph_->AddScan(
|
sparse_pose_graph_->AddScan(
|
||||||
insertion_result->time, insertion_result->range_data_in_tracking,
|
insertion_result->time, insertion_result->range_data_in_tracking,
|
||||||
insertion_result->pose_observation, trajectory_id_,
|
insertion_result->pose_observation, trajectory_id_,
|
||||||
std::move(insertion_result->insertion_submaps));
|
insertion_result->insertion_submaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalTrajectoryBuilder::AddOdometerData(const common::Time time,
|
void GlobalTrajectoryBuilder::AddOdometerData(const common::Time time,
|
||||||
|
|
|
@ -190,7 +190,7 @@ LocalTrajectoryBuilder::InsertIntoSubmap(
|
||||||
// Querying the active submaps must be done here before calling
|
// Querying the active submaps must be done here before calling
|
||||||
// InsertRangeData() since the queried values are valid for next insertion.
|
// InsertRangeData() since the queried values are valid for next insertion.
|
||||||
std::vector<std::shared_ptr<const Submap>> insertion_submaps;
|
std::vector<std::shared_ptr<const Submap>> insertion_submaps;
|
||||||
for (std::shared_ptr<Submap> submap : active_submaps_.submaps()) {
|
for (const std::shared_ptr<Submap>& submap : active_submaps_.submaps()) {
|
||||||
insertion_submaps.push_back(submap);
|
insertion_submaps.push_back(submap);
|
||||||
}
|
}
|
||||||
active_submaps_.InsertRangeData(
|
active_submaps_.InsertRangeData(
|
||||||
|
|
|
@ -139,7 +139,7 @@ void SparsePoseGraph::AddScan(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparsePoseGraph::AddWorkItem(std::function<void()> work_item) {
|
void SparsePoseGraph::AddWorkItem(const std::function<void()>& work_item) {
|
||||||
if (scan_queue_ == nullptr) {
|
if (scan_queue_ == nullptr) {
|
||||||
work_item();
|
work_item();
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,6 +427,10 @@ void SparsePoseGraph::RunOptimization() {
|
||||||
if (optimization_problem_.submap_data().empty()) {
|
if (optimization_problem_.submap_data().empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No other thread is accessing the optimization_problem_, constraints_ and
|
||||||
|
// frozen_trajectories_ when executing the Solve. Solve is time consuming, so
|
||||||
|
// not taking the mutex before Solve to avoid blocking foreground processing.
|
||||||
optimization_problem_.Solve(constraints_, frozen_trajectories_);
|
optimization_problem_.Solve(constraints_, frozen_trajectories_);
|
||||||
common::MutexLocker locker(&mutex_);
|
common::MutexLocker locker(&mutex_);
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ class SparsePoseGraph : public mapping::SparsePoseGraph {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles a new work item.
|
// Handles a new work item.
|
||||||
void AddWorkItem(std::function<void()> work_item) REQUIRES(mutex_);
|
void AddWorkItem(const std::function<void()>& work_item) REQUIRES(mutex_);
|
||||||
|
|
||||||
// Grows the optimization problem to have an entry for every element of
|
// Grows the optimization problem to have an entry for every element of
|
||||||
// 'insertion_submaps'. Returns the IDs for the 'insertion_submaps'.
|
// 'insertion_submaps'. Returns the IDs for the 'insertion_submaps'.
|
||||||
|
|
|
@ -109,7 +109,7 @@ void ConstraintBuilder::NotifyEndOfScan() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConstraintBuilder::WhenDone(
|
void ConstraintBuilder::WhenDone(
|
||||||
const std::function<void(const ConstraintBuilder::Result&)> callback) {
|
const std::function<void(const ConstraintBuilder::Result&)>& callback) {
|
||||||
common::MutexLocker locker(&mutex_);
|
common::MutexLocker locker(&mutex_);
|
||||||
CHECK(when_done_ == nullptr);
|
CHECK(when_done_ == nullptr);
|
||||||
when_done_ =
|
when_done_ =
|
||||||
|
@ -123,7 +123,7 @@ void ConstraintBuilder::WhenDone(
|
||||||
void ConstraintBuilder::ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
void ConstraintBuilder::ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
||||||
const mapping::SubmapId& submap_id,
|
const mapping::SubmapId& submap_id,
|
||||||
const std::vector<mapping::TrajectoryNode>& submap_nodes,
|
const std::vector<mapping::TrajectoryNode>& submap_nodes,
|
||||||
const Submap* const submap, const std::function<void()> work_item) {
|
const Submap* const submap, const std::function<void()>& work_item) {
|
||||||
if (submap_scan_matchers_[submap_id].fast_correlative_scan_matcher !=
|
if (submap_scan_matchers_[submap_id].fast_correlative_scan_matcher !=
|
||||||
nullptr) {
|
nullptr) {
|
||||||
thread_pool_->Schedule(work_item);
|
thread_pool_->Schedule(work_item);
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ConstraintBuilder {
|
||||||
|
|
||||||
// Registers the 'callback' to be called with the results, after all
|
// Registers the 'callback' to be called with the results, after all
|
||||||
// computations triggered by MaybeAddConstraint() have finished.
|
// computations triggered by MaybeAddConstraint() have finished.
|
||||||
void WhenDone(std::function<void(const Result&)> callback);
|
void WhenDone(const std::function<void(const Result&)>& callback);
|
||||||
|
|
||||||
// Returns the number of consecutive finished scans.
|
// Returns the number of consecutive finished scans.
|
||||||
int GetNumFinishedScans();
|
int GetNumFinishedScans();
|
||||||
|
@ -121,7 +121,7 @@ class ConstraintBuilder {
|
||||||
void ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
void ScheduleSubmapScanMatcherConstructionAndQueueWorkItem(
|
||||||
const mapping::SubmapId& submap_id,
|
const mapping::SubmapId& submap_id,
|
||||||
const std::vector<mapping::TrajectoryNode>& submap_nodes,
|
const std::vector<mapping::TrajectoryNode>& submap_nodes,
|
||||||
const Submap* submap, std::function<void()> work_item) REQUIRES(mutex_);
|
const Submap* submap, const std::function<void()>& work_item) REQUIRES(mutex_);
|
||||||
|
|
||||||
// Constructs the scan matcher for a 'submap', then schedules its work items.
|
// Constructs the scan matcher for a 'submap', then schedules its work items.
|
||||||
void ConstructSubmapScanMatcher(
|
void ConstructSubmapScanMatcher(
|
||||||
|
|
|
@ -205,6 +205,7 @@ void OptimizationProblem::Solve(const std::vector<Constraint>& constraints,
|
||||||
// Add constraints based on IMU observations of angular velocities and
|
// Add constraints based on IMU observations of angular velocities and
|
||||||
// linear acceleration.
|
// linear acceleration.
|
||||||
trajectory_data_.resize(imu_data_.size());
|
trajectory_data_.resize(imu_data_.size());
|
||||||
|
CHECK_GE(trajectory_data_.size(), node_data_.size());
|
||||||
for (size_t trajectory_id = 0; trajectory_id != node_data_.size();
|
for (size_t trajectory_id = 0; trajectory_id != node_data_.size();
|
||||||
++trajectory_id) {
|
++trajectory_id) {
|
||||||
const auto& node_data = node_data_[trajectory_id];
|
const auto& node_data = node_data_[trajectory_id];
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace sensor {
|
||||||
void Collator::AddTrajectory(
|
void Collator::AddTrajectory(
|
||||||
const int trajectory_id,
|
const int trajectory_id,
|
||||||
const std::unordered_set<string>& expected_sensor_ids,
|
const std::unordered_set<string>& expected_sensor_ids,
|
||||||
const Callback callback) {
|
const Callback& callback) {
|
||||||
for (const auto& sensor_id : expected_sensor_ids) {
|
for (const auto& sensor_id : expected_sensor_ids) {
|
||||||
const auto queue_key = QueueKey{trajectory_id, sensor_id};
|
const auto queue_key = QueueKey{trajectory_id, sensor_id};
|
||||||
queue_.AddQueue(queue_key,
|
queue_.AddQueue(queue_key,
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Collator {
|
||||||
// for each collated sensor data.
|
// for each collated sensor data.
|
||||||
void AddTrajectory(int trajectory_id,
|
void AddTrajectory(int trajectory_id,
|
||||||
const std::unordered_set<string>& expected_sensor_ids,
|
const std::unordered_set<string>& expected_sensor_ids,
|
||||||
Callback callback);
|
const Callback& callback);
|
||||||
|
|
||||||
// Marks 'trajectory_id' as finished.
|
// Marks 'trajectory_id' as finished.
|
||||||
void FinishTrajectory(int trajectory_id);
|
void FinishTrajectory(int trajectory_id);
|
||||||
|
|
|
@ -54,7 +54,7 @@ proto::CompressedRangeData ToProto(
|
||||||
CompressedRangeData FromProto(const proto::CompressedRangeData& proto);
|
CompressedRangeData FromProto(const proto::CompressedRangeData& proto);
|
||||||
CompressedRangeData Compress(const RangeData& range_data);
|
CompressedRangeData Compress(const RangeData& range_data);
|
||||||
|
|
||||||
RangeData Decompress(const CompressedRangeData& compressed_range_Data);
|
RangeData Decompress(const CompressedRangeData& compressed_range_data);
|
||||||
|
|
||||||
} // namespace sensor
|
} // namespace sensor
|
||||||
} // namespace cartographer
|
} // namespace cartographer
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace sensor {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ::testing::Contains;
|
using ::testing::Contains;
|
||||||
using ::testing::PrintToString;
|
|
||||||
|
|
||||||
MATCHER(NearPointwise, std::string(negation ? "Doesn't" : "Does") + " match.") {
|
MATCHER(NearPointwise, std::string(negation ? "Doesn't" : "Does") + " match.") {
|
||||||
return std::get<0>(arg).isApprox(std::get<1>(arg), 0.001f);
|
return std::get<0>(arg).isApprox(std::get<1>(arg), 0.001f);
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
namespace cartographer {
|
namespace cartographer {
|
||||||
namespace transform {
|
namespace transform {
|
||||||
|
|
||||||
Rigid2d ToRigid2(const proto::Rigid2d& pose) {
|
Rigid2d ToRigid2(const proto::Rigid2d& transform) {
|
||||||
return Rigid2d({pose.translation().x(), pose.translation().y()},
|
return Rigid2d({transform.translation().x(), transform.translation().y()},
|
||||||
pose.rotation());
|
transform.rotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
Eigen::Vector2d ToEigen(const proto::Vector2d& vector) {
|
Eigen::Vector2d ToEigen(const proto::Vector2d& vector) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace transform {
|
||||||
|
|
||||||
void TransformInterpolationBuffer::Push(const common::Time time,
|
void TransformInterpolationBuffer::Push(const common::Time time,
|
||||||
const transform::Rigid3d& transform) {
|
const transform::Rigid3d& transform) {
|
||||||
if (deque_.size() > 0) {
|
if (!deque_.empty()) {
|
||||||
CHECK_GE(time, latest_time()) << "New transform is older than latest.";
|
CHECK_GE(time, latest_time()) << "New transform is older than latest.";
|
||||||
}
|
}
|
||||||
deque_.push_back(TimestampedTransform{time, transform});
|
deque_.push_back(TimestampedTransform{time, transform});
|
||||||
|
|
Loading…
Reference in New Issue