From 71bb6ec3fb5828bd024fbc98b8b34b4f63dd43a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mart=C3=ADn=20Rico?= Date: Sat, 10 Oct 2026 08:09:01 +0200 Subject: [PATCH] Enable cpplint and copyright linters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the lines that disabled ament_cmake_cpplint and ament_cmake_copyright, and fix what they report: header guards, include order, missing includes, using-directives in tests, C types and casts, comment spacing, and two remaining GPL headers moved to the Apache header of the rest of the project. Humble's ament_copyright does not recognize the license when the header has the EasyNav line, so copyright is skipped only there. Fixes #26 Signed-off-by: Francisco Martín Rico --- navmap_core/CMakeLists.txt | 6 ++- navmap_core/include/navmap_core/Geometry.hpp | 7 +-- navmap_core/include/navmap_core/NavMap.hpp | 36 ++++++------- navmap_core/src/navmap_core/NavMap.cpp | 4 +- navmap_core/tests/test_geometry.cpp | 6 ++- navmap_core/tests/test_locate_grid.cpp | 6 ++- navmap_core/tests/test_navmap.cpp | 6 ++- navmap_core/tests/test_navmap_assign.cpp | 37 ++++++------- navmap_core/tests/test_navmap_easy.cpp | 4 +- .../tests/test_navmap_uniform_and_closest.cpp | 4 +- navmap_core/tests/test_raycast_many.cpp | 4 +- navmap_examples/CMakeLists.txt | 6 ++- .../launch/navmap_to_occgrid.launch.py | 15 ++++++ navmap_examples/src/01_flat_plane.cpp | 4 +- navmap_examples/src/02_two_floors.cpp | 2 +- navmap_examples/src/03_slope_surface.cpp | 2 +- navmap_examples/src/04_layers.cpp | 4 +- .../src/05_neighbors_and_centroids.cpp | 4 +- navmap_examples/src/06_area_marking.cpp | 4 +- navmap_examples/src/07_raycast.cpp | 2 +- navmap_examples/src/08_copy_and_assign.cpp | 4 +- navmap_examples/src_ros2/03_save_load.cpp | 7 +-- navmap_ros/CMakeLists.txt | 6 ++- navmap_ros/include/navmap_ros/conversions.hpp | 7 ++- navmap_ros/src/navmap_ros/conversions.cpp | 8 +-- navmap_ros/src/navmap_ros/navmap_io.cpp | 14 +++-- navmap_ros/src/slam_server_app.cpp | 2 +- navmap_ros/tests/test_conversions.cpp | 12 ++--- navmap_ros/tests/test_navmap_io.cpp | 54 +++++++++---------- navmap_rviz_plugin/CMakeLists.txt | 6 ++- .../navmap_rviz_plugin/NavMapDisplay.hpp | 43 +++++++-------- .../src/navmap_rviz_plugin/NavMapDisplay.cpp | 31 +++++------ .../navmap_rviz_plugin/navmap_pose_tool.cpp | 16 +++--- navmap_tools/CMakeLists.txt | 6 ++- navmap_tools/src/pointcloud_to_navmap.cpp | 7 ++- 35 files changed, 199 insertions(+), 187 deletions(-) diff --git a/navmap_core/CMakeLists.txt b/navmap_core/CMakeLists.txt index fea7aa5..c5067b8 100644 --- a/navmap_core/CMakeLists.txt +++ b/navmap_core/CMakeLists.txt @@ -38,8 +38,10 @@ install(TARGETS if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) - set(ament_cmake_copyright_FOUND TRUE) - set(ament_cmake_cpplint_FOUND TRUE) + # Humble's ament_copyright does not recognize the license with the EasyNav line in the header + if("$ENV{ROS_DISTRO}" STREQUAL "humble") + list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright) + endif() ament_lint_auto_find_test_dependencies() find_package(ament_cmake_gtest REQUIRED) diff --git a/navmap_core/include/navmap_core/Geometry.hpp b/navmap_core/include/navmap_core/Geometry.hpp index 8ffa1d7..f97367a 100644 --- a/navmap_core/include/navmap_core/Geometry.hpp +++ b/navmap_core/include/navmap_core/Geometry.hpp @@ -26,14 +26,15 @@ * - Closest point on triangle and point–triangle distance. */ -#ifndef NAVMAP_CORE__GEOMETRY_HPP -#define NAVMAP_CORE__GEOMETRY_HPP +#ifndef NAVMAP_CORE__GEOMETRY_HPP_ +#define NAVMAP_CORE__GEOMETRY_HPP_ #include #include #include #include #include +#include namespace navmap { @@ -376,4 +377,4 @@ inline float point_triangle_squared_distance( } // namespace navmap -#endif // NAVMAP_CORE__GEOMETRY_HPP +#endif // NAVMAP_CORE__GEOMETRY_HPP_ diff --git a/navmap_core/include/navmap_core/NavMap.hpp b/navmap_core/include/navmap_core/NavMap.hpp index cb837a8..340ce1d 100644 --- a/navmap_core/include/navmap_core/NavMap.hpp +++ b/navmap_core/include/navmap_core/NavMap.hpp @@ -1,25 +1,20 @@ // Copyright 2025 Intelligent Robotics Lab // // This file is part of the project Easy Navigation (EasyNav in short) -// licensed under the GNU General Public License v3.0. -// See for details. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Easy Navigation program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3.0, or -// (at your option) any later version. +// http://www.apache.org/licenses/LICENSE-2.0 // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. -#ifndef NAVMAP_CORE__NAVMAP_HPP -#define NAVMAP_CORE__NAVMAP_HPP +#ifndef NAVMAP_CORE__NAVMAP_HPP_ +#define NAVMAP_CORE__NAVMAP_HPP_ /** * \file @@ -50,8 +45,9 @@ #include #include #include +#include -#include +#include "Eigen/Core" #include "navmap_core/Geometry.hpp" namespace navmap @@ -881,7 +877,7 @@ class NavMap auto src_base = layers.get(src); auto src_view = std::dynamic_pointer_cast>(src_base); if (!src_view) { - return false; // source layer missing or wrong type + return false; // source layer missing or wrong type } // Ensure destination exists with correct length (navcels.size()) @@ -906,7 +902,7 @@ class NavMap // Hash-based skip: O(1) if cached, O(n) only on first compute (then cached) const bool same_hash = (src_view->content_hash() == dst_view->content_hash()); if (same_hash) { - return true; // identical content → avoid copy + return true; // identical content → avoid copy } // Copy only when different. set_data() marks hash as dirty for dst. @@ -1193,4 +1189,4 @@ inline bool NavMap::locate_navcel( } // namespace navmap -#endif // NAVMAP_CORE__NAVMAP_HPP +#endif // NAVMAP_CORE__NAVMAP_HPP_ diff --git a/navmap_core/src/navmap_core/NavMap.cpp b/navmap_core/src/navmap_core/NavMap.cpp index a4b80fb..b18b331 100644 --- a/navmap_core/src/navmap_core/NavMap.cpp +++ b/navmap_core/src/navmap_core/NavMap.cpp @@ -42,7 +42,7 @@ inline std::uint64_t fnv1a64( } return h; } -} // namespace +} // namespace NavMap::NavMap() { @@ -696,7 +696,7 @@ bool NavMap::locate_navcel_core( const Vec3 c = positions.at(tri.v[2]); Vec3 bary_tmp; if (!point_in_triangle_bary(h.p, a, b, c, bary_tmp, opts.planar_eps)) { - continue; // numerical guard + continue; // numerical guard } if (dz < best_dz) { best_dz = dz; diff --git a/navmap_core/tests/test_geometry.cpp b/navmap_core/tests/test_geometry.cpp index 492a435..82a5148 100644 --- a/navmap_core/tests/test_geometry.cpp +++ b/navmap_core/tests/test_geometry.cpp @@ -17,7 +17,11 @@ #include #include "navmap_core/Geometry.hpp" -using namespace navmap; +using navmap::AABB; +using navmap::Vec3; +using navmap::ray_triangle_intersect; +using navmap::triangle_area; +using navmap::triangle_normal; static constexpr float kEps = 1e-6f; diff --git a/navmap_core/tests/test_locate_grid.cpp b/navmap_core/tests/test_locate_grid.cpp index e0a9fa1..cb1e00f 100644 --- a/navmap_core/tests/test_locate_grid.cpp +++ b/navmap_core/tests/test_locate_grid.cpp @@ -16,7 +16,9 @@ #include #include "navmap_core/NavMap.hpp" -using namespace navmap; +using navmap::NavCelId; +using navmap::NavMap; +using navmap::Surface; TEST(NavMap_LocateGrid, MultiFloorsChoosesClosestByDz) { @@ -46,6 +48,6 @@ TEST(NavMap_LocateGrid, MultiFloorsChoosesClosestByDz) size_t sidx; NavCelId cid; Eigen::Vector3f bary; Eigen::Vector3f hit; bool ok = nm.locate_navcel(p, sidx, cid, bary, &hit); ASSERT_TRUE(ok); - EXPECT_EQ(sidx, 1u); // should pick upper floor + EXPECT_EQ(sidx, 1u); // should pick upper floor EXPECT_NEAR(hit.z(), 3.0f, 1e-6); } diff --git a/navmap_core/tests/test_navmap.cpp b/navmap_core/tests/test_navmap.cpp index 669a713..a98bea3 100644 --- a/navmap_core/tests/test_navmap.cpp +++ b/navmap_core/tests/test_navmap.cpp @@ -23,7 +23,11 @@ #include "navmap_core/NavMap.hpp" -using namespace navmap; +using navmap::LayerType; +using navmap::LayerView; +using navmap::NavCelId; +using navmap::NavMap; +using navmap::PointId; namespace { diff --git a/navmap_core/tests/test_navmap_assign.cpp b/navmap_core/tests/test_navmap_assign.cpp index 02d33fe..e766e21 100644 --- a/navmap_core/tests/test_navmap_assign.cpp +++ b/navmap_core/tests/test_navmap_assign.cpp @@ -1,22 +1,17 @@ // Copyright 2025 Intelligent Robotics Lab // // This file is part of the project Easy Navigation (EasyNav in short) -// licensed under the GNU General Public License v3.0. -// See for details. +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at // -// Easy Navigation program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3.0, or -// (at your option) any later version. +// http://www.apache.org/licenses/LICENSE-2.0 // -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #include #include @@ -25,7 +20,9 @@ #include "navmap_core/NavMap.hpp" -using namespace navmap; +using navmap::LayerView; +using navmap::NavMap; +using navmap::layer_type_tag; namespace { @@ -44,7 +41,7 @@ void fill_one_tri_map(NavMap & m) auto occ = m.layers.add_or_get("occ", 1, layer_type_tag()); auto & v = occ->mutable_data(); v.resize(1); - v[0] = 254; // occupied (black) + v[0] = 254; // occupied (black) m.layer_meta["occ"].description = "occupancy"; m.layer_meta["occ"].unit = ""; m.layer_meta["occ"].per_cell = true; @@ -69,7 +66,7 @@ void fill_one_tri_map_variant(NavMap & m) if (auto occ = std::dynamic_pointer_cast>(m.layers.get("occ"))) { auto & v = occ->mutable_data(); - v[0] = 0; // free (white) + v[0] = 0; // free (white) } if (auto cost = std::dynamic_pointer_cast>(m.layers.get("cost"))) { auto & v = cost->mutable_data(); @@ -88,12 +85,12 @@ void fill_one_tri_map_variant(NavMap & m) } } -} // namespace +} // namespace TEST(NavMapAssign, CopiesOnlyLayersWhenGeometryEqualAndRemovesExtras) { NavMap src; fill_one_tri_map(src); - NavMap dst; fill_one_tri_map_variant(dst); // has extra layer and different values + NavMap dst; fill_one_tri_map_variant(dst); // has extra layer and different values // Keep destination geometry pointers to verify geometry is not rebuilt const float * px = dst.positions.x.data(); @@ -206,7 +203,7 @@ TEST(NavMapAssign, HashSkipsCopyWhenLayerIdentical) auto occ_dst_after = std::dynamic_pointer_cast>(dst.layers.get("occ")); ASSERT_TRUE(occ_dst_after); const uint8_t * occ_ptr_after = occ_dst_after->data().data(); - EXPECT_EQ(occ_ptr_before, occ_ptr_after); // same backing storage + EXPECT_EQ(occ_ptr_before, occ_ptr_after); // same backing storage // Content must still be equal auto occ_src = std::dynamic_pointer_cast>(src.layers.get("occ")); diff --git a/navmap_core/tests/test_navmap_easy.cpp b/navmap_core/tests/test_navmap_easy.cpp index 1d7c805..5173030 100644 --- a/navmap_core/tests/test_navmap_easy.cpp +++ b/navmap_core/tests/test_navmap_easy.cpp @@ -226,7 +226,7 @@ TEST(NavMap_EasyAPI, AddSurfaceMoveOverload) Surface s = nm.create_surface_obj("map"); s.navcels.clear(); std::size_t idx1 = nm.add_surface(s); // by copy - std::size_t idx2 = nm.add_surface(std::move(s)); // by move + std::size_t idx2 = nm.add_surface(std::move(s)); // by move EXPECT_EQ(idx1, 0u); EXPECT_EQ(idx2, 1u); EXPECT_EQ(nm.surfaces.size(), 2u); @@ -363,7 +363,7 @@ TEST(NavMap_SetArea, TypeMismatchReturnsFalseAndDoesNotModifyData) static void make_grid(NavMap & nm, int nx, int ny, float z = 0.0f) { // Build a [0,1]x[0,1] plane subdivided in nx*ny quads, 2 triangles per quad - nm.create_surface("map"); // index 0 + nm.create_surface("map"); // index 0 auto addv = [&](float x, float y) { return nm.add_vertex(Eigen::Vector3f(x, y, z)); }; diff --git a/navmap_core/tests/test_navmap_uniform_and_closest.cpp b/navmap_core/tests/test_navmap_uniform_and_closest.cpp index 9e49c29..20c1ece 100644 --- a/navmap_core/tests/test_navmap_uniform_and_closest.cpp +++ b/navmap_core/tests/test_navmap_uniform_and_closest.cpp @@ -17,7 +17,9 @@ #include #include "navmap_core/NavMap.hpp" -using namespace navmap; +using navmap::NavCelId; +using navmap::NavMap; +using navmap::PointId; namespace { diff --git a/navmap_core/tests/test_raycast_many.cpp b/navmap_core/tests/test_raycast_many.cpp index 7de6dd6..1787a0b 100644 --- a/navmap_core/tests/test_raycast_many.cpp +++ b/navmap_core/tests/test_raycast_many.cpp @@ -16,7 +16,9 @@ #include #include "navmap_core/NavMap.hpp" -using namespace navmap; +using navmap::NavMap; +using navmap::Ray; +using navmap::RayHit; TEST(NavMap_RaycastMany, FlatFloorBatchHits) { diff --git a/navmap_examples/CMakeLists.txt b/navmap_examples/CMakeLists.txt index 62fe45b..ea94257 100644 --- a/navmap_examples/CMakeLists.txt +++ b/navmap_examples/CMakeLists.txt @@ -50,8 +50,10 @@ endif() if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) - set(ament_cmake_copyright_FOUND TRUE) - set(ament_cmake_cpplint_FOUND TRUE) + # Humble's ament_copyright does not recognize the license with the EasyNav line in the header + if("$ENV{ROS_DISTRO}" STREQUAL "humble") + list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright) + endif() ament_lint_auto_find_test_dependencies() endif() diff --git a/navmap_examples/launch/navmap_to_occgrid.launch.py b/navmap_examples/launch/navmap_to_occgrid.launch.py index 2f45d44..943e8b2 100644 --- a/navmap_examples/launch/navmap_to_occgrid.launch.py +++ b/navmap_examples/launch/navmap_to_occgrid.launch.py @@ -1,3 +1,18 @@ +# Copyright 2025 Intelligent Robotics Lab +# +# This file is part of the project Easy Navigation (EasyNav in short) +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from launch import LaunchDescription from launch_ros.actions import Node diff --git a/navmap_examples/src/01_flat_plane.cpp b/navmap_examples/src/01_flat_plane.cpp index 50a2404..10c6459 100644 --- a/navmap_examples/src/01_flat_plane.cpp +++ b/navmap_examples/src/01_flat_plane.cpp @@ -17,8 +17,8 @@ #include #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; @@ -59,7 +59,7 @@ int main() cout << "locate=" << ok << " sidx=" << sidx << " cid=" << cid << " hit=(" << hit.x() << "," << hit.y() << "," << hit.z() << ")\n"; if (ok) { - cout << "occ at cid: " << (int)nm.navcel_value(cid, *occ) << endl; + cout << "occ at cid: " << static_cast(nm.navcel_value(cid, *occ)) << endl; } return 0; } diff --git a/navmap_examples/src/02_two_floors.cpp b/navmap_examples/src/02_two_floors.cpp index ac89f44..2135d38 100644 --- a/navmap_examples/src/02_two_floors.cpp +++ b/navmap_examples/src/02_two_floors.cpp @@ -16,8 +16,8 @@ #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; diff --git a/navmap_examples/src/03_slope_surface.cpp b/navmap_examples/src/03_slope_surface.cpp index f479cb9..f818f64 100644 --- a/navmap_examples/src/03_slope_surface.cpp +++ b/navmap_examples/src/03_slope_surface.cpp @@ -16,8 +16,8 @@ #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; diff --git a/navmap_examples/src/04_layers.cpp b/navmap_examples/src/04_layers.cpp index 4b07e55..ed3bbea 100644 --- a/navmap_examples/src/04_layers.cpp +++ b/navmap_examples/src/04_layers.cpp @@ -16,8 +16,8 @@ #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; @@ -44,7 +44,7 @@ int main() nm.layer_set("cost", c0, 5.5f); auto names = nm.list_layers(); - cout << "Layers:"; for (auto & n:names) { + cout << "Layers:"; for (auto & n : names) { cout << " " << n; } cout << endl; diff --git a/navmap_examples/src/05_neighbors_and_centroids.cpp b/navmap_examples/src/05_neighbors_and_centroids.cpp index 5d99476..f8c1ebe 100644 --- a/navmap_examples/src/05_neighbors_and_centroids.cpp +++ b/navmap_examples/src/05_neighbors_and_centroids.cpp @@ -16,8 +16,8 @@ #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; @@ -49,7 +49,7 @@ int main() auto neigh = nm.navcel_neighbors(c0); cout << "centroid0=(" << cc0.x() << "," << cc0.y() << "," << cc0.z() << ")" << endl; cout << "centroid1=(" << cc1.x() << "," << cc1.y() << "," << cc1.z() << ")" << endl; - cout << "neighbors of c0:"; for (auto n:neigh) { + cout << "neighbors of c0:"; for (auto n : neigh) { cout << " " << n; } cout << endl; diff --git a/navmap_examples/src/06_area_marking.cpp b/navmap_examples/src/06_area_marking.cpp index c0727b4..f887398 100644 --- a/navmap_examples/src/06_area_marking.cpp +++ b/navmap_examples/src/06_area_marking.cpp @@ -14,10 +14,11 @@ // limitations under the License. +#include #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; @@ -26,7 +27,6 @@ using Eigen::Vector3f; using std::cout; using std::endl; // 06_area_marking: set_area CIRCULAR y RECTANGULAR sobre una malla 1x1 de 2 tris -#include int main() { NavMap nm; diff --git a/navmap_examples/src/07_raycast.cpp b/navmap_examples/src/07_raycast.cpp index 4ff7d8d..e37d7ec 100644 --- a/navmap_examples/src/07_raycast.cpp +++ b/navmap_examples/src/07_raycast.cpp @@ -16,8 +16,8 @@ #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; diff --git a/navmap_examples/src/08_copy_and_assign.cpp b/navmap_examples/src/08_copy_and_assign.cpp index 691d1de..1433809 100644 --- a/navmap_examples/src/08_copy_and_assign.cpp +++ b/navmap_examples/src/08_copy_and_assign.cpp @@ -17,8 +17,8 @@ #include #include #include -#include +#include "Eigen/Core" #include "navmap_core/NavMap.hpp" using navmap::NavMap; @@ -50,7 +50,7 @@ int main() dst = src; auto names_after = dst.list_layers(); std::cout << "assign equal geom ok; layers after:"; - for (auto & n:names_after) { + for (auto & n : names_after) { std::cout << " " << n; } std::cout << "\n"; diff --git a/navmap_examples/src_ros2/03_save_load.cpp b/navmap_examples/src_ros2/03_save_load.cpp index b87587a..6a5a4a0 100644 --- a/navmap_examples/src_ros2/03_save_load.cpp +++ b/navmap_examples/src_ros2/03_save_load.cpp @@ -15,9 +15,10 @@ // Guardar/cargar NavMap en JSON muy simple (demo) — geometría + una capa U8 -#include #include -#include + +#include "rclcpp/rclcpp.hpp" +#include "nlohmann/json.hpp" #include "navmap_core/NavMap.hpp" using json = nlohmann::json; @@ -27,7 +28,7 @@ static void save_json(const navmap::NavMap & nm, const std::string & path) json j; j["x"] = nm.positions.x; j["y"] = nm.positions.y; j["z"] = nm.positions.z; j["tris"] = json::array(); - for (const auto & c: nm.navcels) { + for (const auto & c : nm.navcels) { j["tris"].push_back({c.v[0], c.v[1], c.v[2]}); } // Solo capa "occupancy" si existe diff --git a/navmap_ros/CMakeLists.txt b/navmap_ros/CMakeLists.txt index 572ac54..a716163 100644 --- a/navmap_ros/CMakeLists.txt +++ b/navmap_ros/CMakeLists.txt @@ -71,8 +71,10 @@ install(DIRECTORY include/ DESTINATION include) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) - set(ament_cmake_copyright_FOUND TRUE) - set(ament_cmake_cpplint_FOUND TRUE) + # Humble's ament_copyright does not recognize the license with the EasyNav line in the header + if("$ENV{ROS_DISTRO}" STREQUAL "humble") + list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright) + endif() ament_lint_auto_find_test_dependencies() find_package(ament_cmake_gtest REQUIRED) diff --git a/navmap_ros/include/navmap_ros/conversions.hpp b/navmap_ros/include/navmap_ros/conversions.hpp index 253f9a5..1fbc813 100644 --- a/navmap_ros/include/navmap_ros/conversions.hpp +++ b/navmap_ros/include/navmap_ros/conversions.hpp @@ -37,16 +37,15 @@ */ #include -#include -#include -#include +#include "Eigen/Core" +#include "pcl/point_cloud.h" +#include "pcl/point_types.h" #include "std_msgs/msg/header.hpp" #include "sensor_msgs/msg/point_cloud2.hpp" #include "navmap_ros_interfaces/msg/nav_map.hpp" #include "navmap_ros_interfaces/msg/nav_map_layer.hpp" #include "nav_msgs/msg/occupancy_grid.hpp" - #include "navmap_core/NavMap.hpp" /** diff --git a/navmap_ros/src/navmap_ros/conversions.cpp b/navmap_ros/src/navmap_ros/conversions.cpp index faf2117..2a96eea 100644 --- a/navmap_ros/src/navmap_ros/conversions.cpp +++ b/navmap_ros/src/navmap_ros/conversions.cpp @@ -568,7 +568,7 @@ bool build_navmap_from_mesh( navmap_ros_interfaces::msg::NavMapLayer layer; layer.name = "elevation"; - layer.type = 1; // F32 + layer.type = 1; // F32 layer.data_f32 = std::move(elev); out_msg.layers.push_back(std::move(layer)); } @@ -1133,9 +1133,9 @@ navmap::NavMap from_points( // Z windows around the expanding boundary (keeps ramps but avoids jumps) const float z_window_seed = std::max(P.max_dz, 0.35f); - std::vector> surf_tri_ranges; // [offset, count] + std::vector> surf_tri_ranges; // [offset, count] - RejectCounts global_rej{}; // still used to track precheck stats (no logging) + RejectCounts global_rej{}; // still used to track precheck stats (no logging) for (int seed_idx : order) { if (used_vertex[seed_idx]) {continue;} @@ -1490,4 +1490,4 @@ navmap::NavMap from_pointcloud2( return from_points(input_points, out_msg, params); } -} // namespace navmap_ros +} // namespace navmap_ros diff --git a/navmap_ros/src/navmap_ros/navmap_io.cpp b/navmap_ros/src/navmap_ros/navmap_io.cpp index e13ac6a..b538140 100644 --- a/navmap_ros/src/navmap_ros/navmap_io.cpp +++ b/navmap_ros/src/navmap_ros/navmap_io.cpp @@ -14,20 +14,18 @@ // limitations under the License. +#include + #include #include #include -#include #include #include "navmap_ros/navmap_io.hpp" - #include "navmap_core/NavMap.hpp" #include "navmap_ros/conversions.hpp" - - -#include -#include +#include "rclcpp/serialized_message.hpp" +#include "rclcpp/serialization.hpp" namespace navmap_ros::io { @@ -43,7 +41,7 @@ inline void set_error(std::error_code * ec, int ev = EIO) if (ec) {*ec = std::error_code(ev, std::generic_category());} } -} // namespace +} // namespace bool save_msg_to_file( const navmap_ros_interfaces::msg::NavMap & msg, @@ -161,4 +159,4 @@ bool load_from_file( return true; } -} // namespace navmap_ros::io +} // namespace navmap_ros::io diff --git a/navmap_ros/src/slam_server_app.cpp b/navmap_ros/src/slam_server_app.cpp index ed28550..1aa143f 100644 --- a/navmap_ros/src/slam_server_app.cpp +++ b/navmap_ros/src/slam_server_app.cpp @@ -29,7 +29,7 @@ class SLAMServerNode : public rclcpp::Node public: RCLCPP_SMART_PTR_DEFINITIONS(SLAMServerNode) - SLAMServerNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()) + explicit SLAMServerNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()) : Node("slam_server_node", options) { navmap_pub_ = create_publisher("navmap", diff --git a/navmap_ros/tests/test_conversions.cpp b/navmap_ros/tests/test_conversions.cpp index bcdd9f5..4b0847e 100644 --- a/navmap_ros/tests/test_conversions.cpp +++ b/navmap_ros/tests/test_conversions.cpp @@ -17,14 +17,12 @@ #include #include -#include -#include -#include -#include - +#include "gtest/gtest.h" +#include "nav_msgs/msg/occupancy_grid.hpp" +#include "pcl/point_cloud.h" +#include "pcl/point_types.h" #include "navmap_ros_interfaces/msg/nav_map_layer.hpp" #include "std_msgs/msg/header.hpp" - #include "navmap_ros/conversions.hpp" #include "navmap_core/NavMap.hpp" @@ -402,7 +400,7 @@ TEST(TestConversions, TriangleIndicesFollowPattern0) static pcl::PointCloud make_organized_grid( int W, int H, double spacing, - const std::function & z_fn = [](int, int) {return 0.0f;}) + const std::function & z_fn = [] (int, int) {return 0.0f;}) { pcl::PointCloud cloud; cloud.width = static_cast(W); diff --git a/navmap_ros/tests/test_navmap_io.cpp b/navmap_ros/tests/test_navmap_io.cpp index f0b7ace..e3dc5f4 100644 --- a/navmap_ros/tests/test_navmap_io.cpp +++ b/navmap_ros/tests/test_navmap_io.cpp @@ -13,18 +13,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include -#include -#include +#include #include #include #include -#include #include +#include "gtest/gtest.h" +#include "rclcpp/serialization.hpp" +#include "rclcpp/serialized_message.hpp" #include "std_msgs/msg/header.hpp" - #include "navmap_core/NavMap.hpp" #include "navmap_ros/conversions.hpp" #include "navmap_ros/navmap_io.hpp" @@ -56,7 +55,7 @@ void fill_basic_header(navmap_ros_interfaces::msg::NavMap & msg, const std::stri // leave stamp default } -} // namespace +} // namespace // --- helpers: semantic comparison for messages --- @@ -136,13 +135,13 @@ static void ExpectNavMapMsgEqualSemantic( EXPECT_EQ(La->type, Lb->type) << "layer type mismatch for " << name; switch (La->type) { - case 0: // u8 + case 0: // u8 ExpectVecEq(La->data_u8, Lb->data_u8, (name + ".data_u8").c_str()); break; - case 1: // f32 + case 1: // f32 ExpectVecFloatEq(La->data_f32, Lb->data_f32, (name + ".data_f32").c_str()); break; - case 2: // f64 + case 2: // f64 ExpectVecNear64(La->data_f64, Lb->data_f64, (name + ".data_f64").c_str()); break; default: @@ -194,7 +193,7 @@ TEST(NavMapIoMsg, SingleTriangleWithU8AndVertexRGBA) // U8 layer with one value navmap_ros_interfaces::msg::NavMapLayer layer_u8; layer_u8.name = "occupancy_like"; - layer_u8.type = 0; // u8 + layer_u8.type = 0; // u8 layer_u8.data_u8 = {42}; msg.layers.push_back(layer_u8); @@ -291,29 +290,28 @@ TEST(NavMapIoCore, RoundtripViaCoreAndMsgCompare) f32.name = "cost"; f32.type = 1; f32.data_f32 = {0.1f, 0.5f, 1.0f}; msg.layers = {u8, f32}; -// msg -> core -std_msgs::msg::Header h_in; -navmap::NavMap core = navmap_ros::from_msg(msg, h_in); -EXPECT_EQ(h_in.frame_id, msg.header.frame_id); + // msg -> core + std_msgs::msg::Header h_in; + navmap::NavMap core = navmap_ros::from_msg(msg, h_in); + EXPECT_EQ(h_in.frame_id, msg.header.frame_id); -// save(core) -> load(core) -std::string path = (std::filesystem::temp_directory_path() / + // save(core) -> load(core) + std::string path = (std::filesystem::temp_directory_path() / ("core_roundtrip_" + std::to_string(::getpid()) + ".navmap")).string(); -std::error_code ec; -ASSERT_TRUE(navmap_ros::io::save_to_file(core, path, {}, &ec)) << ec.message(); + std::error_code ec; + ASSERT_TRUE(navmap_ros::io::save_to_file(core, path, {}, &ec)) << ec.message(); -navmap::NavMap core_loaded; -ASSERT_TRUE(navmap_ros::io::load_from_file(path, core_loaded, &ec)) << ec.message(); + navmap::NavMap core_loaded; + ASSERT_TRUE(navmap_ros::io::load_from_file(path, core_loaded, &ec)) << ec.message(); -// core -> msg -std_msgs::msg::Header h_out; -h_out.frame_id = msg.header.frame_id; -auto msg_from_core = navmap_ros::to_msg(core, h_out); -auto msg_from_core_loaded = navmap_ros::to_msg(core_loaded, h_out); + // core -> msg + std_msgs::msg::Header h_out; + h_out.frame_id = msg.header.frame_id; + auto msg_from_core = navmap_ros::to_msg(core, h_out); + auto msg_from_core_loaded = navmap_ros::to_msg(core_loaded, h_out); -// Semantic comparison (order and FP tolerant) -ExpectNavMapMsgEqualSemantic(msg_from_core, msg_from_core_loaded); + // Semantic comparison (order and FP tolerant) + ExpectNavMapMsgEqualSemantic(msg_from_core, msg_from_core_loaded); -std::filesystem::remove(path); std::filesystem::remove(path); } diff --git a/navmap_rviz_plugin/CMakeLists.txt b/navmap_rviz_plugin/CMakeLists.txt index 703fdcd..188769d 100644 --- a/navmap_rviz_plugin/CMakeLists.txt +++ b/navmap_rviz_plugin/CMakeLists.txt @@ -70,8 +70,10 @@ install(FILES resource/navmap_rviz_plugin_description.xml if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) - set(ament_cmake_copyright_FOUND TRUE) - set(ament_cmake_cpplint_FOUND TRUE) + # Humble's ament_copyright does not recognize the license with the EasyNav line in the header + if("$ENV{ROS_DISTRO}" STREQUAL "humble") + list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright) + endif() ament_lint_auto_find_test_dependencies() endif() diff --git a/navmap_rviz_plugin/include/navmap_rviz_plugin/NavMapDisplay.hpp b/navmap_rviz_plugin/include/navmap_rviz_plugin/NavMapDisplay.hpp index 077429b..9097a01 100644 --- a/navmap_rviz_plugin/include/navmap_rviz_plugin/NavMapDisplay.hpp +++ b/navmap_rviz_plugin/include/navmap_rviz_plugin/NavMapDisplay.hpp @@ -14,33 +14,28 @@ // limitations under the License. -#ifndef NAVMAP_RVIZ_PLUGIN__NAVMAP_DISPLAY_HPP_ -#define NAVMAP_RVIZ_PLUGIN__NAVMAP_DISPLAY_HPP_ +#ifndef NAVMAP_RVIZ_PLUGIN__NAVMAPDISPLAY_HPP_ +#define NAVMAP_RVIZ_PLUGIN__NAVMAPDISPLAY_HPP_ #include #include #include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - +#include "QObject" +#include "OgreHardwareVertexBuffer.h" +#include "OgreMesh.h" +#include "rclcpp/qos.hpp" +#include "rclcpp/subscription.hpp" +#include "rviz_common/message_filter_display.hpp" +#include "rviz_common/properties/bool_property.hpp" +#include "rviz_common/properties/enum_property.hpp" +#include "rviz_common/properties/float_property.hpp" +#include "rviz_common/properties/qos_profile_property.hpp" +#include "rviz_common/properties/ros_topic_property.hpp" +#include "rviz_common/properties/string_property.hpp" +#include "rviz_common/display_context.hpp" +#include "navmap_ros_interfaces/msg/nav_map.hpp" +#include "navmap_ros_interfaces/msg/nav_map_layer.hpp" #include "navmap_core/NavMap.hpp" #if defined _WIN32 || defined __CYGWIN__ @@ -164,10 +159,10 @@ private Q_SLOTS: Ogre::Entity * entity_{nullptr}; Ogre::SharedPtr mesh_; // Ogre::MeshPtr Ogre::HardwareVertexBufferSharedPtr colour_vbuf_; - unsigned short colour_vbuf_source_{0}; // which stream holds VES_DIFFUSE + uint16_t colour_vbuf_source_{0}; // which stream holds VES_DIFFUSE bool mesh_built_{false}; }; } // namespace navmap_rviz_plugin -#endif // NAVMAP_RVIZ_PLUGIN__NAVMAP_DISPLAY_HPP_ +#endif // NAVMAP_RVIZ_PLUGIN__NAVMAPDISPLAY_HPP_ diff --git a/navmap_rviz_plugin/src/navmap_rviz_plugin/NavMapDisplay.cpp b/navmap_rviz_plugin/src/navmap_rviz_plugin/NavMapDisplay.cpp index 6a6618d..559eaeb 100644 --- a/navmap_rviz_plugin/src/navmap_rviz_plugin/NavMapDisplay.cpp +++ b/navmap_rviz_plugin/src/navmap_rviz_plugin/NavMapDisplay.cpp @@ -83,7 +83,7 @@ inline Ogre::ColourValue colorFromHeat(float value, float max_value, float alpha return Ogre::ColourValue(t, 1.0f - t, 0.0f, alpha); } -} // namespace +} // namespace namespace navmap_rviz_plugin { @@ -547,7 +547,7 @@ void NavMapDisplay::ensureMeshBuilt_() #else // Fallback: rebuild declaration without VES_DIFFUSE Ogre::VertexDeclaration * newDecl = context_->getSceneManager()->createVertexDeclaration(); - for (unsigned short s = 0; s < decl->getElementCount(); ++s) { + for (uint16_t s = 0; s < decl->getElementCount(); ++s) { const Ogre::VertexElement & e = decl->getElement(s); if (e.getSemantic() == Ogre::VES_DIFFUSE) {continue;} newDecl->addElement(e.getSource(), e.getOffset(), e.getType(), e.getSemantic(), e.getIndex()); @@ -558,16 +558,16 @@ void NavMapDisplay::ensureMeshBuilt_() } // Choose a free binding source for colours (avoid clashing with positions/normals) - unsigned short COLOR_SRC = 1; + uint16_t COLOR_SRC = 1; while (bind->isBufferBound(COLOR_SRC)) {++COLOR_SRC;} // Create the dynamic colour buffer (one 32-bit colour per vertex) - const Ogre::VertexElementType col_type = Ogre::VET_COLOUR_ARGB; // we'll pack ARGB + const Ogre::VertexElementType col_type = Ogre::VET_COLOUR_ARGB; // we'll pack ARGB decl->addElement(COLOR_SRC, /*offset=*/0, col_type, Ogre::VES_DIFFUSE); Ogre::HardwareVertexBufferSharedPtr colour_vbuf = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer( - Ogre::VertexElement::getTypeSize(col_type), // should be 4 + Ogre::VertexElement::getTypeSize(col_type), // should be 4 vertex_count, Ogre::HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE); @@ -627,24 +627,19 @@ void NavMapDisplay::updateColorsOnly_() float max_val = 0.0f; bool is_u8 = false; if (selected_layer) { - if (selected_layer->type == NavMapLayerMsg::U8 && - selected_layer->data_u8.size() == V0.size()) - { + const auto & L = *selected_layer; + if (L.type == NavMapLayerMsg::U8 && L.data_u8.size() == V0.size()) { is_u8 = true; - } else if (selected_layer->type == NavMapLayerMsg::F32 && - selected_layer->data_f32.size() == V0.size()) - { - for (float v : selected_layer->data_f32) { + } else if (L.type == NavMapLayerMsg::F32 && L.data_f32.size() == V0.size()) { + for (float v : L.data_f32) { max_val = std::max(max_val, v); } - } else if (selected_layer->type == NavMapLayerMsg::F64 && - selected_layer->data_f64.size() == V0.size()) - { - for (double v : selected_layer->data_f64) { + } else if (L.type == NavMapLayerMsg::F64 && L.data_f64.size() == V0.size()) { + for (double v : L.data_f64) { max_val = std::max(max_val, static_cast(v)); } } else { - selected_layer = nullptr; // fallback to neutral grey + selected_layer = nullptr; // fallback to neutral grey } } @@ -712,7 +707,7 @@ void NavMapDisplay::updateColorsOnly_() const uint32_t packed = packARGB(col); *p++ = packed; *p++ = packed; *p++ = packed; } - } else { // F64 + } else { // F64 for (size_t t = 0; t < V0.size(); ++t) { const float v = static_cast(selected_layer->data_f64[t]); const Ogre::ColourValue col = use_rainbow ? diff --git a/navmap_rviz_plugin/src/navmap_rviz_plugin/navmap_pose_tool.cpp b/navmap_rviz_plugin/src/navmap_rviz_plugin/navmap_pose_tool.cpp index 398f5bd..e9540b4 100644 --- a/navmap_rviz_plugin/src/navmap_rviz_plugin/navmap_pose_tool.cpp +++ b/navmap_rviz_plugin/src/navmap_rviz_plugin/navmap_pose_tool.cpp @@ -20,25 +20,21 @@ #include #include -#include -#include -#include -#include -#include - -#include - +#include "OgrePlane.h" +#include "OgreRay.h" +#include "OgreSceneNode.h" +#include "OgreViewport.h" +#include "OgreCamera.h" +#include "Eigen/Core" #include "rviz_rendering/geometry.hpp" #include "rviz_rendering/objects/arrow.hpp" #include "rviz_rendering/render_window.hpp" - #include "rviz_common/logging.hpp" #include "rviz_common/display_context.hpp" #include "rviz_common/render_panel.hpp" #include "rviz_common/viewport_mouse_event.hpp" #include "rviz_common/view_manager.hpp" #include "rviz_common/view_controller.hpp" - #include "navmap_core/NavMap.hpp" #include "navmap_rviz_plugin/NavMapDisplay.hpp" diff --git a/navmap_tools/CMakeLists.txt b/navmap_tools/CMakeLists.txt index 7480051..602ceb5 100644 --- a/navmap_tools/CMakeLists.txt +++ b/navmap_tools/CMakeLists.txt @@ -53,8 +53,10 @@ install(TARGETS if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) - set(ament_cmake_copyright_FOUND TRUE) - set(ament_cmake_cpplint_FOUND TRUE) + # Humble's ament_copyright does not recognize the license with the EasyNav line in the header + if("$ENV{ROS_DISTRO}" STREQUAL "humble") + list(APPEND AMENT_LINT_AUTO_EXCLUDE ament_cmake_copyright) + endif() ament_lint_auto_find_test_dependencies() find_package(ament_cmake_pytest REQUIRED) diff --git a/navmap_tools/src/pointcloud_to_navmap.cpp b/navmap_tools/src/pointcloud_to_navmap.cpp index 14f6760..c4b637a 100644 --- a/navmap_tools/src/pointcloud_to_navmap.cpp +++ b/navmap_tools/src/pointcloud_to_navmap.cpp @@ -27,10 +27,9 @@ #include #include -#include -#include -#include - +#include "pcl/io/pcd_io.h" +#include "pcl/point_types.h" +#include "pcl/search/kdtree.h" #include "navmap_ros/conversions.hpp" #include "navmap_ros/navmap_io.hpp"