Gazebo Sim

API Reference

7.9.0

This class provides wrappers around entities and components which are more convenient and straight-forward to use than dealing with the EntityComponentManager directly. All the functions provided here are meant to be used with a model entity. More...

#include <gz/sim/Model.hh>

Public Member Functions

 Model (const Model &_model)
 Copy constructor. More...
 
 Model (Model &&_model) noexcept
 Move constructor. More...
 
 Model (sim::Entity _entity=kNullEntity)
 Constructor. More...
 
virtual ~Model ()
 Destructor. More...
 
sim::Entity CanonicalLink (const EntityComponentManager &_ecm) const
 Get the model's canonical link entity. More...
 
sim::Entity Entity () const
 Get the entity which this Model is related to. More...
 
sim::Entity JointByName (const EntityComponentManager &_ecm, const std::string &_name)
 Get the ID of a joint entity which is an immediate child of this model. More...
 
uint64_t JointCount (const EntityComponentManager &_ecm) const
 Get the number of joints which are immediate children of this model. More...
 
std::vector< sim::EntityJoints (const EntityComponentManager &_ecm) const
 Get all joints which are immediate children of this model. More...
 
sim::Entity LinkByName (const EntityComponentManager &_ecm, const std::string &_name)
 Get the ID of a link entity which is an immediate child of this model. More...
 
uint64_t LinkCount (const EntityComponentManager &_ecm) const
 Get the number of links which are immediate children of this model. More...
 
std::vector< sim::EntityLinks (const EntityComponentManager &_ecm) const
 Get all links which are immediate children of this model. More...
 
std::vector< sim::EntityModels (const EntityComponentManager &_ecm) const
 Get all models which are immediate children of this model. More...
 
std::string Name (const EntityComponentManager &_ecm) const
 Get the model's unscoped name. More...
 
Modeloperator= (const Model &_model)
 Copy assignment operator. More...
 
Modeloperator= (Model &&_model) noexcept
 Move assignment operator. More...
 
bool SelfCollide (const EntityComponentManager &_ecm) const
 Get whether this model has self-collide enabled. More...
 
void SetWorldPoseCmd (EntityComponentManager &_ecm, const math::Pose3d &_pose)
 Set a command to change the model's pose. More...
 
std::string SourceFilePath (const EntityComponentManager &_ecm) const
 Get the source file where this model came from. If empty, the model wasn't loaded directly from a file, probably from an SDF string. More...
 
bool Static (const EntityComponentManager &_ecm) const
 Get whether this model is static. More...
 
bool Valid (const EntityComponentManager &_ecm) const
 Check whether this model correctly refers to an entity that has a components::Model. More...
 
bool WindMode (const EntityComponentManager &_ecm) const
 Get whether this model has wind enabled. More...
 

Detailed Description

This class provides wrappers around entities and components which are more convenient and straight-forward to use than dealing with the EntityComponentManager directly. All the functions provided here are meant to be used with a model entity.

For example, given a model's entity, to find the value of its name component, one could use the entity-component manager (ecm) directly as follows:

std::string name = ecm.Component<components::Name>(entity)->Data();

Using this class however, the same information can be obtained with a simpler function call:

Model model(entity); std::string name = model.Name(ecm);

Todo:
(louise) Store the ecm instead of passing it at every API call.

Constructor & Destructor Documentation

◆ Model() [1/3]

Model ( sim::Entity  _entity = kNullEntity)
explicit

Constructor.

Parameters
[in]_entityModel entity

◆ Model() [2/3]

Model ( const Model _model)

Copy constructor.

Parameters
[in]_modelModel to copy.

◆ Model() [3/3]

Model ( Model &&  _model)
noexcept

Move constructor.

Parameters
[in]_modelModel to move.

◆ ~Model()

virtual ~Model ( )
virtual

Destructor.

Member Function Documentation

◆ CanonicalLink()

sim::Entity CanonicalLink ( const EntityComponentManager _ecm) const

