PersonVisual.h
Go to the documentation of this file.
1 /*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2013-2015, Timm Linder, Social Robotics Lab, University of Freiburg
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright notice,
13 * this list of conditions and the following disclaimer in the documentation
14 * and/or other materials provided with the distribution.
15 * * Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 
31 #ifndef PERSON_VISUAL_H
32 #define PERSON_VISUAL_H
33 
36 
37 #include <OgreSceneNode.h>
38 #include <OgreAnimation.h>
39 #include <OgreSharedPtr.h>
40 #include <OgreEntity.h>
41 
43 #include <boost/algorithm/string/predicate.hpp>
44 #include <boost/filesystem.hpp>
45 
46 namespace fs = boost::filesystem;
47 
48 namespace tuw_object_rviz {
49  // Abstract class for visuals which have got an adjustable line width
50  class HasLineWidth {
51  public:
52  virtual void setLineWidth(double lineWidth) = 0;
53  };
54 
55  // Default arguments that need to be supplied to all types of PersonVisual
57  PersonVisualDefaultArgs(Ogre::SceneManager* sceneManager, Ogre::SceneNode* parentNode) : sceneManager(sceneManager), parentNode(parentNode) {}
58  Ogre::SceneManager* sceneManager;
59  Ogre::SceneNode* parentNode;
60  };
61 
63  class PersonVisual {
64  public:
66 
67  virtual ~PersonVisual();
68 
69  void setPosition(const Ogre::Vector3& position);
70 
71  const Ogre::Vector3& getPosition() const;
72 
73  void setOrientation(const Ogre::Quaternion& orientation);
74 
75  const Ogre::Quaternion& getOrientation() const;
76 
77  virtual void setScalingFactor(double scalingFactor);
78 
79  void setVisible(bool visible);
80 
81  Ogre::SceneNode* getParentSceneNode();
82 
83  virtual void update(float deltaTime);
84 
85  virtual void setColor(const Ogre::ColourValue& c) = 0;
86 
87  virtual Ogre::ColourValue& getColor() = 0;
88 
89  virtual double getHeight() = 0;
90 
91  protected:
92  Ogre::SceneManager* m_sceneManager;
93  Ogre::SceneNode *m_sceneNode, *m_parentSceneNode;
94  Ogre::ColourValue m_color;
95  };
96 
98  class RosPackagePathResourceLoadingListener : public Ogre::ResourceLoadingListener
99  {
100  public:
101  RosPackagePathResourceLoadingListener(const fs::path& parentPath);
102 
104  virtual Ogre::DataStreamPtr resourceLoading(const Ogre::String &name, const Ogre::String &group, Ogre::Resource *resource);
105 
106  virtual void resourceStreamOpened(const Ogre::String &name, const Ogre::String &group, Ogre::Resource *resource, Ogre::DataStreamPtr& dataStream);
107 
108  virtual bool resourceCollision(Ogre::Resource *resource, Ogre::ResourceManager *resourceManager);
109 
110  private:
111  const fs::path& _parentPath;
113  };
114 
117  public:
119 
120  virtual ~CylinderPersonVisual();
121 
122  virtual void setColor(const Ogre::ColourValue& c);
123 
124  virtual Ogre::ColourValue& getColor();
125 
126  virtual double getHeight();
127 
128  private:
129  rviz::Shape *m_bodyShape, *m_headShape;
130  };
131 
134  public:
135  BoundingBoxPersonVisual ( const PersonVisualDefaultArgs& args, double height = 1.75, double width = 0.6, double scalingFactor = 1.0 );
136 
137  virtual ~BoundingBoxPersonVisual();
138 
139  virtual void setColor(const Ogre::ColourValue& c);
140 
141  virtual Ogre::ColourValue& getColor();
142 
143  virtual double getHeight();
144 
145  virtual void setLineWidth(double lineWidth);
146 
147  /*
148  virtual void setScalingFactor(double scalingFactor);
149  */
150 
151  protected:
152  virtual void generateWireframe();
153 
154  private:
156  double m_width, m_height, m_scalingFactor, m_lineWidth;
157  };
158 
159 
162 
163  private:
164  Ogre::SceneNode *m_childSceneNode;
165  Ogre::Entity* entity_;
166  Ogre::AnimationState* m_animationState;
167  std::set<Ogre::MaterialPtr> materials_;
169  public:
171 
172  virtual ~MeshPersonVisual();
173 
174  virtual void update(float deltaTime);
175 
176  virtual void setColor(const Ogre::ColourValue& c);
177 
178  virtual Ogre::ColourValue& getColor();
179 
180  void setAnimationState(const std::string& nameOfAnimationState);
181 
182  void setWalkingSpeed(float walkingSpeed);
183 
184  virtual double getHeight() {
185  return 1.75;
186  }
187 
188  virtual void setScalingFactor(double scalingFactor) {
189  // Not supported (for some reason causes the mesh to be mirrored vertically).
190  }
191  };
192 
193 }
194 
195 #endif // PERSON_VISUAL_H
Visualization of a person as a mesh (walking human)
Definition: PersonVisual.h:161
Ogre::AnimationState * m_animationState
Definition: PersonVisual.h:166
Ogre::ColourValue m_color
Definition: PersonVisual.h:94
Ogre::SceneManager * m_sceneManager
Definition: PersonVisual.h:92
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
Ogre::SceneNode * m_childSceneNode
Definition: PersonVisual.h:164
Ogre::SceneNode * m_sceneNode
Definition: PersonVisual.h:93
Visualization of a person as a wireframe bounding box.
Definition: PersonVisual.h:133
std::set< Ogre::MaterialPtr > materials_
Definition: PersonVisual.h:167
PersonVisualDefaultArgs(Ogre::SceneManager *sceneManager, Ogre::SceneNode *parentNode)
Definition: PersonVisual.h:57
Visualization of a person as cylinder (body) + sphere (head)
Definition: PersonVisual.h:116
resource_retriever::MemoryResource _lastResource
Definition: PersonVisual.h:112
virtual void setScalingFactor(double scalingFactor)
Definition: PersonVisual.h:188
Base class for all person visualization types.
Definition: PersonVisual.h:63
virtual void setLineWidth(double lineWidth)=0


tuw_object_rviz
Author(s): Florian Beck
autogenerated on Mon Jun 10 2019 15:40:17