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>
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 protected Q_SLOTS:
126  void updateAlpha();
127  void updateTopic();
128  void updateDrawUnder();
129  void updatePalette();
130  void updateMap();
131  void transformMap();
132 
133 protected:
134  // overrides from Display
135  void onEnable() override;
136  void onDisable() override;
137 
138  virtual void subscribe();
139  virtual void unsubscribe();
140  void update(float wall_dt, float ros_dt) override;
141 
143  void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr& msg);
144 
146  void incomingUpdate(const map_msgs::OccupancyGridUpdate::ConstPtr& update);
147 
148  void clear();
149 
150  void createSwatches();
151 
152  std::vector<Swatch*> swatches;
153  std::vector<Ogre::TexturePtr> palette_textures_;
154  std::vector<bool> color_scheme_transparency_;
155  bool loaded_;
157 
158  std::string topic_;
159  float resolution_;
160  int width_;
161  int height_;
162  std::string frame_;
163  nav_msgs::OccupancyGrid current_map_;
164 
167 
177 
180 };
181 
182 } // namespace rviz
183 
184 #endif
rviz::MapDisplay::swatches
std::vector< Swatch * > swatches
Definition: map_display.h:152
rviz::MapDisplay::updateAlpha
void updateAlpha()
Definition: map_display.cpp:476
rviz::RosTopicProperty
Definition: ros_topic_property.h:39
rviz::Swatch::parent_
MapDisplay * parent_
Definition: map_display.h:84
rviz::Swatch::updateData
void updateData()
Definition: map_display.cpp:183
rviz::MapDisplay::updatePalette
void updatePalette()
Definition: map_display.cpp:760
Ogre
Definition: axes_display.h:35
rviz::MapDisplay::getWidth
int getWidth()
Definition: map_display.h:114
rviz::MapDisplay::topic_
std::string topic_
Definition: map_display.h:158
rviz::MapDisplay::topic_property_
RosTopicProperty * topic_property_
Definition: map_display.h:168
rviz::Swatch::manual_object_
Ogre::ManualObject * manual_object_
Definition: map_display.h:85
rviz::MapDisplay::height_property_
IntProperty * height_property_
Definition: map_display.h:171
rviz::MapDisplay::color_scheme_property_
EnumProperty * color_scheme_property_
Definition: map_display.h:176
rviz::MapDisplay::getResolution
float getResolution()
Definition: map_display.h:110
rviz::MapDisplay::updateTopic
void updateTopic()
Definition: map_display.cpp:519
time.h
rviz::BoolProperty
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
rviz::Swatch::Swatch
Swatch(MapDisplay *parent, unsigned int x, unsigned int y, unsigned int width, unsigned int height, float resolution)
Definition: map_display.cpp:81
rviz::MapDisplay::createSwatches
void createSwatches()
Definition: map_display.cpp:592
rviz::MapDisplay::map_sub_
ros::Subscriber map_sub_
Definition: map_display.h:165
rviz::MapDisplay::transform_timestamp_property_
BoolProperty * transform_timestamp_property_
Definition: map_display.h:179
rviz::MapDisplay::resolution_property_
FloatProperty * resolution_property_
Definition: map_display.h:169
rviz::MapDisplay::orientation_property_
QuaternionProperty * orientation_property_
Definition: map_display.h:173
rviz::MapDisplay::update_sub_
ros::Subscriber update_sub_
Definition: map_display.h:166
rviz::MapDisplay::color_scheme_transparency_
std::vector< bool > color_scheme_transparency_
Definition: map_display.h:154
rviz::MapDisplay::width_
int width_
Definition: map_display.h:160
rviz::MapDisplay::updateMap
void updateMap()
Definition: map_display.cpp:652
rviz::MapDisplay::alpha_property_
FloatProperty * alpha_property_
Definition: map_display.h:174
rviz::Display
Definition: display.h:63
rviz::EnumProperty
Enum property.
Definition: enum_property.h:46
rviz::QuaternionProperty
Definition: quaternion_property.h:38
rviz::FloatProperty
Property specialized to enforce floating point max/min.
Definition: float_property.h:37
rviz::Swatch::height_
unsigned int height_
Definition: map_display.h:89
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz::MapDisplay::onDisable
void onDisable() override
Derived classes override this to do the actual work of disabling themselves.
Definition: map_display.cpp:423
rviz::Swatch::x_
unsigned int x_
Definition: map_display.h:89
rviz::Swatch::updateAlpha
void updateAlpha(const Ogre::SceneBlendType sceneBlending, bool depthWrite, AlphaSetter *alpha_setter)
Definition: map_display.cpp:171
rviz::MapDisplay::transformMap
void transformMap()
Definition: map_display.cpp:783
rviz::Swatch
Definition: map_display.h:68
rviz::MapDisplay::~MapDisplay
~MapDisplay() override
Definition: map_display.cpp:274
rviz::Swatch::scene_node_
Ogre::SceneNode * scene_node_
Definition: map_display.h:88
rviz::Swatch::texture_
Ogre::TexturePtr texture_
Definition: map_display.h:86
rviz::MapDisplay::current_map_
nav_msgs::OccupancyGrid current_map_
Definition: map_display.h:163
rviz
Definition: add_display_dialog.cpp:54
rviz::MapDisplay::loaded_
bool loaded_
Definition: map_display.h:155
rviz::MapDisplay::fixedFrameChanged
void fixedFrameChanged() override
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
Definition: map_display.cpp:819
rviz::MapDisplay::getHeight
int getHeight()
Definition: map_display.h:118
rviz::MapDisplay::incomingMap
void incomingMap(const nav_msgs::OccupancyGrid::ConstPtr &msg)
Copy msg into current_map_ and set flag map_updated_.
Definition: map_display.cpp:559
rviz::MapDisplay::resolution_
float resolution_
Definition: map_display.h:159
rviz::Swatch::y_
unsigned int y_
Definition: map_display.h:89
ogre_vector.h
rviz::Swatch::material_
Ogre::MaterialPtr material_
Definition: map_display.h:87
rviz::MapDisplay::update
void update(float wall_dt, float ros_dt) override
Called periodically by the visualization manager.
Definition: map_display.cpp:838
rviz::MapDisplay::unsubscribe
virtual void unsubscribe()
Definition: map_display.cpp:470
rviz::MapDisplay::unreliable_property_
BoolProperty * unreliable_property_
Definition: map_display.h:178
rviz::Swatch::width_
unsigned int width_
Definition: map_display.h:89
rviz::MapDisplay::draw_under_property_
Property * draw_under_property_
Definition: map_display.h:175
rviz::MapDisplay::palette_textures_
std::vector< Ogre::TexturePtr > palette_textures_
Definition: map_display.h:153
rviz::MapDisplay::height_
int height_
Definition: map_display.h:161
display.h
rviz::MapDisplay::subscribe
virtual void subscribe()
Definition: map_display.cpp:429
rviz::MapDisplay::width_property_
IntProperty * width_property_
Definition: map_display.h:170
rviz::MapDisplay::updateDrawUnder
void updateDrawUnder()
Definition: map_display.cpp:501
rviz::MapDisplay::incomingUpdate
void incomingUpdate(const map_msgs::OccupancyGridUpdate::ConstPtr &update)
Copy update's data into current_map_ and set flag map_updated_.
Definition: map_display.cpp:567
rviz::MapDisplay::onEnable
void onEnable() override
Derived classes override this to do the actual work of enabling themselves.
Definition: map_display.cpp:418
rviz::VectorProperty
Definition: vector_property.h:39
rviz::MapDisplay
Displays a map along the XY plane.
Definition: map_display.h:97
rviz::MapDisplay::setTopic
void setTopic(const QString &topic, const QString &datatype) override
Set the ROS topic to listen to for this display.
Definition: map_display.cpp:833
rviz::MapDisplay::position_property_
VectorProperty * position_property_
Definition: map_display.h:172
rviz::MapDisplay::onInitialize
void onInitialize() override
Override this function to do subclass-specific initialization.
Definition: map_display.cpp:407
rviz::AlphaSetter
Definition: map_display.cpp:61
rviz::MapDisplay::reset
void reset() override
Called to tell the display to clear its state.
Definition: map_display.cpp:824
rviz::MapDisplay::frame_
std::string frame_
Definition: map_display.h:162
ros::Subscriber
rviz::IntProperty
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:37
rviz::MapDisplay::MapDisplay
MapDisplay()
Definition: map_display.cpp:222
rviz::MapDisplay::clear
void clear()
Definition: map_display.cpp:526
rviz::MapDisplay::map_updated_
bool map_updated_
Definition: map_display.h:156
rviz::Swatch::~Swatch
~Swatch()
Definition: map_display.cpp:166


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Sat Jun 1 2024 02:31:53