eband_local_planner.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2010, Willow Garage, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Willow Garage, Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *
35  * Author: Christian Connette
36  *********************************************************************/
37 
38 #ifndef EBAND_LOCAL_PLANNER_H_
39 #define EBAND_LOCAL_PLANNER_H_
40 
41 //#define DEBUG_EBAND_ // uncomment to enable additional publishing, visualization and logouts for debug
42 
43 #include <ros/ros.h>
44 #include <ros/assert.h>
45 
46 // classes which are part of this package
49 #include <eband_local_planner/EBandPlannerConfig.h>
50 
51 // local planner specific classes
53 
54 // msgs
55 #include <nav_msgs/Path.h>
56 #include <nav_msgs/Odometry.h>
57 #include <geometry_msgs/PoseStamped.h>
58 #include <geometry_msgs/Pose.h>
59 #include <geometry_msgs/Pose2D.h>
60 #include <geometry_msgs/Twist.h>
61 #include <geometry_msgs/WrenchStamped.h>
62 
63 // transforms
64 #include <angles/angles.h>
65 #include <tf/tf.h>
66 
67 // costmap & geometry
69 
70 // boost classes
71 #include <boost/shared_ptr.hpp>
72 
73 namespace eband_local_planner{
74 
79  class EBandPlanner{
80 
81  public:
85  EBandPlanner();
86 
92  EBandPlanner(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
93 
97  ~EBandPlanner();
98 
104  void initialize(std::string name, costmap_2d::Costmap2DROS* costmap_ros);
105 
110  void reconfigure(EBandPlannerConfig& config);
111 
117 
123  bool setPlan(const std::vector<geometry_msgs::PoseStamped>& global_plan);
124 
130  bool getPlan(std::vector<geometry_msgs::PoseStamped>& global_plan);
131 
137  bool getBand(std::vector<Bubble>& elastic_band);
138 
144  bool addFrames(const std::vector<geometry_msgs::PoseStamped>& robot_pose, const AddAtPosition& add_frames_at);
145 
150  bool optimizeBand();
151 
157  bool optimizeBand(std::vector<Bubble>& band);
158 
159  private:
160  // pointer to external objects (do NOT delete object)
162 
163  // parameters
164  std::vector<double> acc_lim_;
174  double costmap_weight_; // the costmap weight or scaling factor
175 
176  // pointer to locally created objects (delete - except for smart-ptrs:)
178  boost::shared_ptr<EBandVisualization> eband_visual_; // pointer to visualization object
179 
180  // flags
182 
183  // data
184  std::vector<geometry_msgs::Point> footprint_spec_; // specification of robot footprint as vector of corner points
185  costmap_2d::Costmap2D* costmap_; // pointer to underlying costmap
186  std::vector<geometry_msgs::PoseStamped> global_plan_; // copy of the plan that shall be optimized
187  std::vector<Bubble> elastic_band_;
188 
189 
190  // methods
191 
192  // band refinement (filling of gaps & removing redundant bubbles)
193 
199  bool refineBand(std::vector<Bubble>& band);
200 
201 
209  bool removeAndFill(std::vector<Bubble>& band, std::vector<Bubble>::iterator& start_iter,std::vector<Bubble>::iterator& end_iter);
210 
211 
219  bool fillGap(std::vector<Bubble>& band, std::vector<Bubble>::iterator& start_iter,std::vector<Bubble>::iterator& end_iter);
220 
221 
222  // optimization
223 
229  bool modifyBandArtificialForce(std::vector<Bubble>& band);
230 
231 
239  bool applyForces(int bubble_num, std::vector<Bubble>& band, std::vector<geometry_msgs::WrenchStamped> forces);
240 
241 
251  bool moveApproximateEquilibrium(const int& bubble_num, const std::vector<Bubble>& band, Bubble& curr_bubble,
252  const geometry_msgs::WrenchStamped& curr_bubble_force, geometry_msgs::Twist& curr_step_width,
253  const int& curr_recursion_depth);
254 
255 
256  // problem (geometry) dependant functions
257 
265  bool interpolateBubbles(geometry_msgs::PoseStamped start_center, geometry_msgs::PoseStamped end_center, geometry_msgs::PoseStamped& interpolated_center);
266 
267 
275  bool checkOverlap(Bubble bubble1, Bubble bubble2);
276 
277 
285  bool calcBubbleDistance(geometry_msgs::Pose start_center_pose, geometry_msgs::Pose end_center_pose, double& distance);
286 
287 
295  bool calcBubbleDifference(geometry_msgs::Pose start_center_pose, geometry_msgs::Pose end_center_pose, geometry_msgs::Twist& difference);
296 
297 
304  bool calcObstacleKinematicDistance(geometry_msgs::Pose center_pose, double& distance);
305 
306 
315  bool getForcesAt(int bubble_num, std::vector<Bubble> band, Bubble curr_bubble, geometry_msgs::WrenchStamped& forces);
316 
317 
326  bool calcInternalForces(int bubble_num, std::vector<Bubble> band, Bubble curr_bubble, geometry_msgs::WrenchStamped& forces);
327 
328 
336  bool calcExternalForces(int bubble_num, Bubble curr_bubble, geometry_msgs::WrenchStamped& forces);
337 
338 
345  bool suppressTangentialForces(int bubble_num, std::vector<Bubble> band, geometry_msgs::WrenchStamped& forces);
346 
347 
348  // type conversion
349 
356  bool convertPlanToBand(std::vector<geometry_msgs::PoseStamped> plan, std::vector<Bubble>& band);
357 
358 
365  bool convertBandToPlan(std::vector<geometry_msgs::PoseStamped>& plan, std::vector<Bubble> band);
366 
367  };
368 };
369 #endif
std::vector< geometry_msgs::PoseStamped > global_plan_
double internal_force_gain_
gain for internal forces ("Elasticity of Band")
bool convertBandToPlan(std::vector< geometry_msgs::PoseStamped > &plan, std::vector< Bubble > band)
This converts a band from a sequence of bubbles into a plan from, a sequence of stamped poses...
bool interpolateBubbles(geometry_msgs::PoseStamped start_center, geometry_msgs::PoseStamped end_center, geometry_msgs::PoseStamped &interpolated_center)
interpolates between two bubbles by calculating the pose for the center of a bubble in the middle of ...
double equilibrium_relative_overshoot_
maximum depth for recursive approximation to constrain computational burden
bool getPlan(std::vector< geometry_msgs::PoseStamped > &global_plan)
This transforms the refined band to a path again and outputs it.
double external_force_gain_
gain for external forces ("Penalty on low distance to abstacles")
bool setPlan(const std::vector< geometry_msgs::PoseStamped > &global_plan)
Set plan which shall be optimized to elastic band planner.
int num_optim_iterations_
maximal number of iteration steps during optimization of band
void setVisualization(boost::shared_ptr< EBandVisualization > eband_visual)
passes a reference to the eband visualization object which can be used to visualize the band optimiza...
bool calcBubbleDistance(geometry_msgs::Pose start_center_pose, geometry_msgs::Pose end_center_pose, double &distance)
This calculates the distance between two bubbles [depends kinematics, shape].
double significant_force_
percentage of old force for which a new force is considered significant when higher as this value ...
bool getBand(std::vector< Bubble > &elastic_band)
This outputs the elastic_band.
Implements the Elastic Band Method for SE2-Manifold (mobile Base)
bool suppressTangentialForces(int bubble_num, std::vector< Bubble > band, geometry_msgs::WrenchStamped &forces)
Calculates tangential portion of forces.
void initialize(std::string name, costmap_2d::Costmap2DROS *costmap_ros)
Initializes the elastic band class by accesing costmap and loading parameters.
bool calcBubbleDifference(geometry_msgs::Pose start_center_pose, geometry_msgs::Pose end_center_pose, geometry_msgs::Twist &difference)
Calculates the difference between the pose of the center of two bubbles and outputs it as Twist (poin...
std::vector< geometry_msgs::Point > footprint_spec_
bool convertPlanToBand(std::vector< geometry_msgs::PoseStamped > plan, std::vector< Bubble > &band)
This converts a plan from a sequence of stamped poses into a band, a sequence of bubbles. Therefore it calculates distances to the surrounding obstacles and derives the expansion or radius of the bubble.
bool calcInternalForces(int bubble_num, std::vector< Bubble > band, Bubble curr_bubble, geometry_msgs::WrenchStamped &forces)
Calculates internal forces for bubbles along the band [depends kinematic].
bool moveApproximateEquilibrium(const int &bubble_num, const std::vector< Bubble > &band, Bubble &curr_bubble, const geometry_msgs::WrenchStamped &curr_bubble_force, geometry_msgs::Twist &curr_step_width, const int &curr_recursion_depth)
Checks for zero-crossings and large changes in force-vector after moving of bubble - if detected it t...
bool addFrames(const std::vector< geometry_msgs::PoseStamped > &robot_pose, const AddAtPosition &add_frames_at)
converts robot_pose to a bubble and tries to connect to the path
bool removeAndFill(std::vector< Bubble > &band, std::vector< Bubble >::iterator &start_iter, std::vector< Bubble >::iterator &end_iter)
recursively checks an intervall of a band whether gaps need to be filled or bubbles may be removed an...
double min_bubble_overlap_
minimum relative overlap two bubbles must have to be treated as connected
bool applyForces(int bubble_num, std::vector< Bubble > &band, std::vector< geometry_msgs::WrenchStamped > forces)
Applies forces to move bubbles and recalculates expansion of bubbles.
bool optimizeBand()
cycles over the elastic band set before and optimizes it locally by minimizing an energy-function ...
bool calcExternalForces(int bubble_num, Bubble curr_bubble, geometry_msgs::WrenchStamped &forces)
Calculates external forces for bubbles along the band [depends shape, environment].
double costmap_weight_
lower bound for absolute value of force below which it is treated as insignificant (no recursive appr...
std::vector< double > acc_lim_
acceleration limits for translational and rotational motion
double tiny_bubble_expansion_
lower bound for bubble expansion. below this bound bubble is considered as "in collision" ...
bool refineBand(std::vector< Bubble > &band)
Cycles over an band and searches for gaps and redundant bubbles. Tries to close gaps and remove redun...
void reconfigure(EBandPlannerConfig &config)
Reconfigures the parameters of the planner.
bool getForcesAt(int bubble_num, std::vector< Bubble > band, Bubble curr_bubble, geometry_msgs::WrenchStamped &forces)
Calculates all forces for a certain bubble at a specific position in the band [depends kinematic]...
costmap_2d::Costmap2DROS * costmap_ros_
pointer to costmap
double tiny_bubble_distance_
internal forces between two bubbles are only calc. if there distance is bigger than this lower bound ...
bool fillGap(std::vector< Bubble > &band, std::vector< Bubble >::iterator &start_iter, std::vector< Bubble >::iterator &end_iter)
recursively fills gaps between two bubbles (if possible)
bool modifyBandArtificialForce(std::vector< Bubble > &band)
calculates internal and external forces and applies changes to the band
boost::shared_ptr< EBandVisualization > eband_visual_
base_local_planner::CostmapModel * world_model_
bool checkOverlap(Bubble bubble1, Bubble bubble2)
this checks whether two bubbles overlap
bool calcObstacleKinematicDistance(geometry_msgs::Pose center_pose, double &distance)
Calculates the distance between the center of a bubble and the closest obstacle [depends kinematics...


eband_local_planner
Author(s): Christian Connette, Bhaskara Marthi, Piyush Khandelwal
autogenerated on Sat Feb 22 2020 04:03:28