Get the model's canonical link entity.

Parameters
[in]_ecmEntity-component manager.
Returns
Link entity.

◆ Entity()

sim::Entity Entity ( ) const

Get the entity which this Model is related to.

Returns
Model entity.

◆ JointByName()

sim::Entity JointByName ( const EntityComponentManager _ecm,
const std::string _name 
)

Get the ID of a joint entity which is an immediate child of this model.

Parameters
[in]_ecmEntity-component manager.
[in]_nameJoint name.
Returns
Joint entity.
Todo:
(anyone) Make const

◆ JointCount()

uint64_t JointCount ( const EntityComponentManager _ecm) const

Get the number of joints which are immediate children of this model.

Parameters
[in]_ecmEntity-component manager.
Returns
Number of joints in this model.

◆ Joints()

std::vector<sim::Entity> Joints ( const EntityComponentManager _ecm) const

Get all joints which are immediate children of this model.

Parameters
[in]_ecmEntity-component manager.
Returns
All joints in this model.

◆ LinkByName()

sim::Entity LinkByName ( const EntityComponentManager _ecm,
const std::string _name 
)

Get the ID of a link entity which is an immediate child of this model.

Parameters
[in]_ecmEntity-component manager.
[in]_nameLink name.
Returns
Link entity.
Todo:
(anyone) Make const

◆ LinkCount()

uint64_t LinkCount ( const EntityComponentManager _ecm) const

Get the number of links which are immediate children of this model.

Parameters
[in]_ecmEntity-component manager.
Returns
Number of links in this model.

◆ Links()

std::vector<sim::Entity> Links ( const EntityComponentManager _ecm) const

Get all links which are immediate children of this model.

Parameters
[in]_ecmEntity-component manager.
Returns
All links in this model.

◆ Models()

std::vector<sim::Entity> Models ( const EntityComponentManager _ecm) const

Get all models which are immediate children of this model.

Parameters
[in]_ecmEntity-component manager.
Returns
All models in this model.

◆ Name()

std::string Name ( const EntityComponentManager _ecm) const

Get the model's unscoped name.

Parameters
[in]_ecmEntity-component manager.
Returns
Model's name.

◆ operator=() [1/2]

Model& operator= ( const Model _model)

Copy assignment operator.

Parameters
[in]_modelModel to copy.
Returns
Reference to this.

◆ operator=() [2/2]

Model& operator= ( Model &&  _model)
noexcept

Move assignment operator.

Parameters
[in]_modelModel component to move.
Returns
Reference to this.

◆ SelfCollide()

bool SelfCollide ( const EntityComponentManager _ecm) const

Get whether this model has self-collide enabled.

Parameters
[in]_ecmEntity-component manager.
Returns
True if self-colliding.

◆ SetWorldPoseCmd()

void SetWorldPoseCmd ( EntityComponentManager _ecm,
const math::Pose3d _pose 
)

Set a command to change the model's pose.

Parameters
[in]_ecmEntity-component manager.
[in]_poseNew model pose.

◆ SourceFilePath()

std::string SourceFilePath ( const EntityComponentManager _ecm) const

Get the source file where this model came from. If empty, the model wasn't loaded directly from a file, probably from an SDF string.

Parameters
[in]_ecmEntity-component manager.
Returns
Path to the source SDF file.

◆ Static()

bool Static ( const EntityComponentManager _ecm) const

Get whether this model is static.

Parameters
[in]_ecmEntity-component manager.
Returns
True if static.

◆ Valid()

bool Valid ( const EntityComponentManager _ecm) const

Check whether this model correctly refers to an entity that has a components::Model.

Parameters
[in]_ecmEntity-component manager.
Returns
True if it's a valid model in the manager.

◆ WindMode()

bool WindMode ( const EntityComponentManager _ecm) const

Get whether this model has wind enabled.

Parameters
[in]_ecmEntity-component manager.
Returns
True if wind mode is on.

The documentation for this class was generated from the following file: