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_max_x_(-1e6),
00052     extra_min_y_(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    * Updates the master_grid within the specified
00075    * bounding box using this layer's values.
00076    *
00077    * TrueOverwrite means every value from this layer
00078    * is written into the master grid.
00079    */
00080   void updateWithTrueOverwrite(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00081 
00082   /*
00083    * Updates the master_grid within the specified
00084    * bounding box using this layer's values.
00085    *
00086    * Overwrite means every valid value from this layer
00087    * is written into the master grid (does not copy NO_INFORMATION)
00088    */
00089   void updateWithOverwrite(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00090 
00091   /*
00092    * Updates the master_grid within the specified
00093    * bounding box using this layer's values.
00094    *
00095    * Sets the new value to the maximum of the master_grid's value
00096    * and this layer's value. If the master value is NO_INFORMATION,
00097    * it is overwritten. If the layer's value is NO_INFORMATION,
00098    * the master value does not change.
00099    */
00100   void updateWithMax(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00101 
00102   /*
00103    * Updates the master_grid within the specified
00104    * bounding box using this layer's values.
00105    *
00106    * Sets the new value to the sum of the master grid's value
00107    * and this layer's value. If the master value is NO_INFORMATION,
00108    * it is overwritten with the layer's value. If the layer's value
00109    * is NO_INFORMATION, then the master value does not change.
00110    *
00111    * If the sum value is larger than INSCRIBED_INFLATED_OBSTACLE,
00112    * the master value is set to (INSCRIBED_INFLATED_OBSTACLE - 1).
00113    */
00114   void updateWithAddition(costmap_2d::Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j);
00115 
00127   void touch(double x, double y, double* min_x, double* min_y, double* max_x, double* max_y);
00128 
00129   /*
00130    * Updates the bounding box specified in the parameters
00131    * to include the bounding box from the addExtraBounds
00132    * call. If addExtraBounds was not called, the method will do nothing.
00133    *
00134    * Should be called at the beginning of the updateBounds method
00135    *
00136    * @param min_x bounding box (input and output)
00137    * @param min_y bounding box (input and output)
00138    * @param max_x bounding box (input and output)
00139    * @param max_y bounding box (input and output)
00140    */
00141   void useExtraBounds(double* min_x, double* min_y, double* max_x, double* max_y);
00142   bool has_extra_bounds_;
00143 
00144 private:
00145   double extra_min_x_, extra_max_x_, extra_min_y_, extra_max_y_;
00146 };
00147 
00148 }  // namespace costmap_2d
00149 #endif  // COSTMAP_2D_COSTMAP_LAYER_H_


costmap_2d
Author(s): Eitan Marder-Eppstein, David V. Lu!!, Dave Hershberger, contradict@gmail.com
autogenerated on Wed Aug 2 2017 03:12:21