Skip to content

Commit cc5351a

Browse files
authored
Add search helper for goal angle tolerance (#317)
1 parent e9519ed commit cc5351a

15 files changed

+1684
-138
lines changed

mbf_costmap_nav/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
cmake_minimum_required(VERSION 3.0.2)
22
project(mbf_costmap_nav)
33

4+
set(CMAKE_CXX_STANDARD 17)
5+
46
find_package(catkin REQUIRED
57
COMPONENTS
68
costmap_2d
@@ -76,6 +78,8 @@ add_library(${MBF_COSTMAP_2D_SERVER_LIB}
7678
src/mbf_costmap_nav/costmap_recovery_execution.cpp
7779
src/mbf_costmap_nav/costmap_wrapper.cpp
7880
src/mbf_costmap_nav/footprint_helper.cpp
81+
src/mbf_costmap_nav/free_pose_search.cpp
82+
src/mbf_costmap_nav/free_pose_search_viz.cpp
7983
)
8084
add_dependencies(${MBF_COSTMAP_2D_SERVER_LIB} ${catkin_EXPORTED_TARGETS})
8185
add_dependencies(${MBF_COSTMAP_2D_SERVER_LIB} ${MBF_NAV_CORE_WRAPPER_LIB})
@@ -108,3 +112,20 @@ install(DIRECTORY include/${PROJECT_NAME}/
108112
catkin_install_python(PROGRAMS scripts/move_base_legacy_relay.py
109113
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
110114
)
115+
116+
#############
117+
## Test ##
118+
#############
119+
120+
if(CATKIN_ENABLE_TESTING)
121+
find_package(rostest REQUIRED)
122+
find_package(map_server REQUIRED)
123+
124+
add_rostest_gtest(free_pose_search_test
125+
test/free_pose_search.test
126+
test/free_pose_search_test.cpp
127+
)
128+
target_link_libraries(free_pose_search_test
129+
${MBF_COSTMAP_2D_SERVER_LIB}
130+
)
131+
endif()

mbf_costmap_nav/include/mbf_costmap_nav/costmap_navigation_server.h

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <mbf_msgs/CheckPath.h>
4848
#include <mbf_msgs/CheckPose.h>
4949
#include <mbf_msgs/CheckPoint.h>
50+
#include <mbf_msgs/FindValidPose.h>
5051

5152
#include <nav_core/base_global_planner.h>
5253
#include <nav_core/base_local_planner.h>
@@ -71,8 +72,8 @@ namespace mbf_costmap_nav
7172
* @brief Classes belonging to the Move Base Server level.
7273
*/
7374

74-
75-
typedef boost::shared_ptr<dynamic_reconfigure::Server<mbf_costmap_nav::MoveBaseFlexConfig> > DynamicReconfigureServerCostmapNav;
75+
typedef boost::shared_ptr<dynamic_reconfigure::Server<mbf_costmap_nav::MoveBaseFlexConfig> >
76+
DynamicReconfigureServerCostmapNav;
7677

7778
/// @brief A mapping from a string to a map-ptr.
7879
typedef boost::unordered_map<std::string, CostmapWrapper::Ptr> StringToMap;
@@ -88,14 +89,13 @@ typedef boost::unordered_map<std::string, CostmapWrapper::Ptr> StringToMap;
8889
class CostmapNavigationServer : public mbf_abstract_nav::AbstractNavigationServer
8990
{
9091
public:
91-
9292
typedef boost::shared_ptr<CostmapNavigationServer> Ptr;
9393

9494
/**
9595
* @brief Constructor
9696
* @param tf_listener_ptr Shared pointer to a common TransformListener
9797
*/
98-
CostmapNavigationServer(const TFPtr &tf_listener_ptr);
98+
CostmapNavigationServer(const TFPtr& tf_listener_ptr);
9999

100100
/**
101101
* @brief Destructor
@@ -105,62 +105,56 @@ class CostmapNavigationServer : public mbf_abstract_nav::AbstractNavigationServe
105105
virtual void stop();
106106

107107
private:
108-
109108
/**
110109
* @brief Create a new planner execution.
111110
* @param plugin_name Name of the planner to use.
112111
* @param plugin_ptr Shared pointer to the plugin to use.
113112
* @return Shared pointer to a new @ref planner_execution "PlannerExecution".
114113
*/
115-
virtual mbf_abstract_nav::AbstractPlannerExecution::Ptr newPlannerExecution(
116-
const std::string &plugin_name,
117-
const mbf_abstract_core::AbstractPlanner::Ptr &plugin_ptr);
114+
virtual mbf_abstract_nav::AbstractPlannerExecution::Ptr
115+
newPlannerExecution(const std::string& plugin_name, const mbf_abstract_core::AbstractPlanner::Ptr& plugin_ptr);
118116

119117
/**
120118
* @brief Create a new controller execution.
121119
* @param plugin_name Name of the controller to use.
122120
* @param plugin_ptr Shared pointer to the plugin to use.
123121
* @return Shared pointer to a new @ref controller_execution "ControllerExecution".
124122
*/
125-
virtual mbf_abstract_nav::AbstractControllerExecution::Ptr newControllerExecution(
126-
const std::string &plugin_name,
127-
const mbf_abstract_core::AbstractController::Ptr &plugin_ptr);
123+
virtual mbf_abstract_nav::AbstractControllerExecution::Ptr
124+
newControllerExecution(const std::string& plugin_name, const mbf_abstract_core::AbstractController::Ptr& plugin_ptr);
128125

129126
/**
130127
* @brief Create a new recovery behavior execution.
131128
* @param plugin_name Name of the recovery behavior to run.
132129
* @param plugin_ptr Shared pointer to the plugin to use
133130
* @return Shared pointer to a new @ref recovery_execution "RecoveryExecution".
134131
*/
135-
virtual mbf_abstract_nav::AbstractRecoveryExecution::Ptr newRecoveryExecution(
136-
const std::string &plugin_name,
137-
const mbf_abstract_core::AbstractRecovery::Ptr &plugin_ptr);
132+
virtual mbf_abstract_nav::AbstractRecoveryExecution::Ptr
133+
newRecoveryExecution(const std::string& plugin_name, const mbf_abstract_core::AbstractRecovery::Ptr& plugin_ptr);
138134

139135
/**
140136
* @brief Loads the plugin associated with the given planner_type parameter.
141137
* @param planner_type The type of the planner plugin to load.
142138
* @return true, if the local planner plugin was successfully loaded.
143139
*/
144-
virtual mbf_abstract_core::AbstractPlanner::Ptr loadPlannerPlugin(const std::string &planner_type);
140+
virtual mbf_abstract_core::AbstractPlanner::Ptr loadPlannerPlugin(const std::string& planner_type);
145141

146142
/**
147143
* @brief Initializes the controller plugin with its name and pointer to the costmap
148144
* @param name The name of the planner
149145
* @param planner_ptr pointer to the planner object which corresponds to the name param
150146
* @return true if init succeeded, false otherwise
151147
*/
152-
virtual bool initializePlannerPlugin(
153-
const std::string &name,
154-
const mbf_abstract_core::AbstractPlanner::Ptr &planner_ptr
155-
);
148+
virtual bool initializePlannerPlugin(const std::string& name,
149+
const mbf_abstract_core::AbstractPlanner::Ptr& planner_ptr);
156150

157151
/**
158152
* @brief Loads the plugin associated with the given controller type parameter
159153
* @param controller_type The type of the controller plugin
160154
* @return A shared pointer to a new loaded controller, if the controller plugin was loaded successfully,
161155
* an empty pointer otherwise.
162156
*/
163-
virtual mbf_abstract_core::AbstractController::Ptr loadControllerPlugin(const std::string &controller_type);
157+
virtual mbf_abstract_core::AbstractController::Ptr loadControllerPlugin(const std::string& controller_type);
164158

165159
/**
166160
* @brief Initializes the controller plugin with its name, a pointer to the TransformListener
@@ -169,69 +163,82 @@ class CostmapNavigationServer : public mbf_abstract_nav::AbstractNavigationServe
169163
* @param controller_ptr pointer to the controller object which corresponds to the name param
170164
* @return true if init succeeded, false otherwise
171165
*/
172-
virtual bool initializeControllerPlugin(
173-
const std::string &name,
174-
const mbf_abstract_core::AbstractController::Ptr &controller_ptr
175-
);
166+
virtual bool initializeControllerPlugin(const std::string& name,
167+
const mbf_abstract_core::AbstractController::Ptr& controller_ptr);
176168

177169
/**
178170
* @brief Loads a Recovery plugin associated with given recovery type parameter
179171
* @param recovery_name The name of the Recovery plugin
180172
* @return A shared pointer to a Recovery plugin, if the plugin was loaded successfully, an empty pointer otherwise.
181173
*/
182-
virtual mbf_abstract_core::AbstractRecovery::Ptr loadRecoveryPlugin(const std::string &recovery_type);
174+
virtual mbf_abstract_core::AbstractRecovery::Ptr loadRecoveryPlugin(const std::string& recovery_type);
183175

184176
/**
185177
* @brief Initializes a recovery behavior plugin with its name and pointers to the global and local costmaps
186178
* @param name The name of the recovery behavior
187179
* @param behavior_ptr pointer to the recovery behavior object which corresponds to the name param
188180
* @return true if init succeeded, false otherwise
189181
*/
190-
virtual bool initializeRecoveryPlugin(
191-
const std::string &name,
192-
const mbf_abstract_core::AbstractRecovery::Ptr &behavior_ptr);
182+
virtual bool initializeRecoveryPlugin(const std::string& name,
183+
const mbf_abstract_core::AbstractRecovery::Ptr& behavior_ptr);
184+
185+
/**
186+
* @brief If mbf_msgs::CheckPose::Request::LOCAL_COSTMAP the local costmap is returned
187+
* if mbf_msgs::CheckPose::Request::GLOBAL_COSTMAP, the global costmap is returned.
188+
* Otherwise, it returns an empty pointer.
189+
* @param costmap_type The type of the costmap to return
190+
* @return A pair: string which is the type of the costmap; and the shared pointer to the requested costmap.
191+
* If costmap is not valid, it returns an empty pointer and an empty string.
192+
*/
193+
std::pair<std::string, CostmapWrapper::Ptr>
194+
requestedCostmap(mbf_msgs::CheckPose::Request::_costmap_type costmap_type) const;
193195

194196
/**
195197
* @brief Callback method for the check_point_cost service
196198
* @param request Request object, see the mbf_msgs/CheckPoint service definition file.
197199
* @param response Response object, see the mbf_msgs/CheckPoint service definition file.
198200
* @return true, if the service completed successfully, false otherwise
199201
*/
200-
bool callServiceCheckPointCost(mbf_msgs::CheckPoint::Request &request,
201-
mbf_msgs::CheckPoint::Response &response);
202+
bool callServiceCheckPointCost(mbf_msgs::CheckPoint::Request& request, mbf_msgs::CheckPoint::Response& response);
202203

203204
/**
204205
* @brief Callback method for the check_pose_cost service
205206
* @param request Request object, see the mbf_msgs/CheckPose service definition file.
206207
* @param response Response object, see the mbf_msgs/CheckPose service definition file.
207208
* @return true, if the service completed successfully, false otherwise
208209
*/
209-
bool callServiceCheckPoseCost(mbf_msgs::CheckPose::Request &request,
210-
mbf_msgs::CheckPose::Response &response);
210+
bool callServiceCheckPoseCost(mbf_msgs::CheckPose::Request& request, mbf_msgs::CheckPose::Response& response);
211211

212212
/**
213213
* @brief Callback method for the check_path_cost service
214214
* @param request Request object, see the mbf_msgs/CheckPath service definition file.
215215
* @param response Response object, see the mbf_msgs/CheckPath service definition file.
216216
* @return true, if the service completed successfully, false otherwise
217217
*/
218-
bool callServiceCheckPathCost(mbf_msgs::CheckPath::Request &request,
219-
mbf_msgs::CheckPath::Response &response);
218+
bool callServiceCheckPathCost(mbf_msgs::CheckPath::Request& request, mbf_msgs::CheckPath::Response& response);
220219

221220
/**
222221
* @brief Callback method for the make_plan service
223222
* @param request Empty request object.
224223
* @param response Empty response object.
225224
* @return true, if the service completed successfully, false otherwise
226225
*/
227-
bool callServiceClearCostmaps(std_srvs::Empty::Request &request, std_srvs::Empty::Response &response);
226+
bool callServiceClearCostmaps(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response);
227+
228+
/**
229+
* @brief Callback method for the find valid pose service
230+
* @param request FindValidPose request object.
231+
* @param response FindValidPose response object.
232+
* @return true, if the service completed successfully, false otherwise
233+
*/
234+
bool callServiceFindValidPose(mbf_msgs::FindValidPose::Request& request, mbf_msgs::FindValidPose::Response& response);
228235

229236
/**
230237
* @brief Reconfiguration method called by dynamic reconfigure.
231238
* @param config Configuration parameters. See the MoveBaseFlexConfig definition.
232239
* @param level bit mask, which parameters are set.
233240
*/
234-
void reconfigure(mbf_costmap_nav::MoveBaseFlexConfig &config, uint32_t level);
241+
void reconfigure(mbf_costmap_nav::MoveBaseFlexConfig& config, uint32_t level);
235242

236243
pluginlib::ClassLoader<mbf_costmap_core::CostmapRecovery> recovery_plugin_loader_;
237244
pluginlib::ClassLoader<nav_core::RecoveryBehavior> nav_core_recovery_plugin_loader_;
@@ -275,6 +282,11 @@ class CostmapNavigationServer : public mbf_abstract_nav::AbstractNavigationServe
275282

276283
//! Service Server for the clear_costmap service
277284
ros::ServiceServer clear_costmaps_srv_;
285+
286+
//! Service Server for the find_valid_pose service
287+
ros::ServiceServer find_valid_pose_srv_;
288+
289+
static constexpr double ANGLE_INCREMENT = 5.0 * M_PI / 180.0; // 5 degrees
278290
};
279291

280292
} /* namespace mbf_costmap_nav */

mbf_costmap_nav/include/mbf_costmap_nav/footprint_helper.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace mbf_costmap_nav
4848

4949
struct Cell
5050
{
51-
unsigned int x, y;
51+
unsigned int x, y, cost;
5252
};
5353

5454
class FootprintHelper
@@ -66,6 +66,17 @@ class FootprintHelper
6666
const std::vector<geometry_msgs::Point>& footprint_spec,
6767
const costmap_2d::Costmap2D&, bool fill);
6868

69+
/**
70+
* @brief Supercover algorithm is a modified Bresenham which prints ALL the points (not only one point per axis) the ideal line contains
71+
* ref: http://eugen.dedu.free.fr/projects/bresenham/
72+
* @param x0 The x coordinate of the first point
73+
* @param x1 The x coordinate of the second point
74+
* @param y0 The y coordinate of the first point
75+
* @param y1 The y coordinate of the second point
76+
* @param pts Will be filled with the cells that lie on the line in the grid
77+
*/
78+
static void supercover(int x0, int x1, int y0, int y1, std::vector<Cell>& pts);
79+
6980
/**
7081
* @brief Use Bresenham's algorithm to trace a line between two points in a grid
7182
* @param x0 The x coordinate of the first point

0 commit comments

Comments
 (0)