Skip to content

Commit d6f0912

Browse files
mgaertneratanyboticsCI
authored andcommitted
Merge branch 'fix/grid_map_core/reduce_even_more_clang_warnings' into 'master'
[grid_map_core] removed more clang warnings. GitOrigin-RevId: 967411d912d34b4714656801373419c765a3afd8
1 parent 52c10ef commit d6f0912

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+402
-470
lines changed

grid_map_core/include/grid_map_core/CubicInterpolation.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class GridMap;
3535
* necessary for interpolation. These are either 16
3636
* function values in the case of bicubic convolution interpolation
3737
* or function values and their derivatives for the case
38-
* of standard bicubic inteprolation.
38+
* of standard bicubic interpolation.
3939
*/
4040
using FunctionValueMatrix = Eigen::Matrix4d;
4141

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

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

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

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

315315
/*
316-
* Assemble function value matrix from small submatrices containing function values
316+
* Assemble function value matrix from small sub-matrices containing function values
317317
* or derivative values at the corners of the unit square.
318318
* See https://en.wikipedia.org/wiki/Bicubic_interpolation for details.
319319
*

grid_map_core/include/grid_map_core/GridMap.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class GridMap {
578578
//! Size of the buffer (rows and cols of the data structure).
579579
Size size_;
580580

581-
//! Circular buffer start indeces.
581+
//! Circular buffer start indices.
582582
Index startIndex_;
583583

584584
public:

grid_map_core/include/grid_map_core/GridMapMath.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ namespace grid_map {
1919

2020
union Color
2121
{
22-
unsigned long longColor;
23-
float floatColor;
22+
unsigned long longColor_;
23+
float floatColor_;
2424
};
2525

2626
/*!
@@ -83,7 +83,7 @@ void getPositionOfDataStructureOrigin(const Position& position,
8383
Position& positionOfOrigin);
8484

8585
/*!
86-
* Computes how many cells/indeces the map is moved based on a position shift in
86+
* Computes how many cells/indices the map is moved based on a position shift in
8787
* the grid map frame. Use this function if you are moving the grid map
8888
* and want to ensure that the cells match before and after.
8989
* @param[out] indexShift the corresponding shift of the indices.
@@ -100,7 +100,7 @@ bool getIndexShiftFromPositionShift(Index& indexShift,
100100
* if you are moving the grid map and want to ensure that the cells match
101101
* before and after.
102102
* @param[out] positionShift the corresponding shift in position in the grid map frame.
103-
* @param[in] indexShift the desired shift of the indeces.
103+
* @param[in] indexShift the desired shift of the indices.
104104
* @param[in] resolution the resolution of the map.
105105
* @return true if successful.
106106
*/
@@ -120,7 +120,7 @@ bool checkIfIndexInRange(const Index& index, const Size& bufferSize);
120120
* Bounds an index that runs out of the range of the buffer.
121121
* This means that an index that overflows is stopped at the last valid index.
122122
* This is the 2d version of boundIndexToRange(int&, const int&).
123-
* @param[in/out] index the indeces that will be bounded to the valid region of the buffer.
123+
* @param[in/out] index the indices that will be bounded to the valid region of the buffer.
124124
* @param[in] bufferSize the size of the buffer.
125125
*/
126126
void boundIndexToRange(Index& index, const Size& bufferSize);
@@ -137,7 +137,7 @@ void boundIndexToRange(int& index, const int& bufferSize);
137137
* Wraps an index that runs out of the range of the buffer back into allowed the region.
138138
* This means that an index that overflows is reset to zero.
139139
* This is the 2d version of wrapIndexToRange(int&, const int&).
140-
* @param[in/out] index the indeces that will be wrapped into the valid region of the buffer.
140+
* @param[in/out] index the indices that will be wrapped into the valid region of the buffer.
141141
* @param[in] bufferSize the size of the buffer.
142142
*/
143143
void wrapIndexToRange(Index& index, const Size& bufferSize);
@@ -164,7 +164,7 @@ void boundPositionToRange(Position& position, const Length& mapLength, const Pos
164164
* and the map frame (x/y-coordinate).
165165
* @return the alignment transformation.
166166
*/
167-
const Eigen::Matrix2i getBufferOrderToMapFrameAlignment();
167+
Eigen::Matrix2i getBufferOrderToMapFrameAlignment();
168168

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

210210
/*!
@@ -230,7 +230,7 @@ bool getBufferRegionsForSubmap(std::vector<BufferRegion>& submapBufferRegions,
230230
* @param[in/out] index the index in the map that is incremented (corrected for the circular buffer).
231231
* @param[in] bufferSize the map buffer size.
232232
* @param[in] bufferStartIndex the map buffer start index.
233-
* @return true if successfully incremented indeces, false if end of iteration limits are reached.
233+
* @return true if successfully incremented indices, false if end of iteration limits are reached.
234234
*/
235235
bool incrementIndex(Index& index, const Size& bufferSize,
236236
const Index& bufferStartIndex = Index::Zero());
@@ -249,7 +249,7 @@ bool incrementIndex(Index& index, const Size& bufferSize,
249249
* @param[in] submapBufferSize the submap buffer size.
250250
* @param[in] bufferSize the map buffer size.
251251
* @param[in] bufferStartIndex the map buffer start index.
252-
* @return true if successfully incremented indeces, false if end of iteration limits are reached.
252+
* @return true if successfully incremented indices, false if end of iteration limits are reached.
253253
*/
254254
bool incrementIndexForSubmap(Index& submapIndex, Index& index, const Index& submapTopLeftIndex,
255255
const Size& submapBufferSize, const Size& bufferSize,
@@ -284,7 +284,7 @@ Index getBufferIndexFromIndex(const Index& index, const Size& bufferSize, const
284284
* @param[in] (optional) rowMajor if the linear index is generated for row-major format.
285285
* @return the linear 1d index.
286286
*/
287-
size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, const bool rowMajor = false);
287+
size_t getLinearIndexFromIndex(const Index& index, const Size& bufferSize, bool rowMajor = false);
288288

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

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

344-
} // namespace
344+
} // namespace grid_map

grid_map_core/include/grid_map_core/Polygon.hpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ class Polygon
3737
*/
3838
Polygon(std::vector<Position> vertices);
3939

40-
/*!
41-
* Destructor.
42-
*/
43-
virtual ~Polygon();
44-
4540
/*!
4641
* Check if point is inside polygon.
4742
* @param point the point to be checked.
@@ -60,7 +55,7 @@ class Polygon
6055
* @param index the index of the requested vertex.
6156
* @return the requested vertex.
6257
*/
63-
const Position& getVertex(const size_t index) const;
58+
const Position& getVertex(size_t index) const;
6459

6560
/*!
6661
* Removes all vertices from the polygon.
@@ -72,7 +67,7 @@ class Polygon
7267
* @param index the index of the requested vertex.
7368
* @return the requested vertex.
7469
*/
75-
const Position& operator [](const size_t index) const;
70+
const Position& operator [](size_t index) const;
7671

7772
/*!
7873
* Returns the vertices of the polygon.
@@ -90,7 +85,7 @@ class Polygon
9085
* Set the timestamp of the polygon.
9186
* @param timestamp the timestamp to set (in nanoseconds).
9287
*/
93-
void setTimestamp(const uint64_t timestamp);
88+
void setTimestamp(uint64_t timestamp);
9489

9590
/*!
9691
* Get the timestamp of the polygon.
@@ -156,15 +151,15 @@ class Polygon
156151
* @param margin the margin to offset the polygon by (in [m]).
157152
* @return true if successful, false otherwise.
158153
*/
159-
bool offsetInward(const double margin);
154+
bool offsetInward(double margin);
160155

161156
/*!
162-
* If only two verices are given, this methods generates a
157+
* If only two vertices are given, this methods generates a
163158
* `thickened` line polygon with four vertices.
164159
* @param thickness the desired thickness of the line.
165160
* @return true if successful, false otherwise.
166161
*/
167-
bool thickenLine(const double thickness);
162+
bool thickenLine(double thickness);
168163

169164
/*!
170165
* Return a triangulated version of the polygon.
@@ -179,8 +174,8 @@ class Polygon
179174
* @param[in] nVertices number of vertices of the approximation polygon. Default = 20.
180175
* @return circle as polygon.
181176
*/
182-
static Polygon fromCircle(const Position center, const double radius,
183-
const int nVertices = 20);
177+
static Polygon fromCircle(Position center, double radius,
178+
int nVertices = 20);
184179

185180
/*!
186181
* Approximates two circles with a convex hull and returns it as polygon.
@@ -190,10 +185,10 @@ class Polygon
190185
* @param[in] nVertices number of vertices of the approximation polygon. Default = 20.
191186
* @return convex hull of the two circles as polygon.
192187
*/
193-
static Polygon convexHullOfTwoCircles(const Position center1,
194-
const Position center2,
195-
const double radius,
196-
const int nVertices = 20);
188+
static Polygon convexHullOfTwoCircles(Position center1,
189+
Position center2,
190+
double radius,
191+
int nVertices = 20);
197192

198193
/*!
199194
* Computes the convex hull of two polygons and returns it as polygon.
@@ -237,7 +232,7 @@ class Polygon
237232
static double vectorsMakeClockwiseTurn(const Eigen::Vector2d& pointO,
238233
const Eigen::Vector2d& pointA,
239234
const Eigen::Vector2d& pointB);
240-
235+
// NOLINTBEGIN(misc-non-private-member-variables-in-classes)
241236
//! Frame id of the polygon.
242237
std::string frameId_;
243238

@@ -246,7 +241,7 @@ class Polygon
246241

247242
//! Vertices of the polygon.
248243
std::vector<Position> vertices_;
249-
244+
// NOLINTEND(misc-non-private-member-variables-in-classes)
250245
public:
251246
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
252247
};

grid_map_core/include/grid_map_core/SubmapGeometry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SubmapGeometry
3535
SubmapGeometry(const GridMap& gridMap, const Position& position, const Length& length,
3636
bool& isSuccess);
3737

38-
virtual ~SubmapGeometry();
38+
virtual ~SubmapGeometry() = default;
3939

4040
const GridMap& getGridMap() const;
4141
const Length& getLength() const;

grid_map_core/include/grid_map_core/eigen_plugins/Functors.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct Clamp
1818
max_(max)
1919
{
2020
}
21-
const Scalar operator()(const Scalar& x) const
21+
Scalar operator()(const Scalar& x) const
2222
{
2323
return x < min_ ? min_ : (x > max_ ? max_ : x);
2424
}

grid_map_core/include/grid_map_core/gtest_eigen.hpp

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ namespace grid_map {
9696
}
9797

9898
template<typename M1>
99-
void assertFinite(const M1 & A, std::string const & message = "")
99+
void assertFinite(const M1 & A, std::string const & /*message*/ = "")
100100
{
101+
std::cout << ("test") << std::endl;
101102
for(int r = 0; r < A.rows(); r++)
102103
{
103104
for(int c = 0; c < A.cols(); c++)
@@ -107,58 +108,58 @@ namespace grid_map {
107108
}
108109
}
109110

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

120-
double diff = fabs(a - b)/std::max(fa,fb);
121-
if(diff > percentTolerance * 1e-2)
122-
{
123-
if(percentError)
124-
*percentError = diff * 100.0;
125-
return false;
126-
}
121+
double diff = fabs(a - b) / std::max(fa, fb);
122+
if (diff > percentTolerance * 1e-2) {
123+
if (percentError != nullptr) {
124+
*percentError = diff * 100.0;
125+
}
126+
return false;
127+
}
127128
return true;
128129
}
129130

