Skip to content

Commit 72badc7

Browse files
authored
Fix compilation of nav2_smac_planner on Windows
1 parent 829e683 commit 72badc7

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

nav2_smac_planner/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,17 @@ add_library(${library_name}_common SHARED
4242
src/node_lattice.cpp
4343
src/smoother.cpp
4444
)
45+
# Add GenerateExportHeader support for symbol visibility, as we are using
46+
# static members we need to explicitly export them on Windows, as
47+
# CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS does not work with static members.
48+
include(GenerateExportHeader)
49+
generate_export_header(${library_name}_common
50+
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/${library_name}_common_visibility_control.hpp"
51+
)
4552
target_include_directories(${library_name}_common
4653
PUBLIC
4754
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
55+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
4856
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>"
4957
${OMPL_INCLUDE_DIRS}
5058
)
@@ -167,6 +175,10 @@ install(TARGETS ${library_name}_common ${library_name} ${library_name}_2d ${libr
167175
install(DIRECTORY include/
168176
DESTINATION include/${PROJECT_NAME}
169177
)
178+
install(FILES
179+
"${CMAKE_CURRENT_BINARY_DIR}/include/${PROJECT_NAME}/${library_name}_common_visibility_control.hpp"
180+
DESTINATION include/${PROJECT_NAME}
181+
)
170182

171183
install(DIRECTORY lattice_primitives/sample_primitives DESTINATION share/${PROJECT_NAME})
172184

nav2_smac_planner/include/nav2_smac_planner/node_hybrid.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "nav2_smac_planner/types.hpp"
2727
#include "nav2_smac_planner/collision_checker.hpp"
2828
#include "nav2_smac_planner/costmap_downsampler.hpp"
29+
#include "nav2_smac_planner/nav2_smac_planner_common_visibility_control.hpp"
2930
#include "nav2_costmap_2d/costmap_2d_ros.hpp"
3031
#include "nav2_costmap_2d/inflation_layer.hpp"
3132

@@ -473,16 +474,16 @@ class NodeHybrid
473474
Coordinates pose;
474475

475476
// Constants required across all nodes but don't want to allocate more than once
476-
static float travel_distance_cost;
477-
static HybridMotionTable motion_table;
477+
NAV2_SMAC_PLANNER_COMMON_EXPORT static float travel_distance_cost;
478+
NAV2_SMAC_PLANNER_COMMON_EXPORT static HybridMotionTable motion_table;
478479
// Wavefront lookup and queue for continuing to expand as needed
479-
static LookupTable obstacle_heuristic_lookup_table;
480-
static ObstacleHeuristicQueue obstacle_heuristic_queue;
480+
NAV2_SMAC_PLANNER_COMMON_EXPORT static LookupTable obstacle_heuristic_lookup_table;
481+
NAV2_SMAC_PLANNER_COMMON_EXPORT static ObstacleHeuristicQueue obstacle_heuristic_queue;
481482

482-
static std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros;
483+
NAV2_SMAC_PLANNER_COMMON_EXPORT static std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmap_ros;
483484
// Dubin / Reeds-Shepp lookup and size for dereferencing
484-
static LookupTable dist_heuristic_lookup_table;
485-
static float size_lookup;
485+
NAV2_SMAC_PLANNER_COMMON_EXPORT static LookupTable dist_heuristic_lookup_table;
486+
NAV2_SMAC_PLANNER_COMMON_EXPORT static float size_lookup;
486487

487488
private:
488489
float _cell_cost;

nav2_smac_planner/include/nav2_smac_planner/node_lattice.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "nav2_smac_planner/collision_checker.hpp"
2828
#include "nav2_smac_planner/node_hybrid.hpp"
2929
#include "nav2_smac_planner/utils.hpp"
30+
#include "nav2_smac_planner/nav2_smac_planner_common_visibility_control.hpp"
3031

3132
namespace nav2_smac_planner
3233
{
@@ -415,10 +416,10 @@ class NodeLattice
415416

416417
NodeLattice * parent;
417418
Coordinates pose;
418-
static LatticeMotionTable motion_table;
419+
NAV2_SMAC_PLANNER_COMMON_EXPORT static LatticeMotionTable motion_table;
419420
// Dubin / Reeds-Shepp lookup and size for dereferencing
420-
static LookupTable dist_heuristic_lookup_table;
421-
static float size_lookup;
421+
NAV2_SMAC_PLANNER_COMMON_EXPORT static LookupTable dist_heuristic_lookup_table;
422+
NAV2_SMAC_PLANNER_COMMON_EXPORT static float size_lookup;
422423

423424
private:
424425
float _cell_cost;

0 commit comments

Comments
 (0)