ModelData.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_MODEL_DATA_HH_
18 #define _GAZEBO_MODEL_DATA_HH_
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 
26 
27 namespace boost
28 {
29  class recursive_mutex;
30 }
31 
32 namespace gazebo
33 {
34  namespace gui
35  {
36  class LinkInspector;
37  class ModelPluginInspector;
38 
39  class GZ_GUI_VISIBLE ModelData
40  {
43  public: static std::string GetTemplateSDFString();
44 
47  public: static double GetEditTransparency();
48 
53  public: static void UpdateRenderGroup(rendering::VisualPtr _visual);
54  };
55 
57  class GZ_GUI_VISIBLE NestedModelData
58  {
61  public: void SetName(const std::string &_name);
62 
65  public: void SetPose(const ignition::math::Pose3d &_pose);
66 
69  public: ignition::math::Pose3d Pose() const;
70 
73  public: int Depth() const;
74 
76  public: sdf::ElementPtr modelSDF;
77 
80 
82  public: std::map<std::string, rendering::VisualWeakPtr> models;
83 
85  public: std::map<std::string, rendering::VisualWeakPtr> links;
86  };
87 
90  class GZ_GUI_VISIBLE LinkData : public QObject
91  {
92  Q_OBJECT
93 
95  public: LinkData();
96 
98  public: ~LinkData();
99 
102  public: rendering::VisualPtr LinkVisual() const;
103 
106  public: void SetLinkVisual(rendering::VisualPtr _linkVisual);
107 
110  public: std::string GetName() const;
111 
114  public: void SetName(const std::string &_name);
115 
118  public: ignition::math::Pose3d Pose() const;
119 
122  public: void SetPose(const ignition::math::Pose3d &_pose3d);
123 
126  public: void Load(sdf::ElementPtr _sdf);
127 
130  public: ignition::math::Vector3d Scale() const;
131 
134  public: void SetScale(const ignition::math::Vector3d &_scale);
135 
138  public: void AddVisual(rendering::VisualPtr _visual);
139 
143  public: void AddCollision(rendering::VisualPtr _collisionVis,
144  const msgs::Collision *_msg = NULL);
145 
147  public: void UpdateConfig();
148 
152  public: LinkData *Clone(const std::string &_newName);
153 
156  public slots: void ShowCollisions(const bool _show);
157 
160  public slots: void ShowVisuals(const bool _show);
161 
164  public slots: void ShowLinkFrame(const bool _show);
165 
167  private: void Update();
168 
171  private: bool Apply();
172 
175  private slots: void OnAccept();
176 
179  private slots: void OnApply();
180 
183  private slots: void OnAddVisual(const std::string &_name);
184 
187  private slots: void OnAddCollision(const std::string &_name);
188 
191  private slots: void OnRemoveVisual(const std::string &_name);
192 
195  private slots: void OnRemoveCollision(const std::string &_name);
196 
200  private slots: void OnShowCollision(const bool _show,
201  const std::string &_name);
202 
206  private slots: void OnShowVisual(const bool _show,
207  const std::string &_name);
208 
210  private slots: void OnInspectorOpened();
211 
213  private: std::vector<event::ConnectionPtr> connections;
214 
216  private: boost::recursive_mutex *updateMutex;
217 
219  public: sdf::ElementPtr linkSDF;
220 
222  private: double mass;
223 
225  private: double inertiaIxx;
226 
228  private: double inertiaIyy;
229 
231  private: double inertiaIzz;
232 
234  public: ignition::math::Vector3d scale;
235 
237  private: rendering::VisualPtr linkVisual;
238 
240  public: std::map<rendering::VisualPtr, msgs::Visual> visuals;
241 
243  public: std::map<rendering::VisualPtr, msgs::Visual> deletedVisuals;
244 
246  public: std::vector<msgs::Visual *> visualUpdateMsgs;
247 
249  public: std::vector<msgs::Collision *> collisionUpdateMsgs;
250 
252  public: std::map<rendering::VisualPtr, msgs::Collision> collisions;
253 
255  public: std::map<rendering::VisualPtr, msgs::Collision> deletedCollisions;
256 
259 
262 
264  public: bool nested;
265 
267  public: bool showCollisions = true;
268 
270  public: bool showVisuals = true;
271 
273  public: bool showLinkFrame = true;
274  };
275 
277  class GZ_GUI_VISIBLE ModelPluginData : public QObject
278  {
279  Q_OBJECT
280 
282  public: ModelPluginData();
283 
285  public: ~ModelPluginData();
286 
289  public: void Load(sdf::ElementPtr _pluginElem);
290 
293 
295  public: sdf::ElementPtr modelPluginSDF;
296  };
297  }
298 }
299 
300 #endif
Definition: LinkInspector.hh:38
rendering::VisualPtr modelVisual
Visual representing this model.
Definition: ModelData.hh:79
Definition: JointMaker.hh:46
Forward declarations for the common classes.
Definition: Animation.hh:33
std::map< rendering::VisualPtr, msgs::Visual > visuals
Visuals of the link.
Definition: ModelData.hh:240
sdf::ElementPtr linkSDF
SDF representing the link data.
Definition: ModelData.hh:219
Definition: ModelData.hh:39
std::map< rendering::VisualPtr, msgs::Collision > deletedCollisions
Deleted collisions of the link.
Definition: ModelData.hh:255
std::vector< msgs::Collision * > collisionUpdateMsgs
Msgs for updating collision visuals.
Definition: ModelData.hh:249
ignition::math::Vector3d scale
Scale of link.
Definition: ModelData.hh:234
Helper class to store nested models data.
Definition: ModelData.hh:57
Inspector for model plugin properties.
Definition: ModelPluginInspector.hh:35
std::map< std::string, rendering::VisualWeakPtr > links
Links inside this model.
Definition: ModelData.hh:85
LinkInspector * inspector
Inspector for configuring link properties.
Definition: ModelData.hh:261
ModelPluginInspector * inspector
Inspector for configuring model plugin properties.
Definition: ModelData.hh:292
Helper class to store model plugin data.
Definition: ModelData.hh:277
rendering::LinkFrameVisualPtr linkFrameVis
Link frame visual.
Definition: ModelData.hh:258
Helper class to store link data.
Definition: ModelData.hh:90
sdf::ElementPtr modelPluginSDF
SDF representing the model plugin data.
Definition: ModelData.hh:295
std::shared_ptr< LinkFrameVisual > LinkFrameVisualPtr
Definition: RenderTypes.hh:182
#define NULL
Definition: CommonTypes.hh:33
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
std::map< rendering::VisualPtr, msgs::Visual > deletedVisuals
Deleted visuals of the link.
Definition: ModelData.hh:243
std::map< std::string, rendering::VisualWeakPtr > models
Models inside this model.
Definition: ModelData.hh:82
bool nested
Flag set to true if this is a link of a nested model.
Definition: ModelData.hh:264
sdf::ElementPtr modelSDF
SDF representing the model data.
Definition: ModelData.hh:76
std::vector< msgs::Visual * > visualUpdateMsgs
Msgs for updating visuals.
Definition: ModelData.hh:246
std::map< rendering::VisualPtr, msgs::Collision > collisions
Collisions of the link.
Definition: ModelData.hh:252