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
27namespace boost
28{
29 class recursive_mutex;
30}
31
32namespace 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: std::string Name() const;
66
69 public: void SetPose(const ignition::math::Pose3d &_pose);
70
73 public: ignition::math::Pose3d Pose() const;
74
77 public: int Depth() const;
78
80 public: sdf::ElementPtr modelSDF;
81
84
86 public: std::map<std::string, rendering::VisualWeakPtr> models;
87
89 public: std::map<std::string, rendering::VisualWeakPtr> links;
90 };
91
94 class GZ_GUI_VISIBLE LinkData : public QObject
95 {
96 Q_OBJECT
97
99 public: LinkData();
100
102 public: ~LinkData();
103
106 public: std::string Name() const;
107
110 public: void SetName(const std::string &_name);
111
114 public: ignition::math::Pose3d Pose() const;
115
118 public: void SetPose(const ignition::math::Pose3d &_pose3d);
119
122 public: void Load(sdf::ElementPtr _sdf);
123
126 public: const std::map<std::string, ignition::math::Vector3d> &Scales()
127 const;
128
134 public: void UpdateInspectorScale();
135
140 public: void SetScales(
141 const std::map<std::string, ignition::math::Vector3d> &_scales);
142
145 public: void AddVisual(rendering::VisualPtr _visual);
146
150 public: void AddCollision(rendering::VisualPtr _collisionVis,
151 const msgs::Collision *_msg = NULL);
152
154 public: void UpdateConfig();
155
159 public: LinkData *Clone(const std::string &_newName);
160
163 public slots: void ShowCollisions(const bool _show);
164
167 public slots: void ShowVisuals(const bool _show);
168
171 public slots: void ShowLinkFrame(const bool _show);
172
176 public: static double ComputeVolume(const msgs::Collision &_collision);
177
182 public: static ignition::math::Vector3d ComputeMomentOfInertia(
183 const msgs::Collision &_collision, const double _mass);
184
187 public: double ComputeVolume() const;
188
191 public: void SetLinkVisual(const rendering::VisualPtr _visual);
192
196
198 private: void Update();
199
202 private: bool Apply();
203
206 private slots: void OnAccept();
207
210 private slots: void OnApply();
211
214 private slots: void OnAddVisual(const std::string &_name);
215
220 private slots: void OnAddCollision(const std::string &_name,
221 const std::string &_collisionShape);
222
225 private slots: void OnRemoveVisual(const std::string &_name);
226
229 private slots: void OnRemoveCollision(const std::string &_name);
230
234 private slots: void OnShowCollision(const bool _show,
235 const std::string &_name);
236
240 private slots: void OnShowVisual(const bool _show,
241 const std::string &_name);
242
244 private slots: void OnInspectorOpened();
245
247 private: std::vector<event::ConnectionPtr> connections;
248
250 private: boost::recursive_mutex *updateMutex;
251
253 public: sdf::ElementPtr linkSDF;
254
256 private: double mass;
257
259 private: double inertiaIxx;
260
262 private: double inertiaIyy;
263
265 private: double inertiaIzz;
266
269 public: std::map<std::string, ignition::math::Vector3d> scales;
270
272 private: rendering::VisualPtr linkVisual;
273
275 public: std::map<rendering::VisualPtr, msgs::Visual> visuals;
276
278 public: std::map<rendering::VisualPtr, msgs::Visual> deletedVisuals;
279
281 public: std::vector<msgs::Visual *> visualUpdateMsgs;
282
284 public: std::vector<msgs::Collision *> collisionUpdateMsgs;
285
287 public: std::map<rendering::VisualPtr, msgs::Collision> collisions;
288
290 public: std::map<rendering::VisualPtr, msgs::Collision> deletedCollisions;
291
294
297
299 public: bool nested;
300
302 public: bool showCollisions = true;
303
305 public: bool showVisuals = true;
306
308 public: bool showLinkFrame = true;
309 };
310
312 class GZ_GUI_VISIBLE ModelPluginData : public QObject
313 {
314 Q_OBJECT
315
318
321
324 public: void Load(sdf::ElementPtr _pluginElem);
325
328
330 public: sdf::ElementPtr modelPluginSDF;
331 };
332 }
333}
334
335#endif
#define NULL
Definition CommonTypes.hh:31
gui
Definition KeyEventHandler.hh:29
Helper class to store link data.
Definition ModelData.hh:95
LinkInspector * inspector
Inspector for configuring link properties.
Definition ModelData.hh:296
std::map< rendering::VisualPtr, msgs::Visual > deletedVisuals
Deleted visuals of the link.
Definition ModelData.hh:278
bool showCollisions
True if all collisions are currently visible, false otherwise.
Definition ModelData.hh:302
void SetName(const std::string &_name)
Set the name of the link.
std::map< rendering::VisualPtr, msgs::Collision > deletedCollisions
Deleted collisions of the link.
Definition ModelData.hh:290
void AddCollision(rendering::VisualPtr _collisionVis, const msgs::Collision *_msg=NULL)
Add a collision to the link.
sdf::ElementPtr linkSDF
SDF representing the link data.
Definition ModelData.hh:253
void SetLinkVisual(const rendering::VisualPtr _visual)
Set the visual for the link.
std::string Name() const
Get the name of the link.
void AddVisual(rendering::VisualPtr _visual)
Add a visual to the link.
bool showLinkFrame
True if all link frames are currently visible, false otherwise.
Definition ModelData.hh:308
void ShowLinkFrame(const bool _show)
Show or hide link frame visuals.
void ShowCollisions(const bool _show)
Show or hide collision visuals.
rendering::LinkFrameVisualPtr linkFrameVis
Link frame visual.
Definition ModelData.hh:293
void UpdateInspectorScale()
Update the scale of all the inspectors, making the necessary conversions to update inertial informati...
void SetScales(const std::map< std::string, ignition::math::Vector3d > &_scales)
Set the scales of the link.
bool showVisuals
True if all visuals are currently visible, false otherwise.
Definition ModelData.hh:305
double ComputeVolume() const
Computes the volume of the link.
static ignition::math::Vector3d ComputeMomentOfInertia(const msgs::Collision &_collision, const double _mass)
Computes mass moment of inertia for a link.
std::vector< msgs::Collision * > collisionUpdateMsgs
Msgs for updating collision visuals.
Definition ModelData.hh:284
void ShowVisuals(const bool _show)
Show or hide visual visuals.
void UpdateConfig()
Update the inspector widget if necessary.
std::map< std::string, ignition::math::Vector3d > scales
Scale of all collisions and visuals in the link, indexed by their visual's names.
Definition ModelData.hh:269
LinkData()
Constructor.
std::map< rendering::VisualPtr, msgs::Collision > collisions
Collisions of the link.
Definition ModelData.hh:287
~LinkData()
Destructor.
rendering::VisualPtr LinkVisual() const
Get the visual for the link.
ignition::math::Pose3d Pose() const
Get the pose of the link.
bool nested
Flag set to true if this is a link of a nested model.
Definition ModelData.hh:299
static double ComputeVolume(const msgs::Collision &_collision)
Computes the volume of a link.
std::map< rendering::VisualPtr, msgs::Visual > visuals
Visuals of the link.
Definition ModelData.hh:275
const std::map< std::string, ignition::math::Vector3d > & Scales() const
Get the scale of all of the link's children.
void Load(sdf::ElementPtr _sdf)
Load the link with data from SDF.
void SetPose(const ignition::math::Pose3d &_pose3d)
Set the pose of the link.
std::vector< msgs::Visual * > visualUpdateMsgs
Msgs for updating visuals.
Definition ModelData.hh:281
LinkData * Clone(const std::string &_newName)
Clone the link data.
Definition LinkInspector.hh:40
Definition ModelData.hh:40
static std::string GetTemplateSDFString()
Get a template SDF string of a simple model.
static void UpdateRenderGroup(rendering::VisualPtr _visual)
static double GetEditTransparency()
Get the default transparency setting for entities in model editor.
Helper class to store model plugin data.
Definition ModelData.hh:313
ModelPluginInspector * inspector
Inspector for configuring model plugin properties.
Definition ModelData.hh:327
void Load(sdf::ElementPtr _pluginElem)
Load data from the plugin SDF.
sdf::ElementPtr modelPluginSDF
SDF representing the model plugin data.
Definition ModelData.hh:330
Inspector for model plugin properties.
Definition ModelPluginInspector.hh:35
Helper class to store nested models data.
Definition ModelData.hh:58
void SetName(const std::string &_name)
Set the name of the model.
std::string Name() const
Get the unscoped name of the model.
rendering::VisualPtr modelVisual
Visual representing this model.
Definition ModelData.hh:83
sdf::ElementPtr modelSDF
SDF representing the model data.
Definition ModelData.hh:80
std::map< std::string, rendering::VisualWeakPtr > links
Links inside this model.
Definition ModelData.hh:89
ignition::math::Pose3d Pose() const
Get the pose of the nested model.
std::map< std::string, rendering::VisualWeakPtr > models
Models inside this model.
Definition ModelData.hh:86
int Depth() const
Get the depth of the nested model.
void SetPose(const ignition::math::Pose3d &_pose)
Set the pose of the model.
Definition JointMaker.hh:45
std::shared_ptr< LinkFrameVisual > LinkFrameVisualPtr
Definition RenderTypes.hh:182
std::shared_ptr< Visual > VisualPtr
Definition RenderTypes.hh:114
Forward declarations for the common classes.
Definition Animation.hh:27