Avoid auto for Eigen expressiongs. (#719)

While harmless in most cases, auto can delay evaluation
of expressions in unexpected ways.
So it is better to avoid auto for Eigen expressions.
https://eigen.tuxfamily.org/dox/TopicPitfalls.html
master
gaschler 2018-02-19 14:40:13 +01:00 committed by Wally B. Feed
parent a2a587b3cb
commit fb947f5c7e
3 changed files with 4 additions and 4 deletions

View File

@ -133,7 +133,7 @@ LaserScanToPointCloudWithIntensities(const LaserMessageType& msg) {
if (!point_cloud.points.empty()) { if (!point_cloud.points.empty()) {
const double duration = point_cloud.points.back()[3]; const double duration = point_cloud.points.back()[3];
timestamp += cartographer::common::FromSeconds(duration); timestamp += cartographer::common::FromSeconds(duration);
for (auto& point : point_cloud.points) { for (Eigen::Vector4f& point : point_cloud.points) {
point[3] -= duration; point[3] -= duration;
} }
} }
@ -157,7 +157,7 @@ sensor_msgs::PointCloud2 ToPointCloud2Message(
const ::cartographer::sensor::TimedPointCloud& point_cloud) { const ::cartographer::sensor::TimedPointCloud& point_cloud) {
auto msg = PreparePointCloud2Message(timestamp, frame_id, point_cloud.size()); auto msg = PreparePointCloud2Message(timestamp, frame_id, point_cloud.size());
::ros::serialization::OStream stream(msg.data.data(), msg.data.size()); ::ros::serialization::OStream stream(msg.data.data(), msg.data.size());
for (const auto& point : point_cloud) { for (const Eigen::Vector4f& point : point_cloud) {
stream.next(point.x()); stream.next(point.x());
stream.next(point.y()); stream.next(point.y());
stream.next(point.z()); stream.next(point.z());

View File

@ -177,7 +177,7 @@ class RangeDataChecker {
const cartographer::sensor::TimedPointCloud& point_cloud = const cartographer::sensor::TimedPointCloud& point_cloud =
std::get<0>(point_cloud_with_intensities).points; std::get<0>(point_cloud_with_intensities).points;
Eigen::Vector4f points_sum = Eigen::Vector4f::Zero(); Eigen::Vector4f points_sum = Eigen::Vector4f::Zero();
for (const auto& point : point_cloud) { for (const Eigen::Vector4f& point : point_cloud) {
points_sum += point; points_sum += point;
} }
return {point_cloud.size(), points_sum}; return {point_cloud.size(), points_sum};

View File

@ -192,7 +192,7 @@ void SensorBridge::HandleLaserScan(
// send all other sensor data first. // send all other sensor data first.
const carto::common::Time subdivision_time = const carto::common::Time subdivision_time =
time + carto::common::FromSeconds(time_to_subdivision_end); time + carto::common::FromSeconds(time_to_subdivision_end);
for (auto& point : subdivision) { for (Eigen::Vector4f& point : subdivision) {
point[3] -= time_to_subdivision_end; point[3] -= time_to_subdivision_end;
} }
CHECK_EQ(subdivision.back()[3], 0); CHECK_EQ(subdivision.back()[3], 0);