Go to the documentation of this file.
18 #ifndef GAZEBO_PHYSICS_BASE_HH_
19 #define GAZEBO_PHYSICS_BASE_HH_
21 #include <boost/enable_shared_from_this.hpp>
72 class GZ_PHYSICS_VISIBLE
Base :
public boost::enable_shared_from_this<Base>
86 COLLISION = 0x00000008,
95 BALL_JOINT = 0x00000080,
97 HINGE2_JOINT = 0x00000100,
99 HINGE_JOINT = 0x00000200,
101 SLIDER_JOINT = 0x00000400,
103 SCREW_JOINT = 0x00000800,
105 UNIVERSAL_JOINT = 0x00001000,
107 GEARBOX_JOINT = 0x00002000,
109 FIXED_JOINT = 0x00004000,
117 BOX_SHAPE = 0x00020000,
119 CYLINDER_SHAPE = 0x00040000,
121 HEIGHTMAP_SHAPE = 0x00080000,
123 MAP_SHAPE = 0x00100000,
125 MULTIRAY_SHAPE = 0x00200000,
127 RAY_SHAPE = 0x00400000,
129 PLANE_SHAPE = 0x00800000,
131 SPHERE_SHAPE = 0x01000000,
133 MESH_SHAPE = 0x02000000,
135 POLYLINE_SHAPE = 0x04000000,
138 SENSOR_COLLISION = 0x10000000
146 public:
virtual ~
Base();
150 public:
virtual void Load(sdf::ElementPtr _sdf);
153 public:
virtual void Fini();
159 public:
virtual void Reset();
171 public:
virtual void UpdateParameters(sdf::ElementPtr _sdf);
175 public:
virtual void SetName(
const std::string &_name);
179 public: std::string GetName()
const;
183 public: uint32_t GetId()
const;
188 public:
void SetSaveable(
bool _v);
193 public:
bool GetSaveable()
const;
197 public:
int GetParentId()
const;
201 public:
void SetParent(
BasePtr _parent);
205 public:
BasePtr GetParent()
const;
209 public:
void AddChild(
BasePtr _child);
213 public:
virtual void RemoveChild(
unsigned int _id);
216 public:
void RemoveChildren();
220 public:
unsigned int GetChildCount()
const;
227 public:
BasePtr GetById(
unsigned int _id)
const;
233 public:
BasePtr GetByName(
const std::string &_name);
238 public:
BasePtr GetChild(
unsigned int _i)
const;
243 public:
BasePtr GetChild(
const std::string &_name);
247 public:
void RemoveChild(
const std::string &_name);
256 public:
void AddType(EntityType _type);
262 public:
bool HasType(
const EntityType &_t)
const;
266 public:
unsigned int GetType()
const;
270 public: std::string TypeStr()
const;
278 public: std::string GetScopedName(
bool _prependWorldName =
false)
const;
290 public:
void Print(
const std::string &_prefix);
295 public:
virtual bool SetSelected(
bool _show);
299 public:
bool IsSelected()
const;
305 public:
bool operator ==(
const Base &_ent)
const;
310 public:
void SetWorld(
const WorldPtr &_newWorld);
314 public:
const WorldPtr &GetWorld()
const;
318 public:
virtual const sdf::ElementPtr GetSDF();
323 public:
virtual std::optional<sdf::SemanticPose> SDFSemanticPose()
const;
331 public: ignition::math::Pose3d SDFPoseRelativeToParent()
const;
334 protected:
virtual void RegisterIntrospectionItems();
337 protected:
virtual void UnregisterIntrospectionItems();
342 protected:
void ComputeScopedName();
345 protected: sdf::ElementPtr
sdf;
360 private:
bool saveable;
363 private: uint32_t id;
366 private:
unsigned int type;
369 private: std::string typeStr;
372 private:
bool selected;
375 private: std::string name;
378 private: std::string scopedName;
void ComputeScopedName()
Compute the scoped name of this object based on its parents.
RayShape type.
Definition: Base.hh:127
MultiRayShape type.
Definition: Base.hh:125
virtual void Update()
Update the object.
Definition: Base.hh:166
unsigned int GetChildCount() const
Get the number of children.
A complete URI.
Definition: URI.hh:176
virtual void Fini()
Finialize the object.
virtual void UpdateParameters(sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
BasePtr GetByName(const std::string &_name)
Get by name.
common::URI URI() const
Return the common::URI of this entity.
ScrewJoint type.
Definition: Base.hh:103
bool operator==(const Base &_ent) const
Returns true if the entities are the same.
void Print(const std::string &_prefix)
Print this object to screen via gzmsg.
Forward declarations for the common classes.
Definition: Animation.hh:26
Base type.
Definition: Base.hh:78
Actor type.
Definition: Base.hh:112
GearboxJoint type.
Definition: Base.hh:107
Model type.
Definition: Base.hh:82
BasePtr GetParent() const
Get the parent.
BallJoint type.
Definition: Base.hh:95
MeshShape type.
Definition: Base.hh:133
virtual void SetName(const std::string &_name)
Set the name of the entity.
int GetParentId() const
Return the ID of the parent.
bool IsSelected() const
True if the entity is selected by the user.
MapShape type.
Definition: Base.hh:123
default namespace for gazebo
HingeJoint type.
Definition: Base.hh:99
uint32_t GetId() const
Return the ID of this entity.
Joint type.
Definition: Base.hh:93
std::string TypeStr() const
Get the string name for the entity type.
BasePtr parent
Parent of this entity.
Definition: Base.hh:348
virtual void Reset()
Reset the object.
const WorldPtr & GetWorld() const
Get the World this object is in.
virtual void Load(sdf::ElementPtr _sdf)
Load.
virtual void UnregisterIntrospectionItems()
Unregister items in the introspection service.
virtual void Init()
Initialize the object.
Definition: Base.hh:156
FixedJoint type.
Definition: Base.hh:109
std::string GetScopedName(bool _prependWorldName=false) const
Return the name of this entity with the model scope model1::...::modelN::entityName.
Base class for most physics classes.
Definition: Base.hh:72
Collision type.
Definition: Base.hh:86
std::string GetName() const
Return the name of the entity.
void RemoveChildren()
Remove all children.
UniversalJoint type.
Definition: Base.hh:105
virtual void RemoveChild(unsigned int _id)
Remove a child from this entity.
virtual std::optional< sdf::SemanticPose > SDFSemanticPose() const
Get the SDF SemanticPose object associated with the pose of this object.
Light type.
Definition: Base.hh:88
Base_V children
Children of this entity.
Definition: Base.hh:351
virtual const sdf::ElementPtr GetSDF()
Get the SDF values for the object.
void AddChild(BasePtr _child)
Add a child to this entity.
Link type.
Definition: Base.hh:84
Hing2Joint type.
Definition: Base.hh:97
HeightmapShape type.
Definition: Base.hh:121
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:78
void SetSaveable(bool _v)
Set whether the object should be "saved", when the user selects to save the world to xml.
SliderJoint type.
Definition: Base.hh:101
sdf::ElementPtr sdf
The SDF values for this object.
Definition: Base.hh:345
CylinderShape type.
Definition: Base.hh:119
Visual type.
Definition: Base.hh:90
unsigned int GetType() const
Get the full type definition.
BoxShape type.
Definition: Base.hh:117
void AddType(EntityType _type)
Add a type specifier.
ignition::math::Pose3d SDFPoseRelativeToParent() const
Get the SDF pose of the object according to the sdf 1.6 convention.
Base(BasePtr _parent)
Constructor.
Entity type.
Definition: Base.hh:80
SphereShape type.
Definition: Base.hh:131
Base class for all physics objects in Gazebo.
Definition: Entity.hh:52
std::vector< common::URI > introspectionItems
All the introspection items regsitered for this.
Definition: Base.hh:357
Shape type.
Definition: Base.hh:115
void SetWorld(const WorldPtr &_newWorld)
Set the world this object belongs to.
PolylineShape type.
Definition: Base.hh:135
PlaneShape type.
Definition: Base.hh:129
bool HasType(const EntityType &_t) const
Returns true if this object's type definition has the given type.
EntityType
Unique identifiers for all entity types.
Definition: Base.hh:76
virtual void RegisterIntrospectionItems()
Register items in the introspection service.
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:90
void SetParent(BasePtr _parent)
Set the parent.
virtual ~Base()
Destructor.
bool GetSaveable() const
Get whether the object should be "saved", when the user selects to save the world to xml.
virtual bool SetSelected(bool _show)
Set whether this entity has been selected by the user through the gui.
std::vector< BasePtr > Base_V
Definition: PhysicsTypes.hh:202
static std::string EntityTypename[]
String names for the different entity types.
Definition: Base.hh:42
BasePtr GetChild(unsigned int _i) const
Get a child by index.
Indicates a collision shape used for sensing.
Definition: Base.hh:138
WorldPtr world
Pointer to the world.
Definition: Base.hh:354