Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROS 2][grid_map_core] Code enhancements from master 6ddff74 #503

Open
wants to merge 2 commits into
base: rolling
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions grid_map_core/include/grid_map_core/GridMapMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<Index> 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<Index> & regionIndeces, const Size & regionSizes,
std::vector<Index> 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.
Expand Down
2 changes: 1 addition & 1 deletion grid_map_core/src/CubicInterpolation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ unsigned int bindIndexToRange(int idReq, unsigned int nElem)
if (idReq < 0) {
return 0;
}
if ((unsigned)idReq >= nElem) {
if (static_cast<unsigned int>(idReq) >= nElem) {
return static_cast<unsigned int>(nElem - 1);
}
return static_cast<unsigned int>(idReq);
Expand Down
23 changes: 3 additions & 20 deletions grid_map_core/src/GridMapMath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,23 +607,6 @@ Index getIndexFromLinearIndex(
1), static_cast<int>(linearIndex) % bufferSize(1));
}

// void getIndicesForRegion(
// const Index & regionIndex, const Size & regionSize,
// std::vector<Index> indices)
// {
// // for (int i = line.index_; col < line.endIndex(); col++) {
// // for (int i = 0; i < getSize()(0); i++) {
// //
// // }
// // }
// }

// void getIndicesForRegions(
// const std::vector<Index> & regionIndeces, const Size & regionSizes,
// std::vector<Index> indices)
// {
// }

bool colorValueToVector(const uint64_t & colorValue, Eigen::Vector3i & colorVector)
{
colorVector(0) = (colorValue >> 16) & 0x0000ff;
Expand Down Expand Up @@ -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<float *>(&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)
Expand Down
3 changes: 1 addition & 2 deletions grid_map_core/src/Polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ bool Polygon::offsetInward(const double margin)
return true;
}

std::vector<Polygon> Polygon::triangulate(const TriangulationMethods & method) const
std::vector<Polygon> 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<Polygon> polygons;
if (vertices_.size() < 3) {
return polygons;
Expand Down
3 changes: 1 addition & 2 deletions grid_map_core/src/iterators/PolygonIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
5 changes: 2 additions & 3 deletions grid_map_core/src/iterators/SpiralIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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<unsigned int>(point.x()) != distance_ || point.y() != 0);
}

double SpiralIterator::getCurrentRadius() const
Expand Down
Loading