Skip to content

Commit

Permalink
Merge branch 'fix/grid_map_core/reduce_even_more_clang_warnings' into…
Browse files Browse the repository at this point in the history
… 'master'

[grid_map_core] removed more clang warnings.

GitOrigin-RevId: 967411d912d34b4714656801373419c765a3afd8
  • Loading branch information
mgaertneratanybotics authored and CI committed Jul 11, 2022
1 parent 52c10ef commit d6f0912
Show file tree
Hide file tree
Showing 42 changed files with 402 additions and 470 deletions.
12 changes: 6 additions & 6 deletions grid_map_core/include/grid_map_core/CubicInterpolation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GridMap;
* necessary for interpolation. These are either 16
* function values in the case of bicubic convolution interpolation
* or function values and their derivatives for the case
* of standard bicubic inteprolation.
* of standard bicubic interpolation.
*/
using FunctionValueMatrix = Eigen::Matrix4d;

Expand Down Expand Up @@ -74,7 +74,7 @@ static const Eigen::Matrix4d cubicInterpolationConvolutionMatrix {
-1.0, 3.0, -3.0, 1.0).finished() };

/*
* Index of the middle knot for bicubic inteprolation. This is
* Index of the middle knot for bicubic interpolation. This is
* the function value with subscripts (0,0), i.e. f00 in
* https://en.wikipedia.org/wiki/Bicubic_interpolation
* In the grid map it corresponds to the grid map point closest to the
Expand All @@ -100,7 +100,7 @@ bool getNormalizedCoordinates(const GridMap &gridMap, const Position &queriedPos
Position *position);

/*
* Queries the grid map for function values at the coordiantes which are neccesary for
* Queries the grid map for function values at the coordinates which are necessary for
* performing the interpolation. The right function values are then assembled
* in a matrix.
* @param[in] gridMap - grid map with the data
Expand All @@ -119,7 +119,7 @@ bool assembleFunctionValueMatrix(const GridMap &gridMap, const std::string &laye
* Performs convolution in 1D. the function requires 4 function values
* to compute the convolution. The result is interpolated data in 1D.
* @param[in] t - normalized coordinate (x or y)
* @param[in] functionValues - vector of 4 function values neccessary to perform
* @param[in] functionValues - vector of 4 function values necessary to perform
* interpolation in 1 dimension.
* @return - interpolated value at normalized coordinate t
*/
Expand Down Expand Up @@ -177,7 +177,7 @@ struct DataMatrix

