Instrument metrics in GlobalTrajectoryBuilder. (#945)
RFC=[0014](https://github.com/googlecartographer/rfcs/blob/master/text/0014-monitoring.md)master
parent
0190e7cd99
commit
36df3eec19
|
@ -19,13 +19,18 @@
|
|||
#include <memory>
|
||||
|
||||
#include "cartographer/common/make_unique.h"
|
||||
#include "cartographer/common/time.h"
|
||||
#include "cartographer/mapping/local_slam_result_data.h"
|
||||
#include "cartographer/metrics/family_factory.h"
|
||||
#include "glog/logging.h"
|
||||
|
||||
namespace cartographer {
|
||||
namespace mapping {
|
||||
namespace {
|
||||
|
||||
static auto* kLocalSlamMatchingResults = metrics::Counter::Null();
|
||||
static auto* kLocalSlamInsertionResults = metrics::Counter::Null();
|
||||
|
||||
template <typename LocalTrajectoryBuilder, typename PoseGraph>
|
||||
class GlobalTrajectoryBuilder : public mapping::TrajectoryBuilderInterface {
|
||||
public:
|
||||
|
@ -59,8 +64,10 @@ class GlobalTrajectoryBuilder : public mapping::TrajectoryBuilderInterface {
|
|||
// The range data has not been fully accumulated yet.
|
||||
return;
|
||||
}
|
||||
kLocalSlamMatchingResults->Increment();
|
||||
std::unique_ptr<InsertionResult> insertion_result;
|
||||
if (matching_result->insertion_result != nullptr) {
|
||||
kLocalSlamInsertionResults->Increment();
|
||||
auto node_id = pose_graph_->AddNode(
|
||||
matching_result->insertion_result->constant_data, trajectory_id_,
|
||||
matching_result->insertion_result->insertion_submaps);
|
||||
|
@ -149,5 +156,13 @@ std::unique_ptr<TrajectoryBuilderInterface> CreateGlobalTrajectoryBuilder3D(
|
|||
local_slam_result_callback);
|
||||
}
|
||||
|
||||
void GlobalTrajectoryBuilderRegisterMetrics(metrics::FamilyFactory* factory) {
|
||||
auto* results = factory->NewCounterFamily(
|
||||
"/mapping/internal/global_trajectory_builder/local_slam_results",
|
||||
"Local SLAM results");
|
||||
kLocalSlamMatchingResults = results->Add({{"type", "MatchingResult"}});
|
||||
kLocalSlamInsertionResults = results->Add({{"type", "InsertionResult"}});
|
||||
}
|
||||
|
||||
} // namespace mapping
|
||||
} // namespace cartographer
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "cartographer/mapping/internal/3d/pose_graph_3d.h"
|
||||
#include "cartographer/mapping/local_slam_result_data.h"
|
||||
#include "cartographer/mapping/trajectory_builder_interface.h"
|
||||
#include "cartographer/metrics/family_factory.h"
|
||||
|
||||
namespace cartographer {
|
||||
namespace mapping {
|
||||
|
@ -41,6 +42,9 @@ std::unique_ptr<TrajectoryBuilderInterface> CreateGlobalTrajectoryBuilder3D(
|
|||
const TrajectoryBuilderInterface::LocalSlamResultCallback&
|
||||
local_slam_result_callback);
|
||||
|
||||
void GlobalTrajectoryBuilderRegisterMetrics(
|
||||
metrics::FamilyFactory* family_factory);
|
||||
|
||||
} // namespace mapping
|
||||
} // namespace cartographer
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "cartographer/mapping/internal/2d/pose_graph/constraint_builder_2d.h"
|
||||
#include "cartographer/mapping/internal/3d/local_trajectory_builder_3d.h"
|
||||
#include "cartographer/mapping/internal/3d/pose_graph/constraint_builder_3d.h"
|
||||
#include "cartographer/mapping/internal/global_trajectory_builder.h"
|
||||
|
||||
namespace cartographer {
|
||||
namespace metrics {
|
||||
|
@ -27,6 +28,7 @@ namespace metrics {
|
|||
void RegisterAllMetrics(FamilyFactory* registry) {
|
||||
mapping::pose_graph::ConstraintBuilder2D::RegisterMetrics(registry);
|
||||
mapping::pose_graph::ConstraintBuilder3D::RegisterMetrics(registry);
|
||||
mapping::GlobalTrajectoryBuilderRegisterMetrics(registry);
|
||||
mapping::LocalTrajectoryBuilder2D::RegisterMetrics(registry);
|
||||
mapping::LocalTrajectoryBuilder3D::RegisterMetrics(registry);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue