From 66f6fb79a434e6cf811dcd0d042b7ad61953f721 Mon Sep 17 00:00:00 2001 From: Emilk Roy Sempertegui Aveiga Date: Wed, 7 Apr 2021 14:25:23 +0000 Subject: [PATCH] Merge branch 'fix/grid_map_core_remove_compiler_warnings' into 'master' [grid_map_core] Remove compiler warnings GitOrigin-RevId: 593af35e98d1d24b28f8aaedbc18d96e99f861cf --- .../include/grid_map_core/GridMapMath.hpp | 26 ++++--------------- .../iterators/GridMapIterator.hpp | 6 +++++ grid_map_core/src/CubicInterpolation.cpp | 2 +- grid_map_core/src/GridMapMath.cpp | 23 +++------------- grid_map_core/src/Polygon.cpp | 3 +-- .../src/iterators/PolygonIterator.cpp | 3 +-- .../src/iterators/SpiralIterator.cpp | 5 ++-- 7 files changed, 19 insertions(+), 49 deletions(-) diff --git a/grid_map_core/include/grid_map_core/GridMapMath.hpp b/grid_map_core/include/grid_map_core/GridMapMath.hpp index fe2d5017e..489fd0fe2 100644 --- a/grid_map_core/include/grid_map_core/GridMapMath.hpp +++ b/grid_map_core/include/grid_map_core/GridMapMath.hpp @@ -19,6 +19,11 @@ namespace grid_map { +union Color{ + uint64_t intColor; + float floatColor; +}; + /*! * Gets the position of a cell specified by its index in the map frame. * @param[out] position the position of the center of the cell in the map frame. @@ -311,27 +316,6 @@ Index getIndexFromLinearIndex( const size_t linearIndex, const Size & bufferSize, const bool rowMajor = false); -/*! - * Generates a list of indices for a region in the map. - * @param regionIndex the region top-left index. - * @param regionSize the region size. - * @param indices the list of indices of the region. - */ -void getIndicesForRegion( - const Index & regionIndex, const Size & regionSize, - std::vector indices); - -/*! - * Generates a list of indices for multiple regions in the map. - * This method makes sure every index is only once contained in the list. - * @param regionIndeces the regions' top-left index. - * @param regionSizes the regions' sizes. - * @param indices the list of indices of the regions. - */ -void getIndicesForRegions( - const std::vector & regionIndeces, const Size & regionSizes, - std::vector indices); - /*! * Transforms an int color value (concatenated RGB values) to an int color vector (RGB from 0-255). * @param [in] colorValue the concatenated RGB color value. diff --git a/grid_map_core/include/grid_map_core/iterators/GridMapIterator.hpp b/grid_map_core/include/grid_map_core/iterators/GridMapIterator.hpp index 86a621be4..cedc893f2 100644 --- a/grid_map_core/include/grid_map_core/iterators/GridMapIterator.hpp +++ b/grid_map_core/include/grid_map_core/iterators/GridMapIterator.hpp @@ -33,6 +33,12 @@ class GridMapIterator */ explicit GridMapIterator(const GridMapIterator * other); + /*! + * Copy constructor. + * @param other the object to copy. + */ + GridMapIterator(const GridMapIterator & other) = default; + /*! * Assignment operator. * @param iterator the iterator to copy data from. diff --git a/grid_map_core/src/CubicInterpolation.cpp b/grid_map_core/src/CubicInterpolation.cpp index 456e1f21a..a2a9cf62d 100644 --- a/grid_map_core/src/CubicInterpolation.cpp +++ b/grid_map_core/src/CubicInterpolation.cpp @@ -20,7 +20,7 @@ unsigned int bindIndexToRange(int idReq, unsigned int nElem) if (idReq < 0) { return 0; } - if ((unsigned)idReq >= nElem) { + if (static_cast(idReq) >= nElem) { return static_cast(nElem - 1); } return static_cast(idReq); diff --git a/grid_map_core/src/GridMapMath.cpp b/grid_map_core/src/GridMapMath.cpp index b12162c42..4cf9fb09c 100644 --- a/grid_map_core/src/GridMapMath.cpp +++ b/grid_map_core/src/GridMapMath.cpp @@ -607,23 +607,6 @@ Index getIndexFromLinearIndex( 1), static_cast(linearIndex) % bufferSize(1)); } -// void getIndicesForRegion( -// const Index & regionIndex, const Size & regionSize, -// std::vector indices) -// { -// // for (int i = line.index_; col < line.endIndex(); col++) { -// // for (int i = 0; i < getSize()(0); i++) { -// // -// // } -// // } -// } - -// void getIndicesForRegions( -// const std::vector & regionIndeces, const Size & regionSizes, -// std::vector indices) -// { -// } - bool colorValueToVector(const uint64_t & colorValue, Eigen::Vector3i & colorVector) { colorVector(0) = (colorValue >> 16) & 0x0000ff; @@ -657,9 +640,9 @@ bool colorVectorToValue(const Eigen::Vector3i & colorVector, uint64_t & colorVal void colorVectorToValue(const Eigen::Vector3i & colorVector, float & colorValue) { - uint64_t color = (colorVector(0) << 16) + (colorVector(1) << 8) + colorVector(2); - float * temp = reinterpret_cast(&color); - colorValue = *temp; + Color colors; + colors.intColor = (colorVector(0) << 16) + (colorVector(1) << 8) + colorVector(2); + colorValue = colors.floatColor; } void colorVectorToValue(const Eigen::Vector3f & colorVector, float & colorValue) diff --git a/grid_map_core/src/Polygon.cpp b/grid_map_core/src/Polygon.cpp index fff4f500b..6db2c6378 100644 --- a/grid_map_core/src/Polygon.cpp +++ b/grid_map_core/src/Polygon.cpp @@ -223,11 +223,10 @@ bool Polygon::offsetInward(const double margin) return true; } -std::vector Polygon::triangulate(const TriangulationMethods & method) const +std::vector Polygon::triangulate(const TriangulationMethods & /*method*/) const { // TODO(needs_assignment): Add more triangulation methods. // https://en.wikipedia.org/wiki/Polygon_triangulation - (void)(method); // method parameter unused, should be removed once used. std::vector polygons; if (vertices_.size() < 3) { return polygons; diff --git a/grid_map_core/src/iterators/PolygonIterator.cpp b/grid_map_core/src/iterators/PolygonIterator.cpp index 036562ca9..1a48494a9 100644 --- a/grid_map_core/src/iterators/PolygonIterator.cpp +++ b/grid_map_core/src/iterators/PolygonIterator.cpp @@ -84,10 +84,9 @@ bool PolygonIterator::isInside() const } void PolygonIterator::findSubmapParameters( - const grid_map::Polygon & polygon, Index & startIndex, + const grid_map::Polygon & /*polygon*/, Index & startIndex, Size & bufferSize) const { - (void)(polygon); // polygon parameter unused, should be removed when used. Position topLeft = polygon_.getVertices()[0]; Position bottomRight = topLeft; for (const auto & vertex : polygon_.getVertices()) { diff --git a/grid_map_core/src/iterators/SpiralIterator.cpp b/grid_map_core/src/iterators/SpiralIterator.cpp index 168fb8564..08fe58dc9 100644 --- a/grid_map_core/src/iterators/SpiralIterator.cpp +++ b/grid_map_core/src/iterators/SpiralIterator.cpp @@ -53,9 +53,8 @@ SpiralIterator & SpiralIterator::operator=(const SpiralIterator & other) return *this; } -bool SpiralIterator::operator!=(const SpiralIterator & other) const +bool SpiralIterator::operator!=(const SpiralIterator & /*other*/) const { - (void)(other); // other parameter unused, should be removed when used. return (pointsRing_.back() != pointsRing_.back()).any(); } @@ -119,7 +118,7 @@ void SpiralIterator::generateRing() point.x() += normal.x(); point.y() += normal.y(); } - } while ((unsigned)point.x() != distance_ || point.y() != 0); + } while (static_cast(point.x()) != distance_ || point.y() != 0); } double SpiralIterator::getCurrentRadius() const