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 
58 class EnumProperty;
59 class FloatProperty;
60 class IntProperty;
61 class Property;
62 class QuaternionProperty;
63 class RosTopicProperty;
64 class VectorProperty;
65 
66 class MapDisplay;
67 class AlphaSetter;
68 
69 class Swatch
70 {
71 friend class MapDisplay;
72  public:
73  Swatch(MapDisplay* parent, unsigned int x, unsigned int y, unsigned int width, unsigned int height, float resolution);
74  ~Swatch();
75  void updateAlpha(const Ogre::SceneBlendType sceneBlending, bool depthWrite, AlphaSetter* alpha_setter);
76  void updateData();
77 
78  protected:
80  Ogre::ManualObject* manual_object_;
81  Ogre::TexturePtr texture_;
82  Ogre::MaterialPtr material_;
83  Ogre::SceneNode* scene_node_;
84  unsigned int x_,y_,width_,height_;
85 };
86 
87 
92 class MapDisplay: public Display
93 {
94 friend class Swatch;
95 Q_OBJECT
96 public:
97  MapDisplay();
98  virtual ~MapDisplay();
99 
100  // Overrides from Display
101  virtual void onInitialize();
102  virtual void fixedFrameChanged();
103  virtual void reset();
104 
105  float getResolution() { return resolution_; }
106  int getWidth() { return width_; }
107  int getHeight() { return height_; }
108 
109  virtual void setTopic( const QString &topic, const QString &datatype );
110 
111 Q_SIGNALS:
113  void mapUpdated();
114 
115 protected Q_SLOTS:
116  void updateAlpha();
117  void updateTopic();
118  void updateDrawUnder();
119  void updatePalette();
121  void showMap();
122  void transformMap();
123 
124 protected:
125  // overrides from Display
126  virtual void onEnable();
127  virtual void onDisable();
128 
129  virtual void subscribe();
130  virtual void unsubscribe();
131  virtual void update( float wall_dt, float ros_dt );
132 
134  void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg);
135 
137  void incomingUpdate(const map_msgs::OccupancyGridUpdate::ConstPtr& update);
138 
139  void clear();
140 
141  void createSwatches();
142 
143  std::vector<Swatch*> swatches;
144  std::vector<Ogre::TexturePtr> palette_textures_;
145  std::vector<bool> color_scheme_transparency_;
146  bool loaded_;
147 
148  std::string topic_;
149  float resolution_;
150  int width_;
151  int height_;
152  std::string frame_;
153  nav_msgs::OccupancyGrid current_map_;
154 
157 
167 
170 };
171 
172 } // namespace rviz
173 
174  #endif
float getResolution()
Definition: map_display.h:105
std::string frame_
Definition: map_display.h:152
Ogre::ManualObject * manual_object_
Definition: map_display.h:80
std::vector< Ogre::TexturePtr > palette_textures_
Definition: map_display.h:144
QuaternionProperty * orientation_property_
Definition: map_display.h:163
std::vector< bool > color_scheme_transparency_
Definition: map_display.h:145
Ogre::TexturePtr texture_
Definition: map_display.h:81
MapDisplay * parent_
Definition: map_display.h:79
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:164
Ogre::MaterialPtr material_
Definition: map_display.h:82
Property specialized to enforce floating point max/min.
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:38
ros::Subscriber update_sub_
Definition: map_display.h:156
VectorProperty * position_property_
Definition: map_display.h:162
FloatProperty * resolution_property_
Definition: map_display.h:159
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
void subscribe()
unsigned int y_
Definition: map_display.h:84
std::vector< Swatch * > swatches
Definition: map_display.h:143
std::string topic_
Definition: map_display.h:148
EnumProperty * color_scheme_property_
Definition: map_display.h:166
Displays a map along the XY plane.
Definition: map_display.h:92
RosTopicProperty * topic_property_
Definition: map_display.h:158
IntProperty * height_property_
Definition: map_display.h:161
Property * draw_under_property_
Definition: map_display.h:165
BoolProperty * unreliable_property_
Definition: map_display.h:168
ros::Subscriber map_sub_
Definition: map_display.h:155
BoolProperty * transform_timestamp_property_
Definition: map_display.h:169
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
Ogre::SceneNode * scene_node_
Definition: map_display.h:83
IntProperty * width_property_
Definition: map_display.h:160
Enum property.
Definition: enum_property.h:47
nav_msgs::OccupancyGrid current_map_
Definition: map_display.h:153


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:51