costmap_3d.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2014-2018, the neonavigation authors
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the copyright holder nor the names of its 
00014  *       contributors may be used to endorse or promote products derived from 
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef COSTMAP_CSPACE_COSTMAP_3D_H
00031 #define COSTMAP_CSPACE_COSTMAP_3D_H
00032 
00033 #include <ros/ros.h>
00034 
00035 #include <costmap_cspace/costmap_3d_layer/footprint.h>
00036 #include <costmap_cspace/costmap_3d_layer/plain.h>
00037 #include <costmap_cspace/costmap_3d_layer/output.h>
00038 #include <costmap_cspace/costmap_3d_layer/stop_propagation.h>
00039 #include <costmap_cspace/costmap_3d_layer/unknown_handle.h>
00040 
00041 #include <costmap_cspace/costmap_3d_layer/class_loader.h>
00042 
00043 #include <vector>
00044 
00045 namespace costmap_cspace
00046 {
00047 class Costmap3d
00048 {
00049 protected:
00050   std::vector<Costmap3dLayerBase::Ptr> costmaps_;
00051   int ang_resolution_;
00052 
00053 public:
00054   using Ptr = std::shared_ptr<Costmap3d>;
00055 
00056   explicit Costmap3d(const int ang_resolution)
00057   {
00058     ang_resolution_ = ang_resolution;
00059 
00060     ROS_ASSERT(ang_resolution_ > 0);
00061   }
00062   template <typename T>
00063   typename T::Ptr addRootLayer()
00064   {
00065     typename T::Ptr
00066         costmap_base(new T);
00067 
00068     costmap_base->setAngleResolution(ang_resolution_);
00069 
00070     costmap_base->setOverlayMode(MapOverlayMode::MAX);
00071 
00072     costmaps_.resize(1);
00073     costmaps_[0] = costmap_base;
00074 
00075     return costmap_base;
00076   }
00077   template <typename T>
00078   typename T::Ptr addLayer(
00079       const MapOverlayMode overlay_mode = MapOverlayMode::MAX)
00080   {
00081     typename T::Ptr costmap_overlay(new T);
00082     costmap_overlay->setAngleResolution(ang_resolution_);
00083     costmap_overlay->setOverlayMode(overlay_mode);
00084 
00085     costmaps_.back()->setChild(costmap_overlay);
00086     costmaps_.push_back(costmap_overlay);
00087 
00088     return costmap_overlay;
00089   }
00090   Costmap3dLayerBase::Ptr addLayer(
00091       Costmap3dLayerBase::Ptr costmap_overlay,
00092       const MapOverlayMode overlay_mode = MapOverlayMode::MAX)
00093   {
00094     costmap_overlay->setAngleResolution(ang_resolution_);
00095     costmap_overlay->setOverlayMode(overlay_mode);
00096 
00097     costmaps_.back()->setChild(costmap_overlay);
00098     costmaps_.push_back(costmap_overlay);
00099 
00100     return costmap_overlay;
00101   }
00102   Costmap3dLayerBase::Ptr getRootLayer()
00103   {
00104     return costmaps_.front();
00105   }
00106 };
00107 }  // namespace costmap_cspace
00108 
00109 #endif  // COSTMAP_CSPACE_COSTMAP_3D_H


costmap_cspace
Author(s): Atsushi Watanabe
autogenerated on Sat Jun 22 2019 20:07:13