costmap_2d_ros.hpp
Go to the documentation of this file.
00001 #pragma once
00002 
00003 /*****************************************************************************
00004 ** Includes
00005 *****************************************************************************/
00006 
00007 #include <costmap_2d/costmap_2d_ros.h>
00008 #include <grid_map_core/grid_map_core.hpp>
00009 #include <grid_map_costmap_2d/grid_map_costmap_2d.hpp>
00010 #if ROS_VERSION_MINIMUM(1,14,0)
00011 #include <tf2_ros/transform_listener.h>
00012 #else
00013 #include <tf/transform_listener.h>
00014 #endif
00015 
00016 #include <atomic>
00017 #include <map>
00018 #include <string>
00019 #include <thread>
00020 
00021 /*****************************************************************************
00022 ** Transforms
00023 *****************************************************************************/
00024 
00028 class TransformBroadcaster {
00029 public:
00030   TransformBroadcaster() : shutdownFlag_(false) {}
00031   virtual ~TransformBroadcaster();
00032   void add(const std::string& name, tf::Vector3 origin, const tf::Quaternion& orientation);
00033 
00034   void startBroadCastingThread();
00035   void broadcast();
00036   void shutdown();
00037 
00038 private:
00039   std::map<std::string, tf::Transform> transforms_;
00040   std::thread broadcastingThread_;
00041   std::atomic<bool> shutdownFlag_;
00042 };
00043 
00054 class ROSCostmapServer {
00055 public:
00056   typedef costmap_2d::Costmap2DROS ROSCostmap;
00057   typedef std::shared_ptr<ROSCostmap> ROSCostmapPtr;
00058 
00059   ROSCostmapServer(const std::string& name, const std::string& baseLinkTransformName,
00060                    const grid_map::Position& origin, const double& width, const double& height);
00061 
00062   ROSCostmapPtr getROSCostmap() { return costmap_; };
00063 
00064 private:
00065   ROSCostmapPtr costmap_;
00066 #if ROS_VERSION_MINIMUM(1,14,0)
00067   tf2_ros::Buffer tfBuffer_;
00068   tf2_ros::TransformListener tfListener_;
00069 #else
00070   tf::TransformListener tfListener_;
00071 #endif
00072 };
00073 
00074 
00075 /*****************************************************************************
00076 ** Helpers
00077 *****************************************************************************/
00078 
00085 void broadcastCostmap2DROSTestSuiteTransforms(TransformBroadcaster& broadcaster);
00086 


grid_map_costmap_2d
Author(s): Péter Fankhauser
autogenerated on Tue Jul 9 2019 05:06:21