map_display.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
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  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_MAP_DISPLAY_H
31 #define RVIZ_MAP_DISPLAY_H
32 
33 #ifndef Q_MOC_RUN
34 #include <boost/thread/thread.hpp>
35 
36 #include <OgreTexture.h>
37 #include <OgreMaterial.h>
38 #include <OgreVector3.h>
39 #include <OgreSharedPtr.h>
40 #endif
41 
42 #include <nav_msgs/MapMetaData.h>
43 #include <ros/time.h>
44 
45 #include <nav_msgs/OccupancyGrid.h>
46 #include <map_msgs/OccupancyGridUpdate.h>
47 
48 #include "rviz/display.h"
49 
50 namespace Ogre
51 {
52 class ManualObject;
53 }
54 
55 namespace rviz
56 {
57 class EnumProperty;
58 class FloatProperty;
59 class IntProperty;
60 class Property;
61 class QuaternionProperty;
62 class RosTopicProperty;
63 class VectorProperty;
64 
65 class MapDisplay;
66 class AlphaSetter;
67 
68 class Swatch
69 {
70  friend class MapDisplay;
71 
72 public:
73  Swatch(MapDisplay* parent,
74  unsigned int x,
75  unsigned int y,
76  unsigned int width,
77  unsigned int height,
78  float resolution);
79  ~Swatch();
80  void updateAlpha(const Ogre::SceneBlendType sceneBlending, bool depthWrite, AlphaSetter* alpha_setter);
81  void updateData();
82 
83 protected:
85  Ogre::ManualObject* manual_object_;
86  Ogre::TexturePtr texture_;
87  Ogre::MaterialPtr material_;
88  Ogre::SceneNode* scene_node_;
89  unsigned int x_, y_, width_, height_;
90 };
91 
92 
97 class MapDisplay : public Display
98 {
99  friend class Swatch;
100  Q_OBJECT
101 public:
102  MapDisplay();
103  ~MapDisplay() override;
104 
105  // Overrides from Display
106  void onInitialize() override;
107  void fixedFrameChanged() override;
108  void reset() override;
109 
111  {
112  return resolution_;
113  }
114  int getWidth()
115  {
116  return width_;
117  }
118  int getHeight()
119  {
120  return height_;
121  }
122 
123  void setTopic(const QString& topic, const QString& datatype) override;
124 
125 Q_SIGNALS:
127  void mapUpdated();
128 
129 protected Q_SLOTS:
130  void updateAlpha();
131  void updateTopic();
132  void updateDrawUnder();
133  void updatePalette();
135  void showMap();
136  void transformMap();
137 
138 protected:
139  // overrides from Display
140  void onEnable() override;
141  void onDisable() override;
142 
143  virtual void subscribe();
144  virtual void unsubscribe();
145  void update(float wall_dt, float ros_dt) override;
146 
148  void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg);
149 
151  void incomingUpdate(const map_msgs::OccupancyGridUpdate::ConstPtr& update);
152 
153  void clear();
154 
155  void createSwatches();
156 
157  std::vector<Swatch*> swatches;
158  std::vector<Ogre::TexturePtr> palette_textures_;
159  std::vector<bool> color_scheme_transparency_;
160  bool loaded_;
161 
162  std::string topic_;
163  float resolution_;
164  int width_;
165  int height_;
166  std::string frame_;
167  nav_msgs::OccupancyGrid current_map_;
168 
171 
181 
184 };
185 
186 } // namespace rviz
187 
188 #endif
float getResolution()
Definition: map_display.h:110
std::string frame_
Definition: map_display.h:166
Ogre::ManualObject * manual_object_
Definition: map_display.h:85
std::vector< Ogre::TexturePtr > palette_textures_
Definition: map_display.h:158
QuaternionProperty * orientation_property_
Definition: map_display.h:177
std::vector< bool > color_scheme_transparency_
Definition: map_display.h:159
Ogre::TexturePtr texture_
Definition: map_display.h:86
MapDisplay * parent_
Definition: map_display.h:84
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
FloatProperty * alpha_property_
Definition: map_display.h:178
Ogre::MaterialPtr material_
Definition: map_display.h:87
Property specialized to enforce floating point max/min.
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:37
ros::Subscriber update_sub_
Definition: map_display.h:170
VectorProperty * position_property_
Definition: map_display.h:176
FloatProperty * resolution_property_
Definition: map_display.h:173
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
void subscribe()
unsigned int y_
Definition: map_display.h:89
const char * datatype()
std::vector< Swatch * > swatches
Definition: map_display.h:157
std::string topic_
Definition: map_display.h:162
EnumProperty * color_scheme_property_
Definition: map_display.h:180
Displays a map along the XY plane.
Definition: map_display.h:97
RosTopicProperty * topic_property_
Definition: map_display.h:172
IntProperty * height_property_
Definition: map_display.h:175
Property * draw_under_property_
Definition: map_display.h:179
BoolProperty * unreliable_property_
Definition: map_display.h:182
ros::Subscriber map_sub_
Definition: map_display.h:169
BoolProperty * transform_timestamp_property_
Definition: map_display.h:183
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
Ogre::SceneNode * scene_node_
Definition: map_display.h:88
IntProperty * width_property_
Definition: map_display.h:174
void unsubscribe()
Enum property.
Definition: enum_property.h:46
nav_msgs::OccupancyGrid current_map_
Definition: map_display.h:167


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24