costmap_to_dynamic_obstacles.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  *
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2017
00006  *  TU Dortmund - Institute of Control Theory and Systems Engineering.
00007  *  All rights reserved.
00008  *
00009  *  Redistribution and use in source and binary forms, with or without
00010  *  modification, are permitted provided that the following conditions
00011  *  are met:
00012  *
00013  *   * Redistributions of source code must retain the above copyright
00014  *     notice, this list of conditions and the following disclaimer.
00015  *   * Redistributions in binary form must reproduce the above
00016  *     copyright notice, this list of conditions and the following
00017  *     disclaimer in the documentation and/or other materials provided
00018  *     with the distribution.
00019  *   * Neither the name of the institute nor the names of its
00020  *     contributors may be used to endorse or promote products derived
00021  *     from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034  *  POSSIBILITY OF SUCH DAMAGE.
00035  *
00036  * Notes:
00037  * The following code makes use of the OpenCV library.
00038  * OpenCV is licensed under the terms of the 3-clause BSD License.
00039  *
00040  * Authors: Franz Albers, Christoph Rösmann
00041  *********************************************************************/
00042 
00043 #ifndef COSTMAP_TO_DYNAMIC_OBSTACLES_H_
00044 #define COSTMAP_TO_DYNAMIC_OBSTACLES_H_
00045 
00046 // ROS
00047 #include <costmap_converter/costmap_converter_interface.h>
00048 #include <nav_msgs/Odometry.h>
00049 #include <ros/ros.h>
00050 
00051 // OpenCV
00052 #include <cv_bridge/cv_bridge.h>
00053 #include <opencv2/features2d/features2d.hpp>
00054 #include <opencv2/video/tracking.hpp>
00055 
00056 // dynamic reconfigure
00057 #include <costmap_converter/CostmapToDynamicObstaclesConfig.h>
00058 #include <dynamic_reconfigure/server.h>
00059 
00060 // Own includes
00061 #include <costmap_converter/costmap_to_dynamic_obstacles/multitarget_tracker/Ctracker.h>
00062 #include <costmap_converter/costmap_to_dynamic_obstacles/background_subtractor.h>
00063 #include <costmap_converter/costmap_to_dynamic_obstacles/blob_detector.h>
00064 
00065 // STL
00066 #include <memory>
00067 
00068 namespace costmap_converter {
00069 
00077 class CostmapToDynamicObstacles : public BaseCostmapToPolygons
00078 {
00079 public:
00083   CostmapToDynamicObstacles();
00084 
00088   virtual ~CostmapToDynamicObstacles();
00089 
00094   virtual void initialize(ros::NodeHandle nh);
00095 
00100   virtual void compute();
00101 
00107   virtual void setCostmap2D(costmap_2d::Costmap2D* costmap);
00108 
00113   virtual void updateCostmap2D();
00114 
00121   ObstacleArrayConstPtr getObstacles();
00122 
00132   virtual void setOdomTopic(const std::string& odom_topic)
00133   {
00134     odom_topic_ = odom_topic;
00135   }
00136 
00142   void visualize(const std::string& name, const cv::Mat& image);
00143 
00144 protected:
00152   Point_t getEstimatedVelocityOfObject(unsigned int idx);
00153 
00161   void getContour(unsigned int idx, std::vector<Point_t>& contour);
00162 
00169   void updateObstacleContainer(ObstacleArrayPtr obstacles);
00170 
00171 private:
00172   boost::mutex mutex_;
00173   costmap_2d::Costmap2D* costmap_;
00174   cv::Mat costmap_mat_;
00175   ObstacleArrayPtr obstacles_;
00176   cv::Mat fg_mask_;
00177   std::unique_ptr<BackgroundSubtractor> bg_sub_;
00178   cv::Ptr<BlobDetector> blob_det_;
00179   std::vector<cv::KeyPoint> keypoints_;
00180   std::unique_ptr<CTracker> tracker_;
00181   ros::Subscriber odom_sub_;
00182   Point_t ego_vel_;
00183 
00184   std::string odom_topic_ = "/odom";
00185   bool publish_static_obstacles_ = true;
00186 
00187   dynamic_reconfigure::Server<CostmapToDynamicObstaclesConfig>*
00188       dynamic_recfg_; 
00189 
00190 
00197   void odomCallback(const nav_msgs::Odometry::ConstPtr &msg);
00198 
00207   void reconfigureCB(CostmapToDynamicObstaclesConfig &config, uint32_t level);
00208 };
00209 
00210 } // end namespace costmap_converter
00211 
00212 #endif /* COSTMAP_TO_DYNAMIC_OBSTACLES_H_ */


costmap_converter
Author(s): Christoph Rösmann , Franz Albers , Otniel Rinaldo
autogenerated on Wed Sep 20 2017 03:00:37