costmap_layer.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2008, 2013, Willow Garage, Inc.
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/or other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of Willow Garage, Inc. nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *
00035  * Author: Eitan Marder-Eppstein
00036  *         David V. Lu!!
00037  *********************************************************************/
00038 #ifndef COSTMAP_2D_COSTMAP_LAYER_H_
00039 #define COSTMAP_2D_COSTMAP_LAYER_H_
00040 #include <ros/ros.h>
00041 #include <costmap_2d/layer.h>
00042 #include <costmap_2d/layered_costmap.h>
00043 
00044 namespace costmap_2d
00045 {
00046 
00047 class CostmapLayer : public Layer, public Costmap2D
00048 {
00049 public:
00050   CostmapLayer() : has_extra_bounds_(false), 
00051     extra_min_x_( 1e6), extra_min_y_( 1e6),
00052     extra_max_x_(-1e6), extra_max_y_(-1e6) {}
00053 
00054   bool isDiscretized()
00055   {
00056     return true;
00057   }
00058 
00059   virtual void matchSize();
00060   
00070   void addExtraBounds(double mx0, double my0, double mx1, double my1);
00071 
00072 protected:
00073 
00074   /*
00075    * Updates the master_grid within the specified 
00076    * bounding box using this layer's values. 
00077    *
00078    * TrueOverwrite means every value from this layer
00079    * is written into the master grid.
00080    */
00081   void updateWithTrueOverwrite(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00082   
00083   /*
00084    * Updates the master_grid within the specified 
00085    * bounding box using this layer's values. 
00086    *
00087    * Overwrite means every valid value from this layer
00088    * is written into the master grid (does not copy NO_INFORMATION)
00089    */
00090   void updateWithOverwrite    (costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00091   
00092   /*
00093    * Updates the master_grid within the specified 
00094    * bounding box using this layer's values. 
00095    *
00096    * Sets the new value to the maximum of the master_grid's value 
00097    * and this layer's value. If the master value is NO_INFORMATION,
00098    * it is overwritten. If the layer's value is NO_INFORMATION, 
00099    * the master value does not change. 
00100    */
00101   void updateWithMax          (costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00102   
00103   /*
00104    * Updates the master_grid within the specified 
00105    * bounding box using this layer's values. 
00106    *
00107    * Sets the new value to the sum of the master grid's value 
00108    * and this layer's value. If the master value is NO_INFORMATION,
00109    * it is overwritten with the layer's value. If the layer's value 
00110    * is NO_INFORMATION, then the master value does not change. 
00111    *
00112    * If the sum value is larger than INSCRIBED_INFLATED_OBSTACLE,
00113    * the master value is set to (INSCRIBED_INFLATED_OBSTACLE - 1).
00114    */
00115   void updateWithAddition     (costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00116 
00128   void touch(double x, double y, double* min_x, double* min_y, double* max_x, double* max_y);
00129   
00130   /*
00131    * Updates the bounding box specified in the parameters
00132    * to include the bounding box from the addExtraBounds
00133    * call. If addExtraBounds was not called, the method will do nothing.
00134    *
00135    * Should be called at the beginning of the updateBounds method
00136    * 
00137    * @param min_x bounding box (input and output)
00138    * @param min_y bounding box (input and output)
00139    * @param max_x bounding box (input and output)
00140    * @param max_y bounding box (input and output)
00141    */
00142   void useExtraBounds(double* min_x, double* min_y, double* max_x, double* max_y);
00143   bool has_extra_bounds_;
00144   
00145 private:
00146   double extra_min_x_, extra_max_x_, extra_min_y_, extra_max_y_;
00147 };
00148 
00149 }  // namespace costmap_2d
00150 
00151 #endif  // COSTMAP_2D_COSTMAP_LAYER_H_


costmap_2d
Author(s): Eitan Marder-Eppstein, David V. Lu!!, Dave Hershberger, contradict@gmail.com
autogenerated on Thu Aug 27 2015 14:06:55