facing_visualizer.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 
37 #ifndef JSK_RVIZ_PLUGIN_FACING_VISUALIZER_H_
38 #define JSK_RVIZ_PLUGIN_FACING_VISUALIZER_H_
39 
40 #include <OGRE/OgreTexture.h>
41 #include <OGRE/OgreSceneManager.h>
42 #include <OGRE/OgreSceneNode.h>
43 #include <OGRE/OgreTexture.h>
44 #include <OGRE/OgreMaterial.h>
45 #include <OGRE/OgreManualObject.h>
46 #include <rviz/display_context.h>
47 #include <ros/time.h>
50 #include "overlay_utils.h"
51 
52 namespace jsk_rviz_plugins
53 {
54 
55  // outer radius
56  // inner radius
58  {
59  public:
60 #if ROS_VERSION_MINIMUM(1,12,0)
61  typedef std::shared_ptr<SquareObject> Ptr;
62 #else
64 #endif
65  SquareObject(Ogre::SceneManager* manager,
66  double outer_radius,
67  double inner_radius,
68  std::string name);
70  {
72  };
73 
74  virtual ~SquareObject();
75  virtual Ogre::ManualObject* getManualObject();
76  virtual void setOuterRadius(double outer_radius);
77  virtual void setInnerRadius(double inner_radius);
78  virtual void rebuildPolygon();
79  virtual void setPolygonType(PolygonType type);
80  protected:
81  Ogre::ManualObject* manual_;
82  Ogre::SceneManager* manager_;
83  double outer_radius_;
84  double inner_radius_;
85  std::string name_;
87  private:
88  };
89 
90  class TextureObject // utility class for texture
91  {
92  public:
93 #if ROS_VERSION_MINIMUM(1,12,0)
94  typedef std::shared_ptr<TextureObject> Ptr;
95 #else
97 #endif
98  TextureObject(const int width, const int height, const std::string name);
99  virtual ~TextureObject();
100  virtual int getWidth() { return width_; };
101  virtual int getHeight() { return height_; };
102  virtual ScopedPixelBuffer getBuffer();
103  virtual std::string getMaterialName();
104  protected:
105  Ogre::TexturePtr texture_;
106  Ogre::MaterialPtr material_;
107  const int width_;
108  const int height_;
109  const std::string name_;
110  private:
111 
112  };
113 
115  {
116  public:
117 #if ROS_VERSION_MINIMUM(1,12,0)
118  typedef std::shared_ptr<FacingObject> Ptr;
119 #else
121 #endif
122  FacingObject(Ogre::SceneManager* manager,
123  Ogre::SceneNode* parent,
124  double size);
125  virtual ~FacingObject();
126  virtual void setPosition(Ogre::Vector3& pos);
127  virtual void setOrientation(rviz::DisplayContext* context);
128  virtual void setOrientation(Ogre::Quaternion& rot); // non facing API
129  virtual void update(float wall_dt, float ros_dt) = 0;
130  virtual void setSize(double size);
131  virtual void setEnable(bool enable);
132  virtual void setColor(QColor color);
133  virtual void setColor(Ogre::ColourValue color);
134  virtual void setText(std::string text);
135  virtual void setAlpha(double alpha);
136  protected:
137  virtual void updateColor() = 0;
138  virtual void updateText() = 0;
139  Ogre::SceneManager* scene_manager_;
140  Ogre::SceneNode* node_;
141  Ogre::ColourValue color_;
142  double size_;
143  bool enable_;
144  std::string text_;
145  private:
146 
147  };
148 
150  {
151  public:
152 #if ROS_VERSION_MINIMUM(1,12,0)
153  typedef std::shared_ptr<SimpleCircleFacingVisualizer> Ptr;
154 #else
156 #endif
157  SimpleCircleFacingVisualizer(Ogre::SceneManager* manager,
158  Ogre::SceneNode* parent,
159  rviz::DisplayContext* context,
160  double size,
161  std::string text = "");
162  virtual ~SimpleCircleFacingVisualizer();
163  virtual void update(float wall_dt, float ros_dt);
164  virtual void reset();
165 
166  virtual void setSize(double size);
167  virtual void setEnable(bool enable);
168  virtual void setText(std::string text);
169  protected:
170  virtual void updateArrowsObjects(Ogre::ColourValue color);
171  virtual void createArrows(rviz::DisplayContext* context);
172  virtual void updateLine();
173  virtual void updateTextUnderLine();
174  virtual void updateText();
175  virtual void updateColor();
178  Ogre::ManualObject* upper_arrow_;
179  Ogre::ManualObject* lower_arrow_;
180  Ogre::ManualObject* left_arrow_;
181  Ogre::ManualObject* right_arrow_;
182  Ogre::SceneNode* upper_arrow_node_;
183  Ogre::SceneNode* lower_arrow_node_;
184  Ogre::SceneNode* left_arrow_node_;
185  Ogre::SceneNode* right_arrow_node_;
186  Ogre::MaterialPtr upper_material_;
187  Ogre::MaterialPtr lower_material_;
188  Ogre::MaterialPtr left_material_;
189  Ogre::MaterialPtr right_material_;
190  std::string upper_material_name_;
191  std::string left_material_name_;
192  std::string lower_material_name_;
193  std::string right_material_name_;
195  Ogre::SceneNode* target_text_node_;
196  private:
197 
198  };
199 
201  {
202  public:
203 #if ROS_VERSION_MINIMUM(1,12,0)
204  typedef std::shared_ptr<FacingTexturedObject> Ptr;
205 #else
207 #endif
208  FacingTexturedObject(Ogre::SceneManager* manager,
209  Ogre::SceneNode* parent,
210  double size);
211  virtual void setSize(double size);
212  protected:
215 
216  private:
217 
218  };
219 
221  {
222  public:
223 #if ROS_VERSION_MINIMUM(1,12,0)
224  typedef std::shared_ptr<GISCircleVisualizer> Ptr;
225 #else
227 #endif
228  GISCircleVisualizer(Ogre::SceneManager* manager,
229  Ogre::SceneNode* parent,
230  double size,
231  std::string text = "");
232  virtual void setText(std::string text) { text_ = text; }
233  virtual void update(float wall_dt, float ros_dt);
234  virtual void setAnonymous(bool anonymous);
235  protected:
236  virtual void updateColor() {}
237  virtual void updateText() {}
238  virtual void setSize(double size);
240  std::string text_;
241  private:
242  };
243 
244 }
245 
246 #endif
bool update(const T &new_val, T &my_val)
boost::shared_ptr< FacingTexturedObject > Ptr
virtual Ogre::ManualObject * getManualObject()
boost::shared_ptr< SquareObject > Ptr
boost::shared_ptr< FacingObject > Ptr
virtual void setPolygonType(PolygonType type)
virtual void setOuterRadius(double outer_radius)
boost::shared_ptr< GISCircleVisualizer > Ptr
boost::shared_ptr< TextureObject > Ptr
boost::shared_ptr< SimpleCircleFacingVisualizer > Ptr
SquareObject(Ogre::SceneManager *manager, double outer_radius, double inner_radius, std::string name)
Ogre::SceneManager * scene_manager_
anonymous
virtual void setText(std::string text)
virtual void setInnerRadius(double inner_radius)


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Sat Mar 20 2021 03:03:18