Skip to content

Commit e392242

Browse files
authored
Bug fixes and improvements (#11)
1 parent 6fea544 commit e392242

31 files changed

+639
-707
lines changed

roadmap_explorer/CMakeLists.txt

Lines changed: 87 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ set(dependencies
5353
roadmap_explorer_msgs
5454
eigen3_cmake_module
5555
Eigen3
56-
yaml-cpp
5756
nav2_behavior_tree
5857
)
5958

@@ -82,14 +81,12 @@ include_directories(
8281
${YAML_CPP_INCLUDE_DIRS}
8382
)
8483

85-
########################### FRONTIER ###########################
84+
########################### Libraries ###########################
8685
add_library(${PROJECT_NAME}_frontier SHARED
8786
src/Frontier.cpp)
8887
ament_target_dependencies(${PROJECT_NAME}_frontier ${dependencies})
8988

9089

91-
########################### UTILS ###########################
92-
9390
add_library(${PROJECT_NAME}_utils SHARED
9491
src/util/EventLogger.cpp
9592
src/util/RosVisualizer.cpp
@@ -98,32 +95,20 @@ src/Helpers.cpp
9895
ament_target_dependencies(${PROJECT_NAME}_utils ${dependencies})
9996
target_link_libraries(${PROJECT_NAME}_utils ${PROJECT_NAME}_frontier)
10097

101-
########################### PLUGINLIB LIBRARIES ###########################
10298

103-
add_library(roadmap_explorer_bt_plugins SHARED
104-
src/bt_plugins/LogIterationPlugin.cpp
105-
src/bt_plugins/UpdateBoundaryPlugin.cpp
106-
src/bt_plugins/SearchForFrontiersPlugin.cpp
107-
src/bt_plugins/CleanupRoadmapPlugin.cpp
108-
src/bt_plugins/UpdateRoadmapPlugin.cpp
109-
src/bt_plugins/ProcessFrontierCostsPlugin.cpp
110-
src/bt_plugins/OptimizeFullPathPlugin.cpp
111-
src/bt_plugins/SendNav2GoalPlugin.cpp
112-
src/bt_plugins/BlacklistGoalPlugin.cpp
99+
add_library(${PROJECT_NAME}_frontier_search_plugins SHARED
100+
src/frontier_search/PluginBFSearch.cpp
113101
)
114-
ament_target_dependencies(roadmap_explorer_bt_plugins ${dependencies})
115-
target_link_libraries(roadmap_explorer_bt_plugins ${PROJECT_NAME}_frontier ${PROJECT_NAME}_utils)
102+
ament_target_dependencies(${PROJECT_NAME}_frontier_search_plugins ${dependencies})
116103

117-
##############
118104

119-
add_library(roadmap_explorer_frontier_search_plugins SHARED
120-
src/frontier_search/PluginBFSearch.cpp
105+
add_library(${PROJECT_NAME}_information_gain_plugins SHARED
106+
src/information_gain/CountBasedGain.cpp
121107
)
122-
ament_target_dependencies(roadmap_explorer_frontier_search_plugins ${dependencies})
108+
ament_target_dependencies(${PROJECT_NAME}_information_gain_plugins ${dependencies})
123109

124-
##############
125110

126-
add_library(roadmap_explorer_planner_plugins SHARED
111+
add_library(${PROJECT_NAME}_planner_plugins SHARED
127112
src/planners/ThetaStar.cpp
128113
src/planners/Astar.cpp
129114
src/planners/NavFn.cpp
@@ -133,52 +118,96 @@ src/planners/FrontierRoadmapPlugin.cpp
133118
src/planners/EuclideanPlugin.cpp
134119
src/planners/RandomDistancePlugin.cpp
135120
)
136-
ament_target_dependencies(roadmap_explorer_planner_plugins ${dependencies})
121+
ament_target_dependencies(${PROJECT_NAME}_planner_plugins ${dependencies})
137122

138-
##############
139123

140-
add_library(roadmap_explorer_information_gain_plugins SHARED
141-
src/information_gain/CountBasedGain.cpp
124+
add_library(${PROJECT_NAME}_core SHARED
125+
src/CostAssigner.cpp
126+
src/Parameters.cpp
127+
src/Nav2Interface.cpp
128+
src/FullPathOptimizer.cpp
129+
src/SensorSimulator.cpp
130+
)
131+
ament_target_dependencies(${PROJECT_NAME}_core ${dependencies})
132+
target_link_libraries(${PROJECT_NAME}_core
133+
${PCL_LIBRARIES}
134+
${PROJECT_NAME}_frontier
135+
${PROJECT_NAME}_utils
136+
${PROJECT_NAME}_frontier_search_plugins
137+
${PROJECT_NAME}_planner_plugins
138+
${PROJECT_NAME}_information_gain_plugins
142139
)
143-
ament_target_dependencies(roadmap_explorer_information_gain_plugins ${dependencies})
144140

145141

146-
########################### CORE LIBRARY ###########################
142+
add_library(${PROJECT_NAME}_bt_plugins SHARED
143+
src/bt_plugins/LogIterationPlugin.cpp
144+
src/bt_plugins/UpdateBoundaryPlugin.cpp
145+
src/bt_plugins/SearchForFrontiersPlugin.cpp
146+
src/bt_plugins/CleanupRoadmapPlugin.cpp
147+
src/bt_plugins/UpdateRoadmapPlugin.cpp
148+
src/bt_plugins/ProcessFrontierCostsPlugin.cpp
149+
src/bt_plugins/OptimizeFullPathPlugin.cpp
150+
src/bt_plugins/SendNav2GoalPlugin.cpp
151+
src/bt_plugins/BlacklistGoalPlugin.cpp
152+
)
153+
ament_target_dependencies(${PROJECT_NAME}_bt_plugins ${dependencies})
154+
target_link_libraries(${PROJECT_NAME}_bt_plugins
155+
${PROJECT_NAME}_frontier
156+
${PROJECT_NAME}_utils
157+
${PROJECT_NAME}_frontier_search_plugins
158+
${PROJECT_NAME}_planner_plugins
159+
${PROJECT_NAME}_information_gain_plugins
160+
)
147161

148-
add_library(roadmap_exploration_bt SHARED
149-
src/Parameters.cpp
150-
src/Nav2Interface.cpp
162+
163+
add_library(${PROJECT_NAME}_bt SHARED
151164
src/ExplorationBT.cpp
152-
src/CostAssigner.cpp
153-
src/FullPathOptimizer.cpp
154165
src/ExplorationServer.cpp
155-
src/SensorSimulator.cpp
156166
)
157-
ament_target_dependencies(roadmap_exploration_bt ${dependencies})
158-
target_link_libraries(roadmap_exploration_bt ${PCL_LIBRARIES} ${YAML_CPP_LIBRARIES} ${PROJECT_NAME}_frontier ${PROJECT_NAME}_utils roadmap_explorer_bt_plugins roadmap_explorer_frontier_search_plugins roadmap_explorer_planner_plugins roadmap_explorer_information_gain_plugins)
167+
ament_target_dependencies(${PROJECT_NAME}_bt ${dependencies})
168+
target_link_libraries(${PROJECT_NAME}_bt
169+
${PROJECT_NAME}_bt_plugins
170+
${PROJECT_NAME}_frontier
171+
${PROJECT_NAME}_utils
172+
${PROJECT_NAME}_frontier_search_plugins
173+
${PROJECT_NAME}_planner_plugins
174+
${PROJECT_NAME}_information_gain_plugins
175+
${PROJECT_NAME}_core
176+
)
159177

160-
rclcpp_components_register_nodes(roadmap_exploration_bt "roadmap_exploration::ExplorationServer")
178+
rclcpp_components_register_nodes(${PROJECT_NAME}_bt "roadmap_exploration::ExplorationServer")
161179

162-
########################### EXECUTABLES ###########################
180+
# ########################### EXECUTABLES ###########################
163181
add_executable(roadmap_exploration_server
164182
src/main.cpp
165183
)
166184
ament_target_dependencies(roadmap_exploration_server ${dependencies})
167-
target_link_libraries(roadmap_exploration_server ${PCL_LIBRARIES} ${YAML_CPP_LIBRARIES} ${PROJECT_NAME}_frontier roadmap_exploration_bt ${PROJECT_NAME}_utils roadmap_explorer_bt_plugins roadmap_explorer_frontier_search_plugins roadmap_explorer_planner_plugins roadmap_explorer_information_gain_plugins)
185+
target_link_libraries(roadmap_exploration_server
186+
${PCL_LIBRARIES}
187+
${PROJECT_NAME}_frontier
188+
${PROJECT_NAME}_bt
189+
${PROJECT_NAME}_utils
190+
${PROJECT_NAME}_bt_plugins
191+
${PROJECT_NAME}_frontier_search_plugins
192+
${PROJECT_NAME}_planner_plugins
193+
${PROJECT_NAME}_information_gain_plugins
194+
${PROJECT_NAME}_core
195+
)
168196

169197
########################### COMPARISON SCRIPTS ###########################
170198
add_subdirectory(comparision_scripts)
171199

172200
########################### INSTALLATION ###########################
173201

174202
install(TARGETS
175-
roadmap_exploration_bt
176203
${PROJECT_NAME}_frontier
177204
${PROJECT_NAME}_utils
178-
roadmap_explorer_bt_plugins
179-
roadmap_explorer_frontier_search_plugins
180-
roadmap_explorer_planner_plugins
181-
roadmap_explorer_information_gain_plugins
205+
${PROJECT_NAME}_frontier_search_plugins
206+
${PROJECT_NAME}_information_gain_plugins
207+
${PROJECT_NAME}_planner_plugins
208+
${PROJECT_NAME}_core
209+
${PROJECT_NAME}_bt_plugins
210+
${PROJECT_NAME}_bt
182211
ARCHIVE DESTINATION lib
183212
LIBRARY DESTINATION lib
184213
RUNTIME DESTINATION bin
@@ -197,7 +226,16 @@ DESTINATION share/${PROJECT_NAME}
197226
)
198227

199228
ament_export_include_directories(include ${EIGEN3_INCLUDE_DIR})
200-
ament_export_libraries(roadmap_exploration_bt ${PROJECT_NAME}_frontier ${PROJECT_NAME}_utils roadmap_explorer_bt_plugins roadmap_explorer_frontier_search_plugins roadmap_explorer_planner_plugins roadmap_explorer_information_gain_plugins)
229+
ament_export_libraries(
230+
${PROJECT_NAME}_frontier
231+
${PROJECT_NAME}_utils
232+
${PROJECT_NAME}_frontier_search_plugins
233+
${PROJECT_NAME}_information_gain_plugins
234+
${PROJECT_NAME}_planner_plugins
235+
${PROJECT_NAME}_core
236+
${PROJECT_NAME}_bt_plugins
237+
${PROJECT_NAME}_bt
238+
)
201239
ament_export_dependencies(rosidl_default_runtime ${dependencies})
202240

203241
install(FILES core_plugins_description.xml frontier_search_plugins.xml frontier_planner_plugins.xml
@@ -213,9 +251,9 @@ find_package(ament_cmake_gtest QUIET)
213251
if(ament_cmake_gtest_FOUND)
214252
add_subdirectory(tests/utils)
215253
# add_subdirectory(tests/bt_plugins)
216-
add_subdirectory(tests/frontier_search)
217-
add_subdirectory(tests/information_gain)
218-
add_subdirectory(tests/other_tests)
254+
# add_subdirectory(tests/frontier_search)
255+
# add_subdirectory(tests/information_gain)
256+
# add_subdirectory(tests/other_tests)
219257
endif()
220258

221259
ament_package()

roadmap_explorer/include/roadmap_explorer/CostAssigner.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <tf2_ros/buffer.h>
2929
#include <tf2/LinearMath/Quaternion.h>
3030

31+
#include <pluginlib/class_loader.hpp>
32+
3133
#include "roadmap_explorer/util/Logger.hpp"
3234
#include "roadmap_explorer/util/RosVisualizer.hpp"
3335
#include "roadmap_explorer/util/EventLogger.hpp"
@@ -52,7 +54,7 @@ struct CalculateFrontierCostsRequest
5254
class CostAssigner
5355
{
5456
public:
55-
CostAssigner(std::shared_ptr<nav2_costmap_2d::Costmap2DROS> explore_costmap_ros);
57+
CostAssigner(std::shared_ptr<nav2_costmap_2d::Costmap2DROS> explore_costmap_ros, std::shared_ptr<nav2_util::LifecycleNode> node);
5658

5759
~CostAssigner();
5860

@@ -69,9 +71,7 @@ class CostAssigner
6971

7072
void recomputeNormalizationFactors(FrontierPtr & frontier);
7173

72-
std::vector<FrontierPtr> findDuplicates(const std::vector<FrontierPtr> & vec);
73-
74-
void initializePlugins(const std::string & informationGainPlugin, const std::string & plannerPlugin);
74+
void initializePlugins();
7575

7676
void processFrontier(FrontierPtr & frontier,
7777
const geometry_msgs::msg::Pose & start_pose_w);
@@ -84,6 +84,7 @@ class CostAssigner
8484
nav2_costmap_2d::LayeredCostmap * layered_costmap_;
8585
nav2_costmap_2d::Costmap2D * costmap_;
8686
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> explore_costmap_ros_;
87+
std::shared_ptr<nav2_util::LifecycleNode> node_;
8788

8889
// map of blacklists with hash map and equality which only considers goal point
8990
std::unordered_map<FrontierPtr, bool, FrontierHash,
@@ -93,10 +94,16 @@ class CostAssigner
9394
double min_traversable_distance = std::numeric_limits<double>::max();
9495
double max_traversable_distance = -1.0 * std::numeric_limits<double>::max();
9596
std::shared_ptr<BasePlanner> planner_plugin_;
97+
std::shared_ptr<pluginlib::ClassLoader<BasePlanner>> planner_loader_;
98+
std::string planner_plugin_name_;
99+
std::string planner_plugin_type_;
96100

97101
double min_arrival_info_per_frontier = std::numeric_limits<double>::max();
98102
double max_arrival_info_per_frontier = -1.0 * std::numeric_limits<double>::max();
99103
std::shared_ptr<BaseInformationGain> information_gain_plugin_;
104+
std::shared_ptr<pluginlib::ClassLoader<BaseInformationGain>> information_gain_loader_;
105+
std::string information_gain_plugin_name_;
106+
std::string information_gain_plugin_type_;
100107

101108
};
102109
}

roadmap_explorer/include/roadmap_explorer/ExplorationBT.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ class RoadmapExplorationBT
8181

8282
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> explore_costmap_ros_;
8383
std::unique_ptr<nav2_util::NodeThread> explore_costmap_thread_;
84+
85+
std::shared_ptr<pluginlib::ClassLoader<FrontierSearchBase>> frontier_search_loader_;
86+
std::shared_ptr<pluginlib::ClassLoader<roadmap_explorer::BTPlugin>> bt_plugin_loader_;
8487
};
8588
}
8689

roadmap_explorer/include/roadmap_explorer/Parameters.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ParameterHandler
3636
}
3737
}
3838

39-
void makeParameters(bool use_ros_parameters, std::shared_ptr<nav2_util::LifecycleNode> node);
39+
void makeParameters(std::shared_ptr<nav2_util::LifecycleNode> node);
4040

4141
static void createInstance()
4242
{
@@ -72,10 +72,6 @@ class ParameterHandler
7272
}
7373

7474
private:
75-
void makeParametersROS(std::shared_ptr<nav2_util::LifecycleNode> node);
76-
77-
void makeParametersYAMLcpp();
78-
7975
void sanityCheckParameters();
8076

8177
rcl_interfaces::msg::SetParametersResult dynamicReconfigureCallback(

roadmap_explorer/include/roadmap_explorer/frontier_search/BaseFrontierSearch.hpp

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <memory>
66

77
#include <rclcpp/rclcpp.hpp>
8-
#include <nav2_costmap_2d/costmap_2d.hpp>
8+
#include <nav2_costmap_2d/costmap_2d_ros.hpp>
99
#include <geometry_msgs/msg/point.hpp>
1010

1111
#include "roadmap_explorer/Frontier.hpp"
@@ -20,12 +20,13 @@ enum class FrontierSearchResult
2020
{
2121
ROBOT_OUT_OF_BOUNDS = 0, ///< Robot position is outside the costmap bounds
2222
CANNOT_FIND_CELL_TO_SEARCH = 1, ///< No valid cells found to start the search
23-
SUCCESSFUL_SEARCH = 2 ///< Search completed successfully
23+
SUCCESSFUL_SEARCH = 2, ///< Search completed successfully
24+
NO_FRONTIERS_FOUND = 3
2425
};
2526

2627
/**
2728
* @brief Base class for frontier search algorithms
28-
*
29+
*
2930
* This abstract base class defines the interface that all frontier search
3031
* algorithms must implement. It provides a plugin-based architecture for
3132
* different frontier detection strategies.
@@ -46,41 +47,27 @@ class FrontierSearchBase
4647
/**
4748
* @brief Configure the frontier search with a costmap
4849
* @param costmap Pointer to the costmap for frontier detection.
50+
* @param node Shared pointer to the lifecycle node for parameter management
4951
*/
50-
virtual void configure(nav2_costmap_2d::Costmap2D * costmap) = 0;
52+
virtual void configure(std::shared_ptr<nav2_costmap_2d::Costmap2DROS> explore_costmap_ros, std::string name, std::shared_ptr<nav2_util::LifecycleNode> node) = 0;
5153

5254
/**
5355
* @brief Reset the frontier search state
54-
*
56+
*
5557
* Clears any internal state or cached data from previous searches.
5658
*/
5759
virtual void reset() = 0;
5860

59-
/**
60-
* @brief Set the frontier search distance to a given value
61-
* @param value The new search distance value
62-
* @return true if the distance was set successfully, false if the value exceeds maximum allowed distance
63-
*/
64-
virtual bool setFrontierSearchDistance(double value) = 0;
65-
66-
/**
67-
* @brief Get the current frontier search distance
68-
* @return Current search distance
69-
*/
70-
virtual double getFrontierSearchDistance() const
71-
{
72-
return frontier_search_distance_;
73-
}
74-
7561
/**
7662
* @brief Search for frontiers from a given position
7763
* @param position The starting position for the search in world coordinates
78-
* @param output_frontier_list Output vector to store found frontiers (will be cleared and populated)
64+
* @param output_frontier_list Output vector to store found "clustered" frontiers (will be cleared and populated)
7965
* @return Result of the search operation indicating success or failure reason
8066
*/
8167
virtual FrontierSearchResult searchFrom(
8268
geometry_msgs::msg::Point position,
83-
std::vector<FrontierPtr> & output_frontier_list) = 0;
69+
std::vector<FrontierPtr> & output_frontier_list,
70+
double max_frontier_search_distance) = 0;
8471

8572
/**
8673
* @brief Get all frontiers found in the last search operation
@@ -90,9 +77,8 @@ class FrontierSearchBase
9077
virtual std::vector<std::vector<double>> getAllFrontiers() = 0;
9178

9279
protected:
93-
double frontier_search_distance_; ///< Maximum distance to search for frontiers from the robot position
94-
95-
nav2_costmap_2d::Costmap2D * costmap_ = nullptr; ///< Pointer to the costmap used for frontier detection
80+
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> explore_costmap_ros_ = nullptr; ///< Pointer to the costmap used for frontier detection
81+
std::shared_ptr<nav2_util::LifecycleNode> node_ = nullptr; ///< Shared pointer to the lifecycle node
9682
};
9783

9884
} // namespace roadmap_explorer

0 commit comments

Comments
 (0)