costmap.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2018, Locus Robotics
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the copyright holder nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  */
00034 
00035 #ifndef NAV_CORE2_COSTMAP_H
00036 #define NAV_CORE2_COSTMAP_H
00037 
00038 #include <nav_grid/nav_grid.h>
00039 #include <nav_core2/common.h>
00040 #include <nav_core2/bounds.h>
00041 #include <boost/thread.hpp>
00042 #include <string>
00043 
00044 namespace nav_core2
00045 {
00046 
00047 class Costmap : public nav_grid::NavGrid<unsigned char>
00048 {
00049 public:
00050   static const unsigned char NO_INFORMATION = 255;
00051   static const unsigned char LETHAL_OBSTACLE = 254;
00052   static const unsigned char INSCRIBED_INFLATED_OBSTACLE = 253;
00053   static const unsigned char FREE_SPACE = 0;
00054 
00055   using Ptr = std::shared_ptr<Costmap>;
00056 
00060   virtual ~Costmap() {}
00061 
00072   virtual void initialize(const ros::NodeHandle& parent, const std::string& name, TFListenerPtr tf) {}
00073 
00074   inline unsigned char getCost(const unsigned int x, const unsigned int y)
00075   {
00076     return getValue(x, y);
00077   }
00078 
00079   inline unsigned char getCost(const nav_grid::Index& index)
00080   {
00081     return getValue(index.x, index.y);
00082   }
00083 
00084   inline void setCost(const unsigned int x, const unsigned int y, const unsigned char cost)
00085   {
00086     setValue(x, y, cost);
00087   }
00088 
00089   inline void setCost(const nav_grid::Index& index, const unsigned char cost)
00090   {
00091     setValue(index, cost);
00092   }
00093 
00101   virtual void update() {}
00102 
00103   using mutex_t = boost::recursive_mutex;
00107   virtual mutex_t* getMutex() = 0;
00108 
00112   virtual bool canTrackChanges() { return false; }
00113 
00137   virtual UIntBounds getChangeBounds(const std::string& ns)
00138   {
00139     if (!canTrackChanges())
00140     {
00141       throw std::runtime_error("You called 'getChangeBounds()' on a derived Costmap type that is not capable of "
00142                                "tracking changes (i.e. canTrackChanges() returns false). You shouldn't do that.");
00143     }
00144     else
00145     {
00146       throw std::runtime_error("You called 'getChangeBounds()' on a derived Costmap type that is capable of tracking "
00147                                "changes but has not properly implemented this function. You should yell at the author "
00148                                "of the derived Costmap.");
00149     }
00150     return UIntBounds();
00151   }
00152 };
00153 }  // namespace nav_core2
00154 
00155 #endif  // NAV_CORE2_COSTMAP_H


nav_core2
Author(s):
autogenerated on Wed Jun 26 2019 20:09:31