130131
#define ASSERT_DOUBLE_MX_EQ(A, B, PERCENT_TOLERANCE, MSG) \
131-
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"; \
132-
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"; \
132+
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"; \
133+
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"; \
133134
for(int r = 0; r < (A).rows(); r++) \
134135
{ \
135136
for(int c = 0; c < (A).cols(); c++) \
136137
{ \
137138
double percentError = 0.0; \
138139
ASSERT_TRUE(grid_map::compareRelative( (A)(r,c), (B)(r,c), PERCENT_TOLERANCE, &percentError)) \
139-
<< MSG << "\nComparing:\n" \
140+
<< (MSG) << "\nComparing:\n" \
140141
<< #A << "(" << r << "," << c << ") = " << (A)(r,c) << std::endl \
141142
<< #B << "(" << r << "," << c << ") = " << (B)(r,c) << std::endl \
142-
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
143-
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
143+
<< "Error was " << percentError << "% > " << (PERCENT_TOLERANCE) << "%\n" \
144+
<< "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B); \
144145
} \
145146
}
146147

147148
#define ASSERT_DOUBLE_SPARSE_MX_EQ(A, B, PERCENT_TOLERANCE, MSG) \
148-
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"; \
149-
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"; \
149+
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"; \
150+
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"; \
150151
for(int r = 0; r < (A).rows(); r++) \
151152
{ \
152153
for(int c = 0; c < (A).cols(); c++) \
153154
{ \
154155
double percentError = 0.0; \
155156
ASSERT_TRUE(grid_map::compareRelative( (A).coeff(r,c), (B).coeff(r,c), PERCENT_TOLERANCE, &percentError)) \
156-
<< MSG << "\nComparing:\n" \
157+
<< (MSG) << "\nComparing:\n" \
157158
<< #A << "(" << r << "," << c << ") = " << (A).coeff(r,c) << std::endl \
158159
<< #B << "(" << r << "," << c << ") = " << (B).coeff(r,c) << std::endl \
159-
<< "Error was " << percentError << "% > " << PERCENT_TOLERANCE << "%\n" \
160-
<< "\nMatrix " << #A << ":\n" << A << "\nand matrix " << #B << "\n" << B; \
160+
<< "Error was " << percentError << "% > " << (PERCENT_TOLERANCE) << "%\n" \
161+
<< "\nMatrix " << #A << ":\n" << (A) << "\nand matrix " << #B << "\n" << (B); \
161162
} \
162163
}
163164

164-
} // namespace
165+
} // namespace grid_map

grid_map_core/include/grid_map_core/iterators/CircleIterator.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ class CircleIterator
3232
*/
3333
CircleIterator(const GridMap& gridMap, const Position& center, double radius);
3434

35-
/*!
36-
* Assignment operator.
37-
* @param iterator the iterator to copy data from.
38-
* @return a reference to *this.
39-
*/
40-
CircleIterator& operator =(const CircleIterator& other) = default;
41-
4235
/*!
4336
* Compare to another iterator.
4437
* @return whether the current iterator points to a different address than the other one.

0 commit comments

Comments
 (0)