Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7505486
Use multithreaded executor so layers can use different callback groups
JustusBraun Mar 5, 2025
38c2bd2
Create LayerManager to load, initialize and handle layers
JustusBraun Mar 12, 2025
96f8552
WIP: Layer updates
JustusBraun Mar 16, 2025
d2f041e
Ensure layer updates are not published before initialization finished
JustusBraun Mar 16, 2025
de7f7ff
Add notifyChanged call in combination layers
JustusBraun Mar 17, 2025
de87afd
Add readLock() and writeLock() functions to layer interface for
JustusBraun Mar 23, 2025
6440206
Switch map_ptr_ to std::weak_ptr to prevent cyclic dependencies.
JustusBraun Mar 23, 2025
d37d9b6
Add LayerTimer to allow layers to log locking, update and notifyChange
JustusBraun Mar 23, 2025
fae057a
Unique logger for each layer provided by AbstractLayer
JustusBraun Mar 24, 2025
46156b1
Add dynamic_obstacle_layer to implement optimizations
JustusBraun Mar 25, 2025
c978366
Remove weak_ptr overhead and in loop vector allocations
JustusBraun Mar 25, 2025
a1bec6c
Downcast Mesh and remove vector field publish
JustusBraun Mar 25, 2025
3d19157
Reduce the number of faces checkd for each neighbour vertex
JustusBraun Mar 25, 2025
f747a34
Remove unused vertex maps, set log levels to debug
JustusBraun Mar 25, 2025
8aef90d
Add check if downcast was successful
JustusBraun Mar 25, 2025
0ea8330
Improve default layer update performance by updating only changed
JustusBraun Mar 26, 2025
f3acf8f
Changed writeLock to a protected function. The only logic that should…
JustusBraun Mar 28, 2025
660c10d
The layer update can now be done without needing the writeLock for the
JustusBraun Mar 28, 2025
13a2be2
Added check to detect if a Non-Manifold Mesh was used as input
JustusBraun Apr 6, 2025
0ea1471
Switch log msg to debug
JustusBraun Apr 7, 2025
0c9cfb9
Set cost of lethal vertices to 1.0 and enable OpenMP for faster
JustusBraun Apr 11, 2025
a7c05f7
Fix vertex color loading and publishing
JustusBraun May 27, 2025
e97557f
Add check if the edge_weights map contains the keys
JustusBraun May 27, 2025
09b4b87
Handle non-manifold meshes during Map load
JustusBraun May 30, 2025
6b7ab87
Fix combination layer lethal vertex handling
JustusBraun Jul 13, 2025
e093a9e
Remove explicit initialization for all map values
JustusBraun Jul 14, 2025
ea5776a
Propagate timestamps through notifyChanged and updateInput calls
JustusBraun Jul 16, 2025
c1442bf
Post merge clean up and fixes
JustusBraun Aug 8, 2025
230e8bf
Apply runtime improvements from dynamic_inflation_layer to inflation_…
JustusBraun Aug 8, 2025
aad1e2e
Remove DynamicInflationLayer
JustusBraun Aug 8, 2025
a496eb6
Add note why we do not normalize the combined costs
JustusBraun Aug 11, 2025
17d48d0
Add note on why we use a multithreaded executor
JustusBraun Aug 13, 2025
cb2ccc3
Change AbstractLayer::costs() and AbstractLayer::lethals() to return
JustusBraun Aug 13, 2025
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
7 changes: 6 additions & 1 deletion mbf_mesh_nav/src/mbf_mesh_nav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <signal.h>
#include <tf2_ros/transform_listener.h>
#include <rclcpp/rclcpp.hpp>
#include <rclcpp/executors/multi_threaded_executor.hpp>

mbf_mesh_nav::MeshNavigationServer::Ptr mesh_nav_srv_ptr;
rclcpp::Node::SharedPtr node;
Expand Down Expand Up @@ -66,7 +67,11 @@ int main(int argc, char** argv)

signal(SIGINT, sigintHandler);

rclcpp::spin(node);
// NOTE: Using a multithreaded executor is recommended so cost layers can use
// different callback groups when processing sensor data.
rclcpp::executors::MultiThreadedExecutor exec;
exec.add_node(node);
exec.spin();
Comment thread
JustusBraun marked this conversation as resolved.

return EXIT_SUCCESS;
}
15 changes: 15 additions & 0 deletions mesh_layers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ endif()
find_package(ament_cmake_ros REQUIRED)
find_package(mesh_map REQUIRED)
find_package(LVR2 REQUIRED)
find_package(OpenMP)
add_definitions(${LVR2_DEFINITIONS})

