Use immediately invoked lambda for tracking_to_local. (#848)

Restores const-correctness that we dropped when introducing the 
`publish_frame_projected_to_2d` param without using a ternary operator.
master
Michael Grupp 2018-05-03 21:37:44 +02:00 committed by Wally B. Feed
parent d18365500d
commit 4b60d9cdfe
1 changed files with 7 additions and 5 deletions

View File

@ -217,11 +217,13 @@ void Node::PublishTrajectoryStates(const ::ros::WallTimerEvent& timer_event) {
FromRos(ros::Time::now()), extrapolator.GetLastExtrapolatedTime()); FromRos(ros::Time::now()), extrapolator.GetLastExtrapolatedTime());
stamped_transform.header.stamp = ToRos(now); stamped_transform.header.stamp = ToRos(now);
Rigid3d tracking_to_local = extrapolator.ExtrapolatePose(now); const Rigid3d tracking_to_local = [&] {
if (trajectory_state.trajectory_options.publish_frame_projected_to_2d) { if (trajectory_state.trajectory_options.publish_frame_projected_to_2d) {
tracking_to_local = carto::transform::Embed3D( return carto::transform::Embed3D(
carto::transform::Project2D(tracking_to_local)); carto::transform::Project2D(extrapolator.ExtrapolatePose(now)));
} }
return extrapolator.ExtrapolatePose(now);
}();
const Rigid3d tracking_to_map = const Rigid3d tracking_to_map =
trajectory_state.local_to_map * tracking_to_local; trajectory_state.local_to_map * tracking_to_local;