##

ModelData.hh
Go to the documentation of this file.
/*
* Copyright (C) 2013 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_MODEL_DATA_HH_
#define _GAZEBO_MODEL_DATA_HH_
#include <map>
#include <string>
#include <vector>
#include "gazebo/rendering/Visual.hh"
#include "gazebo/gui/model/LinkInspector.hh"
namespace boost
{
class recursive_mutex;
}
namespace gazebo
{
namespace gui
{
class LinkInspector;
class ModelPluginInspector;
class GZ_GUI_VISIBLE ModelData
{
public: static std::string GetTemplateSDFString();
public: static double GetEditTransparency();
public: static void UpdateRenderGroup(rendering::VisualPtr _visual);
};
class GZ_GUI_VISIBLE NestedModelData
{
public: void SetName(const std::string &_name);
public: std::string Name() const;
public: void SetPose(const ignition::math::Pose3d &_pose);
public: ignition::math::Pose3d Pose() const;
public: int Depth() const;
public: sdf::ElementPtr modelSDF;
public: rendering::VisualPtr modelVisual;
public: std::map<std::string, rendering::VisualWeakPtr> models;
public: std::map<std::string, rendering::VisualWeakPtr> links;
};
class GZ_GUI_VISIBLE LinkData : public QObject
{
Q_OBJECT
public: LinkData();
public: ~LinkData();
public: std::string Name() const;
public: void SetName(const std::string &_name);
public: ignition::math::Pose3d Pose() const;
public: void SetPose(const ignition::math::Pose3d &_pose3d);
public: void Load(sdf::ElementPtr _sdf);
public: const std::map<std::string, ignition::math::Vector3d> &Scales()
const;
public: void UpdateInspectorScale();
public: void SetScales(
const std::map<std::string, ignition::math::Vector3d> &_scales);
public: void AddVisual(rendering::VisualPtr _visual);
public: void AddCollision(rendering::VisualPtr _collisionVis,
const msgs::Collision *_msg = NULL);
public: void UpdateConfig();
public: LinkData *Clone(const std::string &_newName);
public slots: void ShowCollisions(const bool _show);
public slots: void ShowVisuals(const bool _show);
public slots: void ShowLinkFrame(const bool _show);
public: static double ComputeVolume(const msgs::Collision &_collision);
public: static ignition::math::Vector3d ComputeMomentOfInertia(
const msgs::Collision &_collision, const double _mass);
public: double ComputeVolume() const;
public: void SetLinkVisual(const rendering::VisualPtr _visual);
public: rendering::VisualPtr LinkVisual() const;
private: void Update();
private: bool Apply();
private slots: void OnAccept();
private slots: void OnApply();
private slots: void OnAddVisual(const std::string &_name);
private slots: void OnAddCollision(const std::string &_name);
private slots: void OnRemoveVisual(const std::string &_name);
private slots: void OnRemoveCollision(const std::string &_name);
private slots: void OnShowCollision(const bool _show,
const std::string &_name);
private slots: void OnShowVisual(const bool _show,
const std::string &_name);
private slots: void OnInspectorOpened();
private: std::vector<event::ConnectionPtr> connections;
private: boost::recursive_mutex *updateMutex;
public: sdf::ElementPtr linkSDF;
private: double mass;
private: double inertiaIxx;
private: double inertiaIyy;
private: double inertiaIzz;
public: std::map<std::string, ignition::math::Vector3d> scales;
private: rendering::VisualPtr linkVisual;
public: std::map<rendering::VisualPtr, msgs::Visual> visuals;
public: std::map<rendering::VisualPtr, msgs::Visual> deletedVisuals;
public: std::vector<msgs::Visual *> visualUpdateMsgs;
public: std::vector<msgs::Collision *> collisionUpdateMsgs;
public: std::map<rendering::VisualPtr, msgs::Collision> collisions;
public: std::map<rendering::VisualPtr, msgs::Collision> deletedCollisions;
public: rendering::LinkFrameVisualPtr linkFrameVis;
public: LinkInspector *inspector;
public: bool nested;
public: bool showCollisions = true;
public: bool showVisuals = true;
public: bool showLinkFrame = true;
};
class GZ_GUI_VISIBLE ModelPluginData : public QObject
{
Q_OBJECT
public: ModelPluginData();
public: ~ModelPluginData();
public: void Load(sdf::ElementPtr _pluginElem);
public: ModelPluginInspector *inspector;
public: sdf::ElementPtr modelPluginSDF;
};
}
}
#endif
gazebo::gui::LinkData::Pose
ignition::math::Pose3d Pose() const
Get the pose of the link.
gazebo::gui::LinkData::linkSDF
sdf::ElementPtr linkSDF
SDF representing the link data.
Definition: ModelData.hh:250
gazebo::gui::LinkData::Load
void Load(sdf::ElementPtr _sdf)
Load the link with data from SDF.
gazebo::gui::LinkData::SetScales
void SetScales(const std::map< std::string, ignition::math::Vector3d > &_scales)
Set the scales of the link.
gazebo::gui::ModelPluginData::modelPluginSDF
sdf::ElementPtr modelPluginSDF
SDF representing the model plugin data.
Definition: ModelData.hh:327
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::gui::LinkData::Clone
LinkData * Clone(const std::string &_newName)
Clone the link data.
NULL
#define NULL
Definition: CommonTypes.hh:31
gazebo::gui::LinkData::visuals
std::map< rendering::VisualPtr, msgs::Visual > visuals
Visuals of the link.
Definition: ModelData.hh:272
gazebo::gui::LinkData::SetPose
void SetPose(const ignition::math::Pose3d &_pose3d)
Set the pose of the link.
gazebo::gui::LinkData::AddVisual
void AddVisual(rendering::VisualPtr _visual)
Add a visual to the link.
gazebo::gui::NestedModelData::Name
std::string Name() const
Get the unscoped name of the model.
gazebo::gui::LinkData::visualUpdateMsgs
std::vector< msgs::Visual * > visualUpdateMsgs
Msgs for updating visuals.
Definition: ModelData.hh:278
gazebo::gui::LinkData::linkFrameVis
rendering::LinkFrameVisualPtr linkFrameVis
Link frame visual.
Definition: ModelData.hh:290
boost
Definition: JointMaker.hh:44
gazebo::gui::LinkData::showLinkFrame
bool showLinkFrame
True if all link frames are currently visible, false otherwise.
Definition: ModelData.hh:305
gazebo::gui::NestedModelData::modelSDF
sdf::ElementPtr modelSDF
SDF representing the model data.
Definition: ModelData.hh:80
gazebo::gui::ModelData::GetTemplateSDFString
static std::string GetTemplateSDFString()
Get a template SDF string of a simple model.
gazebo::gui::ModelPluginData::inspector
ModelPluginInspector * inspector
Inspector for configuring model plugin properties.
Definition: ModelData.hh:324
gazebo::gui::NestedModelData::SetPose
void SetPose(const ignition::math::Pose3d &_pose)
Set the pose of the model.
gazebo::gui::LinkData::ShowVisuals
void ShowVisuals(const bool _show)
Show or hide visual visuals.
gazebo::gui::LinkData::UpdateInspectorScale
void UpdateInspectorScale()
Update the scale of all the inspectors, making the necessary conversions to update inertial informati...
gazebo::gui::ModelPluginData::Load
void Load(sdf::ElementPtr _pluginElem)
Load data from the plugin SDF.
gazebo::gui::LinkData::AddCollision
void AddCollision(rendering::VisualPtr _collisionVis, const msgs::Collision *_msg=NULL)
Add a collision to the link.
gazebo::gui::LinkData::Scales
const std::map< std::string, ignition::math::Vector3d > & Scales() const
Get the scale of all of the link's children.
gazebo::gui::LinkData::collisionUpdateMsgs
std::vector< msgs::Collision * > collisionUpdateMsgs
Msgs for updating collision visuals.
Definition: ModelData.hh:281
gazebo::gui::LinkData::~LinkData
~LinkData()
Destructor.
gazebo::gui::ModelData::UpdateRenderGroup
static void UpdateRenderGroup(rendering::VisualPtr _visual)
gazebo::gui::LinkData::showCollisions
bool showCollisions
True if all collisions are currently visible, false otherwise.
Definition: ModelData.hh:299
gazebo::gui::NestedModelData
Helper class to store nested models data.
Definition: ModelData.hh:57
Visual.hh
gazebo::gui::LinkData::deletedCollisions
std::map< rendering::VisualPtr, msgs::Collision > deletedCollisions
Deleted collisions of the link.
Definition: ModelData.hh:287
gazebo::gui::NestedModelData::models
std::map< std::string, rendering::VisualWeakPtr > models
Models inside this model.
Definition: ModelData.hh:86
LinkInspector.hh
gazebo::gui::ModelPluginData::~ModelPluginData
~ModelPluginData()
Destructor.
gazebo::gui::LinkData::collisions
std::map< rendering::VisualPtr, msgs::Collision > collisions
Collisions of the link.
Definition: ModelData.hh:284
gazebo::gui::NestedModelData::modelVisual
rendering::VisualPtr modelVisual
Visual representing this model.
Definition: ModelData.hh:83
gazebo::rendering::LinkFrameVisualPtr
std::shared_ptr< LinkFrameVisual > LinkFrameVisualPtr
Definition: RenderTypes.hh:182
gazebo::gui::NestedModelData::SetName
void SetName(const std::string &_name)
Set the name of the model.
gui
gui
Definition: KeyEventHandler.hh:29
gazebo::gui::LinkData::ComputeMomentOfInertia
static ignition::math::Vector3d ComputeMomentOfInertia(const msgs::Collision &_collision, const double _mass)
Computes mass moment of inertia for a link.
gazebo::gui::LinkData::nested
bool nested
Flag set to true if this is a link of a nested model.
Definition: ModelData.hh:296
gazebo::gui::LinkData::Name
std::string Name() const
Get the name of the link.
gazebo::gui::LinkData::LinkVisual
rendering::VisualPtr LinkVisual() const
Get the visual for the link.
gazebo::gui::LinkData::ComputeVolume
double ComputeVolume() const
Computes the volume of the link.
gazebo::gui::ModelPluginData
Helper class to store model plugin data.
Definition: ModelData.hh:309
gazebo::gui::LinkData::deletedVisuals
std::map< rendering::VisualPtr, msgs::Visual > deletedVisuals
Deleted visuals of the link.
Definition: ModelData.hh:275
gazebo::gui::NestedModelData::Depth
int Depth() const
Get the depth of the nested model.
gazebo::gui::NestedModelData::links
std::map< std::string, rendering::VisualWeakPtr > links
Links inside this model.
Definition: ModelData.hh:89
gazebo::gui::LinkData::SetName
void SetName(const std::string &_name)
Set the name of the link.
gazebo::gui::LinkData
Helper class to store link data.
Definition: ModelData.hh:94
gazebo::gui::ModelData
Definition: ModelData.hh:39
gazebo::gui::LinkData::ShowCollisions
void ShowCollisions(const bool _show)
Show or hide collision visuals.
gazebo::gui::NestedModelData::Pose
ignition::math::Pose3d Pose() const
Get the pose of the nested model.
gazebo::gui::LinkData::SetLinkVisual
void SetLinkVisual(const rendering::VisualPtr _visual)
Set the visual for the link.
gazebo::rendering::VisualPtr
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
gazebo::gui::ModelPluginInspector
Inspector for model plugin properties.
Definition: ModelPluginInspector.hh:34
gazebo::gui::LinkData::inspector
LinkInspector * inspector
Inspector for configuring link properties.
Definition: ModelData.hh:293
gazebo::gui::LinkData::showVisuals
bool showVisuals
True if all visuals are currently visible, false otherwise.
Definition: ModelData.hh:302
gazebo::gui::LinkData::UpdateConfig
void UpdateConfig()
Update the inspector widget if necessary.
gazebo::gui::LinkData::ShowLinkFrame
void ShowLinkFrame(const bool _show)
Show or hide link frame visuals.
gazebo::gui::LinkInspector
Definition: LinkInspector.hh:39
gazebo::gui::LinkData::scales
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:266
gazebo::gui::ModelData::GetEditTransparency
static double GetEditTransparency()
Get the default transparency setting for entities in model editor.
gazebo::gui::LinkData::LinkData
LinkData()
Constructor.
gazebo::gui::ModelPluginData::ModelPluginData
ModelPluginData()
Constructor.