costmap_layer.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright (c) 2015, Michal Drwiega (drwiega.michal@gmail.com)
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 are met:
00009  *     1. Redistributions of source code must retain the above copyright
00010  *        notice, this list of conditions and the following disclaimer.
00011  *     2. Redistributions in binary form must reproduce the above copyright
00012  *        notice, this list of conditions and the following disclaimer in the
00013  *        documentation and/or other materials provided with the distribution.
00014  *     3. Neither the name of the copyright holder nor the names of its
00015  *        contributors may be used to endorse or promote products derived
00016  *        from this software without specific prior written permission.
00017  *
00018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00019  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00020  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00021  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00022  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00023  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00024  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00025  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00026  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00027  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00028  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029  *****************************************************************************/
00037 #ifndef COSTMAP_LAYER_H
00038 #define COSTMAP_LAYER_H
00039 
00040 #include <ros/ros.h>
00041 #include <costmap_2d/layered_costmap.h>
00042 #include <costmap_2d/footprint.h>
00043 #include <costmap_2d/layer.h>
00044 #include <pluginlib/class_list_macros.h>
00045 
00046 #include <depth_nav_msgs/Point32List.h>
00047 #include <geometry_msgs/PointStamped.h>
00048 
00049 #include <boost/thread.hpp>
00050 
00051 #include <math.h>
00052 #include <algorithm>
00053 
00054 #include <angles/angles.h>
00055 
00056 #include <dynamic_reconfigure/server.h>
00057 #include <nav_layer_from_points/NavLayerFromPointsConfig.h>
00058 
00059 
00060 namespace nav_layer_from_points
00061 {
00062 class NavLayerFromPoints : public costmap_2d::Layer
00063 {
00064 public:
00065   NavLayerFromPoints() { layered_costmap_ = NULL; }
00066 
00067   virtual void onInitialize();
00068 
00069   virtual void updateBounds( double origin_x, double origin_y, double origin_yaw,
00070                              double* min_x, double* min_y, double* max_x, double* max_y);
00071 
00072   virtual void updateCosts( costmap_2d::Costmap2D& master_grid,
00073                             int min_i, int min_j, int max_i, int max_j);
00074 
00075   void updateBoundsFromPoints( double* min_x, double* min_y,
00076                                double* max_x, double* max_y);
00077 
00078   bool isDiscretized() { return false; }
00079 
00080 protected:
00081 
00082   void pointsCallback(const depth_nav_msgs::Point32List& points);
00083 
00087   void clearTransformedPoints();
00088 
00089   void configure(NavLayerFromPointsConfig &config, uint32_t level);
00090 
00091 protected: // Protected fields
00092   ros::Subscriber sub_points_;               
00093   depth_nav_msgs::Point32List points_list_;  
00094 
00095   tf::TransformListener tf_;
00096 
00097   std::list<geometry_msgs::PointStamped> transformed_points_;
00098 
00099   // After this time points will be delete
00100   ros::Duration points_keep_time_;
00101 
00102   boost::recursive_mutex lock_;
00103   bool first_time_;
00104   double last_min_x_, last_min_y_, last_max_x_, last_max_y_;
00105 
00106 private:
00107   //-----------------------------------------------------------------------------------------------
00108   // ROS parameters configurated with config file or dynamic_reconfigure
00109   double point_radius_;
00110   double robot_radius_;
00111 
00112   //-----------------------------------------------------------------------------------------------
00113 
00114   dynamic_reconfigure::Server<NavLayerFromPointsConfig>* rec_server_;
00115   dynamic_reconfigure::Server<NavLayerFromPointsConfig>::CallbackType f_;
00116 
00117 };
00118 } // end of namespace
00119 
00120 
00121 #endif
00122 


nav_layer_from_points
Author(s): Michal Drwiega
autogenerated on Thu Jun 6 2019 22:10:55