use common::ToSeconds in local_trajectory_builder and rate_timer.h (#1248)

use the new overload of ToSeconds (introduced in 
[PR1244](https://github.com/googlecartographer/cartographer/pull/1244/files)) in local_trajectory_builder.
master
Susanne Pielawa 2018-07-10 13:14:54 +02:00 committed by Wally B. Feed
parent afa3ba5336
commit a04b6cbc48
3 changed files with 11 additions and 22 deletions

View File

@ -62,9 +62,8 @@ class RateTimer {
return 0.; return 0.;
} }
return common::ToSeconds((events_.back().time - events_.front().time)) / return common::ToSeconds((events_.back().time - events_.front().time)) /
std::chrono::duration_cast<std::chrono::duration<double>>( common::ToSeconds(events_.back().wall_time -
events_.back().wall_time - events_.front().wall_time) events_.front().wall_time);
.count();
} }
// Records an event that will contribute to the computed rate. // Records an event that will contribute to the computed rate.

View File

@ -241,10 +241,9 @@ LocalTrajectoryBuilder2D::AddAccumulatedRangeData(
std::unique_ptr<InsertionResult> insertion_result = InsertIntoSubmap( std::unique_ptr<InsertionResult> insertion_result = InsertIntoSubmap(
time, range_data_in_local, filtered_gravity_aligned_point_cloud, time, range_data_in_local, filtered_gravity_aligned_point_cloud,
pose_estimate, gravity_alignment.rotation()); pose_estimate, gravity_alignment.rotation());
auto duration = std::chrono::steady_clock::now() - accumulation_started_; const auto accumulation_duration =
kLocalSlamLatencyMetric->Set( std::chrono::steady_clock::now() - accumulation_started_;
std::chrono::duration_cast<std::chrono::duration<double>>(duration) kLocalSlamLatencyMetric->Set(common::ToSeconds(accumulation_duration));
.count());
return common::make_unique<MatchingResult>( return common::make_unique<MatchingResult>(
MatchingResult{time, pose_estimate, std::move(range_data_in_local), MatchingResult{time, pose_estimate, std::move(range_data_in_local),
std::move(insertion_result)}); std::move(insertion_result)});

View File

@ -217,9 +217,7 @@ LocalTrajectoryBuilder3D::AddRangeData(
if (sensor_duration.has_value()) { if (sensor_duration.has_value()) {
const double voxel_filter_fraction = const double voxel_filter_fraction =
std::chrono::duration_cast<std::chrono::duration<double>>( common::ToSeconds(voxel_filter_duration) /
voxel_filter_duration)
.count() /
common::ToSeconds(sensor_duration.value()); common::ToSeconds(sensor_duration.value());
kLocalSlamVoxelFilterFraction->Set(voxel_filter_fraction); kLocalSlamVoxelFilterFraction->Set(voxel_filter_fraction);
} }
@ -278,9 +276,7 @@ LocalTrajectoryBuilder3D::AddAccumulatedRangeData(
const auto scan_matcher_duration = scan_matcher_stop - scan_matcher_start; const auto scan_matcher_duration = scan_matcher_stop - scan_matcher_start;
if (sensor_duration.has_value()) { if (sensor_duration.has_value()) {
const double scan_matcher_fraction = const double scan_matcher_fraction =
std::chrono::duration_cast<std::chrono::duration<double>>( common::ToSeconds(scan_matcher_duration) /
scan_matcher_duration)
.count() /
common::ToSeconds(sensor_duration.value()); common::ToSeconds(sensor_duration.value());
kLocalSlamScanMatcherFraction->Set(scan_matcher_fraction); kLocalSlamScanMatcherFraction->Set(scan_matcher_fraction);
} }
@ -301,19 +297,14 @@ LocalTrajectoryBuilder3D::AddAccumulatedRangeData(
const auto insert_into_submap_duration = const auto insert_into_submap_duration =
insert_into_submap_stop - insert_into_submap_start; insert_into_submap_stop - insert_into_submap_start;
if (sensor_duration.has_value()) { if (sensor_duration.has_value()) {
double insert_into_submap_fraction = const double insert_into_submap_fraction =
std::chrono::duration_cast<std::chrono::duration<double>>( common::ToSeconds(insert_into_submap_duration) /
insert_into_submap_duration)
.count() /
common::ToSeconds(sensor_duration.value()); common::ToSeconds(sensor_duration.value());
kLocalSlamInsertIntoSubmapFraction->Set(insert_into_submap_fraction); kLocalSlamInsertIntoSubmapFraction->Set(insert_into_submap_fraction);
} }
const auto accumulation_duration =
const auto duration =
std::chrono::steady_clock::now() - accumulation_started_; std::chrono::steady_clock::now() - accumulation_started_;
kLocalSlamLatencyMetric->Set( kLocalSlamLatencyMetric->Set(common::ToSeconds(accumulation_duration));
std::chrono::duration_cast<std::chrono::duration<double>>(duration)
.count());
return common::make_unique<MatchingResult>(MatchingResult{ return common::make_unique<MatchingResult>(MatchingResult{
time, *pose_estimate, std::move(filtered_range_data_in_local), time, *pose_estimate, std::move(filtered_range_data_in_local),
std::move(insertion_result)}); std::move(insertion_result)});