From eedfcc39b015988bc0cd32bacfe2b8904f8b43aa Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 21 Sep 2023 16:28:05 +0200 Subject: [PATCH 1/4] Address failing DCHECKs for Morton conversions of negative indices --- .../include/wavemap/utils/morton_encoding.h | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/libraries/wavemap/include/wavemap/utils/morton_encoding.h b/libraries/wavemap/include/wavemap/utils/morton_encoding.h index 78156f613..92e63eb6a 100644 --- a/libraries/wavemap/include/wavemap/utils/morton_encoding.h +++ b/libraries/wavemap/include/wavemap/utils/morton_encoding.h @@ -8,11 +8,17 @@ namespace wavemap::morton { template constexpr int kMaxTreeHeight = 8 * sizeof(MortonIndex) / dim; + template constexpr IndexElement kMaxSingleCoordinate = (dim < 3) ? std::numeric_limits::max() : (1ul << kMaxTreeHeight)-1ul; +template +constexpr MortonIndex kMaxMortonIndex = + (dim < 3) ? std::numeric_limits::max() + : (1ul << (dim * kMaxTreeHeight)) - 1ul; + template struct MortonByteLut { private: @@ -41,14 +47,38 @@ struct MortonByteLut { static constexpr std::array decode{generate_decoder()}; }; -template +/** + * Method to convert regular n-dimensional indices into Morton indices. + * @tparam dim Dimension of the index. + * @tparam check_sign Whether to check that each index coefficient is positive. + * Note that negative signs are not preserved when encoding and decoding + * Morton indices. The check can be enabled to throw an error in cases + * where round trip conversions would not yield an identical index. + * Since we often only perform one way conversions and use the Morton + * indices as relative offsets, the check is disabled by default. + * Note that since the check is a DCHECK, it only triggers when the code + * is built with the DCHECK_ALWAYS_ON flag enabled or in debug mode. + */ +template MortonIndex encode(const Index& index) { + // Check if the index coordinates are within the supported range + // NOTE: This check is only performed in debug mode, or if DCHECK_ALWAYS_ON is + // set. Otherwise, the loop is empty and optimized out. + for (int dim_idx = 0; dim_idx < dim; ++dim_idx) { + if constexpr (check_sign) { + DCHECK_GE(index[dim_idx], 0); + } else { + DCHECK_GT(index[dim_idx], -kMaxSingleCoordinate); + } + DCHECK_LE(index[dim_idx], kMaxSingleCoordinate); + } + + // Perform the morton encoding, using bitwise expansion if supported by the + // target CPU architecture and LUTs otherwise uint64_t morton = 0u; #ifdef BIT_EXPAND_AVAILABLE constexpr auto pattern = bit_manip::repeat_block(dim, 0b1); for (int dim_idx = 0; dim_idx < dim; ++dim_idx) { - DCHECK_GE(index[dim_idx], 0); - DCHECK_LE(index[dim_idx], kMaxSingleCoordinate); morton |= bit_manip::expand(index[dim_idx], pattern << dim_idx); } #else @@ -67,6 +97,9 @@ MortonIndex encode(const Index& index) { return morton; } +// Decode a single coordinate from a Morton index using LUTs +// NOTE: This method is only used if bitwise compression is not supported by the +// target CPU architecture. template IndexElement decode_coordinate(MortonIndex morton, int coordinate_idx) { constexpr MortonIndex kByteMask = (1 << 8) - 1; @@ -86,6 +119,11 @@ IndexElement decode_coordinate(MortonIndex morton, int coordinate_idx) { template Index decode(MortonIndex morton) { + // Check if the Morton index is within the supported range + DCHECK_LE(morton, kMaxMortonIndex); + + // Perform the morton decoding, using bitwise compression if supported by the + // target CPU architecture and LUTs otherwise Index index; #ifdef BIT_COMPRESS_AVAILABLE constexpr auto pattern = bit_manip::repeat_block(dim, 0b1); From 4bb08a0c80e77e2890838760c0ddea88118dbf78 Mon Sep 17 00:00:00 2001 From: Victor Date: Thu, 21 Sep 2023 17:03:08 +0200 Subject: [PATCH 2/4] Run CI tests with DCHECK_ALWAYS_ON --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 501088e04..b914ac3ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -364,14 +364,14 @@ jobs: - name: Build regular code working-directory: ${{ env.CATKIN_WS_PATH }} shell: bash - run: catkin build wavemap_all --no-status --force-color + run: catkin build wavemap_all --no-status --force-color --cmake-args -DDCHECK_ALWAYS_ON=ON - name: Build unit tests working-directory: ${{ env.CATKIN_WS_PATH }} shell: bash run: | echo "::add-matcher::./.github/problem-matchers/gcc.json" - catkin build wavemap_all --no-status --force-color --no-deps --catkin-make-args tests + catkin build wavemap_all --no-status --force-color --no-deps --cmake-args -DDCHECK_ALWAYS_ON=ON --catkin-make-args tests echo "::remove-matcher owner=problem-matcher-gcc::" - name: Run unit tests From d726a6d163eabbc09edac891a7c632933c200d89 Mon Sep 17 00:00:00 2001 From: Victor Reijgwart Date: Thu, 28 Sep 2023 10:55:33 +0200 Subject: [PATCH 3/4] Update changelogs --- libraries/wavemap/CHANGELOG.rst | 5 +++++ libraries/wavemap_io/CHANGELOG.rst | 3 +++ ros/wavemap_msgs/CHANGELOG.rst | 3 +++ ros/wavemap_ros/CHANGELOG.rst | 3 +++ ros/wavemap_ros_conversions/CHANGELOG.rst | 3 +++ ros/wavemap_rviz_plugin/CHANGELOG.rst | 3 +++ tooling/packages/catkin_setup/CHANGELOG.rst | 3 +++ tooling/packages/wavemap_all/CHANGELOG.rst | 3 +++ tooling/packages/wavemap_utils/CHANGELOG.rst | 3 +++ 9 files changed, 29 insertions(+) diff --git a/libraries/wavemap/CHANGELOG.rst b/libraries/wavemap/CHANGELOG.rst index 60f979cf1..b2a509218 100644 --- a/libraries/wavemap/CHANGELOG.rst +++ b/libraries/wavemap/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog for package wavemap ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- +* Address failing DCHECKs for Morton conversions of negative indices +* Contributors: Victor Reijgwart + 1.5.2 (2023-09-19) ------------------ * Add missing install rules for wavemap diff --git a/libraries/wavemap_io/CHANGELOG.rst b/libraries/wavemap_io/CHANGELOG.rst index 75de7b6e5..f34ccff01 100644 --- a/libraries/wavemap_io/CHANGELOG.rst +++ b/libraries/wavemap_io/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_io ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_msgs/CHANGELOG.rst b/ros/wavemap_msgs/CHANGELOG.rst index 08b5d76be..c73b6878d 100644 --- a/ros/wavemap_msgs/CHANGELOG.rst +++ b/ros/wavemap_msgs/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_msgs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_ros/CHANGELOG.rst b/ros/wavemap_ros/CHANGELOG.rst index dd8095c47..d659acbff 100644 --- a/ros/wavemap_ros/CHANGELOG.rst +++ b/ros/wavemap_ros/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_ros ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ * Add missing install rules for wavemap diff --git a/ros/wavemap_ros_conversions/CHANGELOG.rst b/ros/wavemap_ros_conversions/CHANGELOG.rst index 5a774843f..2c58bf990 100644 --- a/ros/wavemap_ros_conversions/CHANGELOG.rst +++ b/ros/wavemap_ros_conversions/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_ros_conversions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_rviz_plugin/CHANGELOG.rst b/ros/wavemap_rviz_plugin/CHANGELOG.rst index 38220a6b0..5a246aaae 100644 --- a/ros/wavemap_rviz_plugin/CHANGELOG.rst +++ b/ros/wavemap_rviz_plugin/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_rviz_plugin ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ diff --git a/tooling/packages/catkin_setup/CHANGELOG.rst b/tooling/packages/catkin_setup/CHANGELOG.rst index f416f4469..b0906076f 100644 --- a/tooling/packages/catkin_setup/CHANGELOG.rst +++ b/tooling/packages/catkin_setup/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package catkin_setup ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ diff --git a/tooling/packages/wavemap_all/CHANGELOG.rst b/tooling/packages/wavemap_all/CHANGELOG.rst index 2dfc17b4c..1e4ed783e 100644 --- a/tooling/packages/wavemap_all/CHANGELOG.rst +++ b/tooling/packages/wavemap_all/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_all ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ diff --git a/tooling/packages/wavemap_utils/CHANGELOG.rst b/tooling/packages/wavemap_utils/CHANGELOG.rst index c63f823c7..2664339c7 100644 --- a/tooling/packages/wavemap_utils/CHANGELOG.rst +++ b/tooling/packages/wavemap_utils/CHANGELOG.rst @@ -2,6 +2,9 @@ Changelog for package wavemap_utils ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Forthcoming +----------- + 1.5.2 (2023-09-19) ------------------ From f03a8a2e228a3f359c6b0e3a66d3ed7a686a4ebc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 08:57:03 +0000 Subject: [PATCH 4/4] Prepare release 1.5.3 --- libraries/wavemap/CHANGELOG.rst | 4 ++-- libraries/wavemap/package.xml | 2 +- libraries/wavemap_io/CHANGELOG.rst | 4 ++-- libraries/wavemap_io/package.xml | 2 +- ros/wavemap_msgs/CHANGELOG.rst | 4 ++-- ros/wavemap_msgs/package.xml | 2 +- ros/wavemap_ros/CHANGELOG.rst | 4 ++-- ros/wavemap_ros/package.xml | 2 +- ros/wavemap_ros_conversions/CHANGELOG.rst | 4 ++-- ros/wavemap_ros_conversions/package.xml | 2 +- ros/wavemap_rviz_plugin/CHANGELOG.rst | 4 ++-- ros/wavemap_rviz_plugin/package.xml | 2 +- tooling/packages/catkin_setup/CHANGELOG.rst | 4 ++-- tooling/packages/catkin_setup/package.xml | 2 +- tooling/packages/wavemap_all/CHANGELOG.rst | 4 ++-- tooling/packages/wavemap_all/package.xml | 2 +- tooling/packages/wavemap_utils/CHANGELOG.rst | 4 ++-- tooling/packages/wavemap_utils/package.xml | 2 +- 18 files changed, 27 insertions(+), 27 deletions(-) diff --git a/libraries/wavemap/CHANGELOG.rst b/libraries/wavemap/CHANGELOG.rst index b2a509218..b6afb7ad8 100644 --- a/libraries/wavemap/CHANGELOG.rst +++ b/libraries/wavemap/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ * Address failing DCHECKs for Morton conversions of negative indices * Contributors: Victor Reijgwart diff --git a/libraries/wavemap/package.xml b/libraries/wavemap/package.xml index 10b638065..966c2e735 100644 --- a/libraries/wavemap/package.xml +++ b/libraries/wavemap/package.xml @@ -1,7 +1,7 @@ wavemap - 1.5.2 + 1.5.3 Base library for wavemap. Victor Reijgwart diff --git a/libraries/wavemap_io/CHANGELOG.rst b/libraries/wavemap_io/CHANGELOG.rst index f34ccff01..cfc8efe3f 100644 --- a/libraries/wavemap_io/CHANGELOG.rst +++ b/libraries/wavemap_io/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_io ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/libraries/wavemap_io/package.xml b/libraries/wavemap_io/package.xml index e892d6782..8eb10bd0e 100644 --- a/libraries/wavemap_io/package.xml +++ b/libraries/wavemap_io/package.xml @@ -1,7 +1,7 @@ wavemap_io - 1.5.2 + 1.5.3 (De)serialization of wavemap types to files. Victor Reijgwart diff --git a/ros/wavemap_msgs/CHANGELOG.rst b/ros/wavemap_msgs/CHANGELOG.rst index c73b6878d..ca3aecd5b 100644 --- a/ros/wavemap_msgs/CHANGELOG.rst +++ b/ros/wavemap_msgs/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_msgs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_msgs/package.xml b/ros/wavemap_msgs/package.xml index 34c1cd58d..0f7f26c4e 100644 --- a/ros/wavemap_msgs/package.xml +++ b/ros/wavemap_msgs/package.xml @@ -1,7 +1,7 @@ wavemap_msgs - 1.5.2 + 1.5.3 Message definitions for wavemap's ROS interfaces. Victor Reijgwart diff --git a/ros/wavemap_ros/CHANGELOG.rst b/ros/wavemap_ros/CHANGELOG.rst index d659acbff..d025b6f1a 100644 --- a/ros/wavemap_ros/CHANGELOG.rst +++ b/ros/wavemap_ros/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_ros ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_ros/package.xml b/ros/wavemap_ros/package.xml index 303b14f4f..9c71f83d7 100644 --- a/ros/wavemap_ros/package.xml +++ b/ros/wavemap_ros/package.xml @@ -1,7 +1,7 @@ wavemap_ros - 1.5.2 + 1.5.3 ROS interface for wavemap. Victor Reijgwart diff --git a/ros/wavemap_ros_conversions/CHANGELOG.rst b/ros/wavemap_ros_conversions/CHANGELOG.rst index 2c58bf990..97d62fa55 100644 --- a/ros/wavemap_ros_conversions/CHANGELOG.rst +++ b/ros/wavemap_ros_conversions/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_ros_conversions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_ros_conversions/package.xml b/ros/wavemap_ros_conversions/package.xml index e0ab3b168..b859b4cc4 100644 --- a/ros/wavemap_ros_conversions/package.xml +++ b/ros/wavemap_ros_conversions/package.xml @@ -1,7 +1,7 @@ wavemap_ros_conversions - 1.5.2 + 1.5.3 Conversions between wavemap and ROS types. Victor Reijgwart diff --git a/ros/wavemap_rviz_plugin/CHANGELOG.rst b/ros/wavemap_rviz_plugin/CHANGELOG.rst index 5a246aaae..3a6b49af3 100644 --- a/ros/wavemap_rviz_plugin/CHANGELOG.rst +++ b/ros/wavemap_rviz_plugin/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_rviz_plugin ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/ros/wavemap_rviz_plugin/package.xml b/ros/wavemap_rviz_plugin/package.xml index 6f1598bbe..98e1e87d6 100644 --- a/ros/wavemap_rviz_plugin/package.xml +++ b/ros/wavemap_rviz_plugin/package.xml @@ -1,7 +1,7 @@ wavemap_rviz_plugin - 1.5.2 + 1.5.3 Plugin to interactively visualize maps published in wavemap's native format. diff --git a/tooling/packages/catkin_setup/CHANGELOG.rst b/tooling/packages/catkin_setup/CHANGELOG.rst index b0906076f..1bcca77ba 100644 --- a/tooling/packages/catkin_setup/CHANGELOG.rst +++ b/tooling/packages/catkin_setup/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package catkin_setup ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/tooling/packages/catkin_setup/package.xml b/tooling/packages/catkin_setup/package.xml index dc784cca1..c29caf7c2 100644 --- a/tooling/packages/catkin_setup/package.xml +++ b/tooling/packages/catkin_setup/package.xml @@ -1,7 +1,7 @@ catkin_setup - 1.5.2 + 1.5.3 Dummy package to make it easy to setup the workspace and generate the setup.[sh|bash|zsh] scripts in CI. Victor Reijgwart diff --git a/tooling/packages/wavemap_all/CHANGELOG.rst b/tooling/packages/wavemap_all/CHANGELOG.rst index 1e4ed783e..7fccd2030 100644 --- a/tooling/packages/wavemap_all/CHANGELOG.rst +++ b/tooling/packages/wavemap_all/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_all ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/tooling/packages/wavemap_all/package.xml b/tooling/packages/wavemap_all/package.xml index 817700c33..7bf11d584 100644 --- a/tooling/packages/wavemap_all/package.xml +++ b/tooling/packages/wavemap_all/package.xml @@ -1,7 +1,7 @@ wavemap_all - 1.5.2 + 1.5.3 Metapackage that builds all wavemap packages. Victor Reijgwart diff --git a/tooling/packages/wavemap_utils/CHANGELOG.rst b/tooling/packages/wavemap_utils/CHANGELOG.rst index 2664339c7..f235a57a3 100644 --- a/tooling/packages/wavemap_utils/CHANGELOG.rst +++ b/tooling/packages/wavemap_utils/CHANGELOG.rst @@ -2,8 +2,8 @@ Changelog for package wavemap_utils ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Forthcoming ------------ +1.5.3 (2023-09-28) +------------------ 1.5.2 (2023-09-19) ------------------ diff --git a/tooling/packages/wavemap_utils/package.xml b/tooling/packages/wavemap_utils/package.xml index 47a04f934..16307de22 100644 --- a/tooling/packages/wavemap_utils/package.xml +++ b/tooling/packages/wavemap_utils/package.xml @@ -1,7 +1,7 @@ wavemap_utils - 1.5.2 + 1.5.3 Small package containing scripts to simplify common wavemap development tasks. Victor Reijgwart