pluginlib_export_plugin_description_file(mesh_map mesh_layers.xml)
Expand All @@ -23,6 +24,7 @@ add_library(${PROJECT_NAME}
src/steepness_layer.cpp
src/ridge_layer.cpp
src/clearance_layer.cpp
src/combination_layer.cpp
)
include_directories(
include
Expand All @@ -38,6 +40,7 @@ ament_target_dependencies(${PROJECT_NAME} mesh_map LVR2)
target_compile_definitions(${PROJECT_NAME} PRIVATE "MESH_LAYERS_BUILDING_LIBRARY")
target_link_libraries(${PROJECT_NAME}
${LVR2_LIBRARIES}
OpenMP::OpenMP_CXX
)

install(DIRECTORY include/
Expand All @@ -51,6 +54,18 @@ install(TARGETS
RUNTIME DESTINATION bin
)

if (BUILD_TESTING)
# Add GTest tests
find_package(ament_cmake_gtest REQUIRED)

ament_add_gtest(${PROJECT_NAME}_inflation_layer_test test/inflation_layer_test.cpp)
target_include_directories(${PROJECT_NAME}_inflation_layer_test PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(${PROJECT_NAME}_inflation_layer_test ${PROJECT_NAME})
endif()

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(mesh_map)
Expand Down
12 changes: 2 additions & 10 deletions mesh_layers/include/mesh_layers/border_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,18 @@ class BorderLayer : public mesh_map::AbstractLayer
*
* @return calculated costmap
*/
virtual lvr2::VertexMap<float>& costs() override;
virtual const lvr2::VertexMap<float>& costs() override;

/**
* @brief deliver set containing all vertices marked as lethal
*
* @return lethal vertices
*/
virtual std::set<lvr2::VertexHandle>& lethals() override
virtual const std::set<lvr2::VertexHandle>& lethals() override
{
return lethal_vertices_;
}

/**
* @brief update set of lethal vertices by adding and removing vertices
*
* @param added_lethal vertices to be marked as lethal
* @param removed_lethal vertices to be removed from the set of lethal vertices
*/
virtual void updateLethal(std::set<lvr2::VertexHandle>& added_lethal, std::set<lvr2::VertexHandle>& removed_lethal) override {};

/**
* @brief initializes this layer plugin
*
Expand Down
12 changes: 2 additions & 10 deletions mesh_layers/include/mesh_layers/clearance_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,18 @@ class ClearanceLayer : public mesh_map::AbstractLayer
*
* @return calculated costmap
*/
virtual lvr2::VertexMap<float>& costs() override;
virtual const lvr2::VertexMap<float>& costs() override;

/**
* @brief deliver set containing all vertices marked as lethal
*
* @return lethal vertices
*/
virtual std::set<lvr2::VertexHandle>& lethals() override
virtual const std::set<lvr2::VertexHandle>& lethals() override
{
return lethal_vertices_;
}

/**
* @brief update set of lethal vertices by adding and removing vertices
*
* @param added_lethal vertices to be marked as lethal
* @param removed_lethal vertices to be removed from the set of lethal vertices
*/
virtual void updateLethal(std::set<lvr2::VertexHandle>& added_lethal, std::set<lvr2::VertexHandle>& removed_lethal) override {};

/**
* @brief initializes this layer plugin
*
Expand Down
128 changes: 128 additions & 0 deletions mesh_layers/include/mesh_layers/combination_layer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
* Copyright 2025, Justus Braun
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* authors:
* Justus Braun <jubraun@uni-osnabrueck.de>
*
*/
#pragma once

#include <mesh_map/abstract_layer.h>
#include <rclcpp/rclcpp.hpp>

namespace mesh_layers
{

class MaxCombinationLayer
: public mesh_map::AbstractLayer
{
public:

bool readLayer() override {return false;}
bool writeLayer() override {return true;}
float defaultValue() override {return 0.0;}
float threshold() override {return 1.0;}
const lvr2::VertexMap<float>& costs() override {return costs_;}
const std::set<lvr2::VertexHandle>& lethals() override {return lethals_;}

/**
* @brief Combines the configured layers
*/
bool computeLayer() override;

/**
* @brief Process a change in a lower layer
*/
virtual void onInputChanged(
const rclcpp::Time& timestamp,
const std::set<lvr2::VertexHandle>& changed
) override;

/**
* @brief Initialize the layer
*/
bool initialize() override;

private:
// Combined costs
lvr2::DenseVertexMap<float> costs_;

// Combined lethal vertices
std::set<lvr2::VertexHandle> lethals_;

// Configured layers; use weak_ptr to prevent shared_ptr cycles
std::vector<std::weak_ptr<mesh_map::AbstractLayer>> inputs_;
};


class CombinationLayer
: public mesh_map::AbstractLayer
{
public:

bool readLayer() override {return false;}
bool writeLayer() override {return true;}
float defaultValue() override {return 0.0;}
float threshold() override {return 1.0;}
lvr2::VertexMap<float>& costs() override {return costs_;}
std::set<lvr2::VertexHandle>& lethals() override {return lethals_;}

/**
* @brief Combines the configured layers
*/
bool computeLayer() override;

/**
* @brief Process a change in a lower layer
*/
virtual void onInputChanged(
const rclcpp::Time& timestamp,
const std::set<lvr2::VertexHandle>& changed
) override;

/**
* @brief Initialize the layer
*/
bool initialize() override;

private:
// Combined costs
lvr2::DenseVertexMap<float> costs_;

// Combined lethal vertices
std::set<lvr2::VertexHandle> lethals_;

// Configured layers; use weak_ptr to prevent shared_ptr cycles
std::vector<std::weak_ptr<mesh_map::AbstractLayer>> inputs_;
};

} // namespace mesh_map
12 changes: 2 additions & 10 deletions mesh_layers/include/mesh_layers/height_diff_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,18 @@ class HeightDiffLayer : public mesh_map::AbstractLayer
*
* @return calculated costmap
*/
virtual lvr2::VertexMap<float>& costs() override;
virtual const lvr2::VertexMap<float>& costs() override;

/**
* @brief deliver set containing all vertices marked as lethal
*
* @return lethal vertices
*/
virtual std::set<lvr2::VertexHandle>& lethals() override
virtual const std::set<lvr2::VertexHandle>& lethals() override
{
return lethal_vertices_;
}

/**
* @brief update set of lethal vertices by adding and removing vertices
*
* @param added_lethal vertices to be marked as lethal
* @param removed_lethal vertices to be removed from the set of lethal vertices
*/
virtual void updateLethal(std::set<lvr2::VertexHandle>& added_lethal, std::set<lvr2::VertexHandle>& removed_lethal) override {};

/**
* @brief initializes this layer plugin
*
Expand Down
Loading