/*
* Interpolation is performed on a unit square.
* Hence we need to compute 4 corners of that unit square,
* Hence, we need to compute 4 corners of that unit square,
* and find their indices in the grid map. IndicesMatrix
* is a container that stores those indices. Each index
* contains two numbers (row number, column number) in the
Expand Down Expand Up @@ -313,7 +313,7 @@ double mixedSecondOrderDerivativeAt(const Matrix &layerData, const Index &index,
double evaluatePolynomial(const FunctionValueMatrix &functionValues, double tx, double ty);

/*
* Assemble function value matrix from small submatrices containing function values
* Assemble function value matrix from small sub-matrices containing function values
* or derivative values at the corners of the unit square.
* See https://en.wikipedia.org/wiki/Bicubic_interpolation for details.
*
Expand Down
2 changes: 1 addition & 1 deletion grid_map_core/include/grid_map_core/GridMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ class GridMap {
//! Size of the buffer (rows and cols of the data structure).
Size size_;

//! Circular buffer start indeces.
//! Circular buffer start indices.
Index startIndex_;

public:
Expand Down
26 changes: 13 additions & 13 deletions grid_map_core/include/grid_map_core/GridMapMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ namespace grid_map {

union Color
{
unsigned long longColor;
float floatColor;
unsigned long longColor_;
float floatColor_;
};

/*!
Expand Down Expand Up @@ -83,7 +83,7 @@ void getPositionOfDataStructureOrigin(const Position& position,
Position& positionOfOrigin);

/*!
* Computes how many cells/indeces the map is moved based on a position shift in
* Computes how many cells/indices the map is moved based on a position shift in
* the grid map frame. Use this function if you are moving the grid map
* and want to ensure that the cells match before and after.
* @param[out] indexShift the corresponding shift of the indices.
Expand All @@ -100,7 +100,7 @@ bool getIndexShiftFromPositionShift(Index& indexShift,
* if you are moving the grid map and want to ensure that the cells match
* before and after.
* @param[out] positionShift the corresponding shift in position in the grid map frame.
* @param[in] indexShift the desired shift of the indeces.
* @param[in] indexShift the desired shift of the indices.
* @param[in] resolution the resolution of the map.
* @return true if successful.
*/
Expand All @@ -120,7 +120,7 @@ bool checkIfIndexInRange(const Index& index, const Size& bufferSize);
* Bounds an index that runs out of the range of the buffer.
* This means that an index that overflows is stopped at the last valid index.
* This is the 2d version of boundIndexToRange(int&, const int&).
* @param[in/out] index the indeces that will be bounded to the valid region of the buffer.
* @param[in/out] index the indices that will be bounded to the valid region of the buffer.
* @param[in] bufferSize the size of the buffer.
*/
void boundIndexToRange(Index& index, const Size& bufferSize);
Expand All @@ -137,7 +137,7 @@ void boundIndexToRange(int& index, const int& bufferSize);
* Wraps an index that runs out of the range of the buffer back into allowed the region.
* This means that an index that overflows is reset to zero.
* This is the 2d version of wrapIndexToRange(int&, const int&).
* @param[in/out] index the indeces that will be wrapped into the valid region of the buffer.
* @param[in/out] index the indices that will be wrapped into the valid region of the buffer.
* @param[in] bufferSize the size of the buffer.
*/
void wrapIndexToRange(Index& index, const Size& bufferSize);
Expand All @@ -164,7 +164,7 @@ void boundPositionToRange(Position& position, const Length& mapLength, const Pos
* and the map frame (x/y-coordinate).
* @return the alignment transformation.
*/
const Eigen::Matrix2i getBufferOrderToMapFrameAlignment();
Eigen::Matrix2i getBufferOrderToMapFrameAlignment();

/*!
* Given a map and a desired submap (defined by position and size), this function computes
Expand Down Expand Up @@ -204,7 +204,7 @@ bool getSubmapInformation(Index& submapTopLeftIndex,
* @param bottomRightIndex the bottom right index in the map.
* @return buffer size for the submap.
*/
Size getSubmapSizeFromCornerIndeces(const Index& topLeftIndex, const Index& bottomRightIndex,
Size getSubmapSizeFromCornerIndices(const Index& topLeftIndex, const Index& bottomRightIndex,
const Size& bufferSize, const Index& bufferStartIndex);

/*!
Expand All @@ -230,7 +230,7 @@ bool getBufferRegionsForSubmap(std::vector<BufferRegion>& submapBufferRegions,
* @param[in/out] index the index in the map that is incremented (corrected for the circular buffer).
* @param[in] bufferSize the map buffer size.
* @param[in] bufferStartIndex the map buffer start index.
* @return true if successfully incremented indeces, false if end of iteration limits are reached.
* @return true if successfully incremented indices, false if end of iteration limits are reached.
*/
bool incrementIndex(Index& index, const Size& bufferSize,
const Index& bufferStartIndex = Index::Zero());
Expand All @@ -249,7 +249,7 @@ bool incrementIndex(Index& index, const Size& bufferSize,
* @param[in] submapBufferSize the submap buffer size.
* @param[in] bufferSize the map buffer size.
* @param[in] bufferStartIndex the map buffer start index.
* @return true if successfully incremented indeces, false if end of iteration limits are reached.
* @return true if successfully incremented indices, false if end of iteration limits are reached.
*/
bool incrementIndexForSubmap(Index& submapIndex, Index& index, const Index& submapTopLeftIndex,
const Size& submapBufferSize, const Size& bufferSize,
Expand Down Expand Up @@ -284,7 +284,7 @@ Index getBufferIndexFromIndex(const Index& index, const Size& bufferSize, const
* @param[in] (optional) rowMajor if the linear index is generated for row-major format.
* @return the linear 1d index.
*/
size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, const bool rowMajor = false);
size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, bool rowMajor = false);

/*!
* Returns the regular index (2-dim.) corresponding to the linear index (1-dim.) for a given buffer size.
Expand All @@ -293,7 +293,7 @@ size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, const
* @param[in] (optional) rowMajor if the linear index is generated for row-major format.
* @return the regular 2d index.
*/
Index getIndexFromLinearIndex(const size_t linearIndex, const Size& bufferSize, const bool rowMajor = false);
Index getIndexFromLinearIndex(size_t linearIndex, const Size& bufferSize, bool rowMajor = false);

/*!
* Transforms an int color value (concatenated RGB values) to an int color vector (RGB from 0-255).
Expand Down Expand Up @@ -341,4 +341,4 @@ void colorVectorToValue(const Eigen::Vector3i& colorVector, float& colorValue);
*/
void colorVectorToValue(const Eigen::Vector3f& colorVector, float& colorValue);

} // namespace
} // namespace grid_map
33 changes: 14 additions & 19 deletions grid_map_core/include/grid_map_core/Polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ class Polygon
*/
Polygon(std::vector<Position> vertices);

/*!
* Destructor.
*/
virtual ~Polygon();

/*!
* Check if point is inside polygon.
* @param point the point to be checked.
Expand All @@ -60,7 +55,7 @@ class Polygon
* @param index the index of the requested vertex.
* @return the requested vertex.
*/
const Position& getVertex(const size_t index) const;
const Position& getVertex(size_t index) const;

/*!
* Removes all vertices from the polygon.
Expand All @@ -72,7 +67,7 @@ class Polygon
* @param index the index of the requested vertex.
* @return the requested vertex.
*/
const Position& operator [](const size_t index) const;
const Position& operator [](size_t index) const;

/*!
* Returns the vertices of the polygon.
Expand All @@ -90,7 +85,7 @@ class Polygon
* Set the timestamp of the polygon.
* @param timestamp the timestamp to set (in nanoseconds).
*/
void setTimestamp(const uint64_t timestamp);
void setTimestamp(uint64_t timestamp);

/*!
* Get the timestamp of the polygon.
Expand Down Expand Up @@ -156,15 +151,15 @@ class Polygon
* @param margin the margin to offset the polygon by (in [m]).
* @return true if successful, false otherwise.
*/
bool offsetInward(const double margin);
bool offsetInward(double margin);

/*!
* If only two verices are given, this methods generates a
* If only two vertices are given, this methods generates a
* `thickened` line polygon with four vertices.
* @param thickness the desired thickness of the line.
* @return true if successful, false otherwise.
*/
bool thickenLine(const double thickness);
bool thickenLine(double thickness);

/*!
* Return a triangulated version of the polygon.
Expand All @@ -179,8 +174,8 @@ class Polygon
* @param[in] nVertices number of vertices of the approximation polygon. Default = 20.
* @return circle as polygon.
*/
static Polygon fromCircle(const Position center, const double radius,
const int nVertices = 20);
static Polygon fromCircle(Position center, double radius,
int nVertices = 20);

/*!
* Approximates two circles with a convex hull and returns it as polygon.
Expand All @@ -190,10 +185,10 @@ class Polygon
* @param[in] nVertices number of vertices of the approximation polygon. Default = 20.
* @return convex hull of the two circles as polygon.
*/
static Polygon convexHullOfTwoCircles(const Position center1,
const Position center2,
const double radius,
const int nVertices = 20);
static Polygon convexHullOfTwoCircles(Position center1,
Position center2,
double radius,
int nVertices = 20);

/*!
* Computes the convex hull of two polygons and returns it as polygon.
Expand Down Expand Up @@ -237,7 +232,7 @@ class Polygon
static double vectorsMakeClockwiseTurn(const Eigen::Vector2d& pointO,
const Eigen::Vector2d& pointA,
const Eigen::Vector2d& pointB);

// NOLINTBEGIN(misc-non-private-member-variables-in-classes)
//! Frame id of the polygon.
std::string frameId_;

Expand All @@ -246,7 +241,7 @@ class Polygon

//! Vertices of the polygon.
std::vector<Position> vertices_;

// NOLINTEND(misc-non-private-member-variables-in-classes)
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};
Expand Down
2 changes: 1 addition & 1 deletion grid_map_core/include/grid_map_core/SubmapGeometry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SubmapGeometry
SubmapGeometry(const GridMap& gridMap, const Position& position, const Length& length,
bool& isSuccess);

virtual ~SubmapGeometry();
virtual ~SubmapGeometry() = default;

const GridMap& getGridMap() const;
const Length& getLength() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct Clamp
max_(max)
{
}
const Scalar operator()(const Scalar& x) const
Scalar operator()(const Scalar& x) const
{
return x < min_ ? min_ : (x > max_ ? max_ : x);
}
Expand Down
53 changes: 27 additions & 26 deletions grid_map_core/include/grid_map_core/gtest_eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ namespace grid_map {
}

template<typename M1>
void assertFinite(const M1 & A, std::string const & message = "")
void assertFinite(const M1 & A, std::string const & /*message*/ = "")
{
std::cout << ("test") << std::endl;
for(int r = 0; r < A.rows(); r++)
{
for(int c = 0; c < A.cols(); c++)
Expand All @@ -107,58 +108,58 @@ namespace grid_map {
}
}

inline bool compareRelative(double a, double b, double percentTolerance, double * percentError = NULL)
{
// \todo: does anyone have a better idea?
inline bool compareRelative(double a, double b, double percentTolerance, double* percentError = nullptr) {
// \todo: does anyone have a better idea?
double fa = fabs(a);
double fb = fabs(b);
if( (fa < 1e-15 && fb < 1e-15) || // Both zero.
(fa == 0.0 && fb < 1e-6) || // One exactly zero and the other small
(fb == 0.0 && fa < 1e-6) ) // ditto
return true;
if ((fa < 1e-15 && fb < 1e-15) || // Both zero.
(fa == 0.0 && fb < 1e-6) || // One exactly zero and the other small
(fb == 0.0 && fa < 1e-6)) { // ditto
return true;
}

double diff = fabs(a - b)/std::max(fa,fb);
if(diff > percentTolerance * 1e-2)
{
if(percentError)
*percentError = diff * 100.0;
return false;
}
double diff = fabs(a - b) / std::max(fa, fb);
if (diff > percentTolerance * 1e-2) {
if (percentError != nullptr) {
*percentError = diff * 100.0;
}
return false;
}
return true;
}

#define ASSERT_DOUBLE_MX_EQ(A, B, PERCENT_TOLERANCE, MSG) \
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << (MSG) << "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B) << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << (MSG) << "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B) << "\nare not the same size"; \
for(int r = 0; r < (A).rows(); r++) \
{ \
for(int c = 0; c < (A).cols(); c++) \
{ \
double percentError = 0.0; \
ASSERT_TRUE(grid_map::compareRelative( (A)(r,c), (B)(r,c), PERCENT_TOLERANCE, &percentError)) \
<< MSG << "\nComparing:\n" \
<< (MSG) << "\nComparing:\n" \
<< #A << "(" << r << "," << c << ") = " << (A)(r,c) << std::endl \
<< #B << "(" << r << "," << c << ") = " << (B)(r,c) << std::endl \
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
<< "Error was " << percentError << "% > " << (PERCENT_TOLERANCE) << "%\n" \
<< "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B); \
} \
}

#define ASSERT_DOUBLE_SPARSE_MX_EQ(A, B, PERCENT_TOLERANCE, MSG) \
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << MSG << "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).rows(), (size_t)(B).rows()) << (MSG) << "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B) << "\nare not the same size"; \
ASSERT_EQ((size_t)(A).cols(), (size_t)(B).cols()) << (MSG) << "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B) << "\nare not the same size"; \
for(int r = 0; r < (A).rows(); r++) \
{ \
for(int c = 0; c < (A).cols(); c++) \
{ \
double percentError = 0.0; \
ASSERT_TRUE(grid_map::compareRelative( (A).coeff(r,c), (B).coeff(r,c), PERCENT_TOLERANCE, &percentError)) \
<< MSG << "\nComparing:\n" \
<< (MSG) << "\nComparing:\n" \
<< #A << "(" << r << "," << c << ") = " << (A).coeff(r,c) << std::endl \
<< #B << "(" << r << "," << c << ") = " << (B).coeff(r,c) << std::endl \
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
<< "Error was " << percentError << "% > " << (PERCENT_TOLERANCE) << "%\n" \
<< "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B); \
} \
}

} // namespace
} // namespace grid_map
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ class CircleIterator
*/
CircleIterator(const GridMap& gridMap, const Position& center, double radius);

/*!
* Assignment operator.
* @param iterator the iterator to copy data from.
* @return a reference to *this.
*/
CircleIterator& operator =(const CircleIterator& other) = default;

/*!
* Compare to another iterator.
* @return whether the current iterator points to a different address than the other one.
Expand Down
Loading

0 comments on commit d6f0912

Please sign in to comment.