diff --git a/cartographer/common/rate_timer.h b/cartographer/common/rate_timer.h index bb39e98..afa27ef 100644 --- a/cartographer/common/rate_timer.h +++ b/cartographer/common/rate_timer.h @@ -62,9 +62,8 @@ class RateTimer { return 0.; } return common::ToSeconds((events_.back().time - events_.front().time)) / - std::chrono::duration_cast>( - events_.back().wall_time - events_.front().wall_time) - .count(); + common::ToSeconds(events_.back().wall_time - + events_.front().wall_time); } // Records an event that will contribute to the computed rate. diff --git a/cartographer/mapping/internal/2d/local_trajectory_builder_2d.cc b/cartographer/mapping/internal/2d/local_trajectory_builder_2d.cc index eb8fdc6..52b9d56 100644 --- a/cartographer/mapping/internal/2d/local_trajectory_builder_2d.cc +++ b/cartographer/mapping/internal/2d/local_trajectory_builder_2d.cc @@ -241,10 +241,9 @@ LocalTrajectoryBuilder2D::AddAccumulatedRangeData( std::unique_ptr insertion_result = InsertIntoSubmap( time, range_data_in_local, filtered_gravity_aligned_point_cloud, pose_estimate, gravity_alignment.rotation()); - auto duration = std::chrono::steady_clock::now() - accumulation_started_; - kLocalSlamLatencyMetric->Set( - std::chrono::duration_cast>(duration) - .count()); + const auto accumulation_duration = + std::chrono::steady_clock::now() - accumulation_started_; + kLocalSlamLatencyMetric->Set(common::ToSeconds(accumulation_duration)); return common::make_unique( MatchingResult{time, pose_estimate, std::move(range_data_in_local), std::move(insertion_result)}); diff --git a/cartographer/mapping/internal/3d/local_trajectory_builder_3d.cc b/cartographer/mapping/internal/3d/local_trajectory_builder_3d.cc index f1de0ef..7050bf3 100644 --- a/cartographer/mapping/internal/3d/local_trajectory_builder_3d.cc +++ b/cartographer/mapping/internal/3d/local_trajectory_builder_3d.cc @@ -217,9 +217,7 @@ LocalTrajectoryBuilder3D::AddRangeData( if (sensor_duration.has_value()) { const double voxel_filter_fraction = - std::chrono::duration_cast>( - voxel_filter_duration) - .count() / + common::ToSeconds(voxel_filter_duration) / common::ToSeconds(sensor_duration.value()); kLocalSlamVoxelFilterFraction->Set(voxel_filter_fraction); } @@ -278,9 +276,7 @@ LocalTrajectoryBuilder3D::AddAccumulatedRangeData( const auto scan_matcher_duration = scan_matcher_stop - scan_matcher_start; if (sensor_duration.has_value()) { const double scan_matcher_fraction = - std::chrono::duration_cast>( - scan_matcher_duration) - .count() / + common::ToSeconds(scan_matcher_duration) / common::ToSeconds(sensor_duration.value()); kLocalSlamScanMatcherFraction->Set(scan_matcher_fraction); } @@ -301,19 +297,14 @@ LocalTrajectoryBuilder3D::AddAccumulatedRangeData( const auto insert_into_submap_duration = insert_into_submap_stop - insert_into_submap_start; if (sensor_duration.has_value()) { - double insert_into_submap_fraction = - std::chrono::duration_cast>( - insert_into_submap_duration) - .count() / + const double insert_into_submap_fraction = + common::ToSeconds(insert_into_submap_duration) / common::ToSeconds(sensor_duration.value()); kLocalSlamInsertIntoSubmapFraction->Set(insert_into_submap_fraction); } - - const auto duration = + const auto accumulation_duration = std::chrono::steady_clock::now() - accumulation_started_; - kLocalSlamLatencyMetric->Set( - std::chrono::duration_cast>(duration) - .count()); + kLocalSlamLatencyMetric->Set(common::ToSeconds(accumulation_duration)); return common::make_unique(MatchingResult{ time, *pose_estimate, std::move(filtered_range_data_in_local), std::move(insertion_result)});