exploration_transform_vis.h
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2012, Mark Sollweck, Stefan Kohlbrecher, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Simulation, Systems Optimization and Robotics
13 // group, TU Darmstadt nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
29 #ifndef EXPLORATION_TRANSFORM_VIS_H___
30 #define EXPLORATION_TRANSFORM_VIS_H___
31 
32 #include <sensor_msgs/PointCloud.h>
33 #include <ros/ros.h>
34 #include <costmap_2d/costmap_2d.h>
35 
36 
38 
40  {
41  public:
42  ExplorationTransformVis(const std::string& topic_name)
43  {
44  ros::NodeHandle pnh("~");
45  exploration_transform_pointcloud_pub_ = pnh.advertise<sensor_msgs::PointCloud>(topic_name, 2, false);
46  }
47 
49  {}
50 
51  void publishVisOnDemand(const costmap_2d::Costmap2D& costmap, const unsigned int* exploration_array)
52  {
54  unsigned int size_x = costmap.getSizeInCellsX();
55  unsigned int size_y = costmap.getSizeInCellsY();
56  unsigned int size = size_x * size_y;
57 
58  unsigned int max = 0;
59 
60  for (size_t i = 0; i < size; ++i){
61  if ((exploration_array[i] < INT_MAX) && (exploration_array[i] > max)){
62  max = exploration_array[i];
63  }
64  }
65 
66  float max_f = static_cast<float>(max);
67 
68  sensor_msgs::PointCloud cloud;
69  cloud.header.frame_id = "/map";
70  cloud.header.stamp = ros::Time::now();
71 
72  double x_world, y_world;
73 
74  geometry_msgs::Point32 point;
75 
76  for (size_t x = 0; x < size_x; ++x){
77  for (size_t y = 0; y < size_y; ++y){
78 
79  unsigned int index = costmap.getIndex(x,y);
80 
81  if (exploration_array[index] < INT_MAX){
82 
83  costmap.mapToWorld(x,y, x_world, y_world);
84  point.x = x_world;
85  point.y = y_world;
86  point.z = static_cast<float>(exploration_array[index])/max_f;
87 
88  cloud.points.push_back(point);
89  }
90 
91  }
92  }
94  }
95  }
96 
97  protected:
98 
100  };
101 
102 }
103 
104 #endif
void publish(const boost::shared_ptr< M > &message) const
void mapToWorld(unsigned int mx, unsigned int my, double &wx, double &wy) const
TFSIMD_FORCE_INLINE const tfScalar & y() const
void publishVisOnDemand(const costmap_2d::Costmap2D &costmap, const unsigned int *exploration_array)
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
unsigned int getSizeInCellsY() const
unsigned int getSizeInCellsX() const
uint32_t getNumSubscribers() const
static Time now()
unsigned int getIndex(unsigned int mx, unsigned int my) const


hector_exploration_planner
Author(s):
autogenerated on Mon Jun 10 2019 13:34:41