##

Base.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 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_PHYSICS_BASE_HH_
#define GAZEBO_PHYSICS_BASE_HH_
#include <boost/enable_shared_from_this.hpp>
#include <string>
#include <vector>
#include <sdf/sdf.hh>
#include "gazebo/common/URI.hh"
#include "gazebo/physics/PhysicsTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
static std::string EntityTypename[] = {
"common",
"entity",
"model",
"actor",
"link",
"collision",
"light",
"visual",
"joint",
"ball",
"hinge2",
"hinge",
"slider",
"universal",
"shape",
"box",
"cylinder",
"heightmap",
"map",
"multiray",
"ray",
"plane",
"sphere",
"trimesh",
"polyline"
};
class GZ_PHYSICS_VISIBLE Base : public boost::enable_shared_from_this<Base>
{
public: enum EntityType {
BASE = 0x00000000,
ENTITY = 0x00000001,
MODEL = 0x00000002,
LINK = 0x00000004,
COLLISION = 0x00000008,
LIGHT = 0x00000010,
VISUAL = 0x00000020,
JOINT = 0x00000040,
BALL_JOINT = 0x00000080,
HINGE2_JOINT = 0x00000100,
HINGE_JOINT = 0x00000200,
SLIDER_JOINT = 0x00000400,
SCREW_JOINT = 0x00000800,
UNIVERSAL_JOINT = 0x00001000,
GEARBOX_JOINT = 0x00002000,
FIXED_JOINT = 0x00004000,
ACTOR = 0x00008000,
SHAPE = 0x00010000,
BOX_SHAPE = 0x00020000,
CYLINDER_SHAPE = 0x00040000,
HEIGHTMAP_SHAPE = 0x00080000,
MAP_SHAPE = 0x00100000,
MULTIRAY_SHAPE = 0x00200000,
RAY_SHAPE = 0x00400000,
PLANE_SHAPE = 0x00800000,
SPHERE_SHAPE = 0x01000000,
MESH_SHAPE = 0x02000000,
POLYLINE_SHAPE = 0x04000000,
SENSOR_COLLISION = 0x10000000
};
public: explicit Base(BasePtr _parent);
public: virtual ~Base();
public: virtual void Load(sdf::ElementPtr _sdf);
public: virtual void Fini();
public: virtual void Init() {}
public: virtual void Reset();
public: virtual void Reset(Base::EntityType _resetType);
public: virtual void Update() {}
public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
public: virtual void SetName(const std::string &_name);
public: std::string GetName() const;
public: uint32_t GetId() const;
public: void SetSaveable(bool _v);
public: bool GetSaveable() const;
public: int GetParentId() const;
public: void SetParent(BasePtr _parent);
public: BasePtr GetParent() const;
public: void AddChild(BasePtr _child);
public: virtual void RemoveChild(unsigned int _id);
public: void RemoveChildren();
public: unsigned int GetChildCount() const;
public: BasePtr GetById(unsigned int _id) const;
public: BasePtr GetByName(const std::string &_name);
public: BasePtr GetChild(unsigned int _i) const;
public: BasePtr GetChild(const std::string &_name);
public: void RemoveChild(const std::string &_name);
public: void RemoveChild(physics::BasePtr _child);
public: void AddType(EntityType _type);
public: bool HasType(const EntityType &_t) const;
public: unsigned int GetType() const;
public: std::string TypeStr() const;
public: std::string GetScopedName(bool _prependWorldName = false) const;
public: common::URI URI() const;
public: void Print(const std::string &_prefix);
public: virtual bool SetSelected(bool _show);
public: bool IsSelected() const;
public: bool operator ==(const Base &_ent) const;
public: void SetWorld(const WorldPtr &_newWorld);
public: const WorldPtr &GetWorld() const;
public: virtual const sdf::ElementPtr GetSDF();
protected: virtual void RegisterIntrospectionItems();
protected: virtual void UnregisterIntrospectionItems();
protected: void ComputeScopedName();
protected: sdf::ElementPtr sdf;
protected: BasePtr parent;
protected: Base_V children;
protected: WorldPtr world;
protected: std::vector<common::URI> introspectionItems;
private: bool saveable;
private: uint32_t id;
private: unsigned int type;
private: std::string typeStr;
private: bool selected;
private: std::string name;
private: std::string scopedName;
protected: friend class Entity;
};
}
}
#endif
gazebo::physics::Base::ComputeScopedName
void ComputeScopedName()
Compute the scoped name of this object based on its parents.
gazebo::physics::Base::RAY_SHAPE
RayShape type.
Definition: Base.hh:126
gazebo::physics::Base::MULTIRAY_SHAPE
MultiRayShape type.
Definition: Base.hh:124
gazebo::physics::Base::Update
virtual void Update()
Update the object.
Definition: Base.hh:165
gazebo::physics::Base::GetChildCount
unsigned int GetChildCount() const
Get the number of children.
gazebo::common::URI
A complete URI.
Definition: URI.hh:176
gazebo::physics::Base::Fini
virtual void Fini()
Finialize the object.
gazebo::physics::Base::UpdateParameters
virtual void UpdateParameters(sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
gazebo::physics::Base::GetByName
BasePtr GetByName(const std::string &_name)
Get by name.
gazebo::physics::Base::URI
common::URI URI() const
Return the common::URI of this entity.
gazebo::physics::Base::SCREW_JOINT
ScrewJoint type.
Definition: Base.hh:102
gazebo::physics::Base::operator==
bool operator==(const Base &_ent) const
Returns true if the entities are the same.
gazebo::physics::Base::Print
void Print(const std::string &_prefix)
Print this object to screen via gzmsg.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::Base::BASE
Base type.
Definition: Base.hh:77
gazebo::physics::Base::ACTOR
Actor type.
Definition: Base.hh:111
gazebo::physics::Base::GEARBOX_JOINT
GearboxJoint type.
Definition: Base.hh:106
gazebo::physics::Base::MODEL
Model type.
Definition: Base.hh:81
gazebo::physics::Base::GetParent
BasePtr GetParent() const
Get the parent.
gazebo::physics::Base::BALL_JOINT
BallJoint type.
Definition: Base.hh:94
gazebo::physics::Base::MESH_SHAPE
MeshShape type.
Definition: Base.hh:132
system.hh
gazebo::physics::Base::SetName
virtual void SetName(const std::string &_name)
Set the name of the entity.
gazebo::physics::Base::GetParentId
int GetParentId() const
Return the ID of the parent.
gazebo::physics::Base::IsSelected
bool IsSelected() const
True if the entity is selected by the user.
gazebo::physics::Base::MAP_SHAPE
MapShape type.
Definition: Base.hh:122
PhysicsTypes.hh
default namespace for gazebo
gazebo::physics::Base::HINGE_JOINT
HingeJoint type.
Definition: Base.hh:98
gazebo::physics::Base::GetId
uint32_t GetId() const
Return the ID of this entity.
gazebo::physics::Base::JOINT
Joint type.
Definition: Base.hh:92
gazebo::physics::Base::TypeStr
std::string TypeStr() const
Get the string name for the entity type.
gazebo::physics::Base::parent
BasePtr parent
Parent of this entity.
Definition: Base.hh:334
gazebo::physics::Base::Reset
virtual void Reset()
Reset the object.
gazebo::physics::Base::GetWorld
const WorldPtr & GetWorld() const
Get the World this object is in.
gazebo::physics::Base::Load
virtual void Load(sdf::ElementPtr _sdf)
Load.
gazebo::physics::Base::UnregisterIntrospectionItems
virtual void UnregisterIntrospectionItems()
Unregister items in the introspection service.
gazebo::physics::Base::Init
virtual void Init()
Initialize the object.
Definition: Base.hh:155
gazebo::physics::Base::FIXED_JOINT
FixedJoint type.
Definition: Base.hh:108
gazebo::physics::Base::GetScopedName
std::string GetScopedName(bool _prependWorldName=false) const
Return the name of this entity with the model scope model1::...::modelN::entityName.
gazebo::physics::Base
Base class for most physics classes.
Definition: Base.hh:71
gazebo::physics::Base::COLLISION
Collision type.
Definition: Base.hh:85
gazebo::physics::Base::GetName
std::string GetName() const
Return the name of the entity.
gazebo::physics::Base::RemoveChildren
void RemoveChildren()
Remove all children.
gazebo::physics::Base::UNIVERSAL_JOINT
UniversalJoint type.
Definition: Base.hh:104
URI.hh
gazebo::physics::Base::RemoveChild
virtual void RemoveChild(unsigned int _id)
Remove a child from this entity.
gazebo::physics::Base::LIGHT
Light type.
Definition: Base.hh:87
gazebo::physics::Base::children
Base_V children
Children of this entity.
Definition: Base.hh:337
gazebo::physics::Base::GetSDF
virtual const sdf::ElementPtr GetSDF()
Get the SDF values for the object.
gazebo::physics::Base::AddChild
void AddChild(BasePtr _child)
Add a child to this entity.
gazebo::physics::Base::LINK
Link type.
Definition: Base.hh:83
gazebo::physics::Base::HINGE2_JOINT
Hing2Joint type.
Definition: Base.hh:96
gazebo::physics::Base::HEIGHTMAP_SHAPE
HeightmapShape type.
Definition: Base.hh:120
gazebo::physics::BasePtr
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
gazebo::physics::Base::SetSaveable
void SetSaveable(bool _v)
Set whether the object should be "saved", when the user selects to save the world to xml.
gazebo::physics::Base::SLIDER_JOINT
SliderJoint type.
Definition: Base.hh:100
gazebo::physics::Base::sdf
sdf::ElementPtr sdf
The SDF values for this object.
Definition: Base.hh:331
gazebo::physics::Base::CYLINDER_SHAPE
CylinderShape type.
Definition: Base.hh:118
gazebo::physics::Base::VISUAL
Visual type.
Definition: Base.hh:89
gazebo::physics::Base::GetType
unsigned int GetType() const
Get the full type definition.
gazebo::physics::Base::BOX_SHAPE
BoxShape type.
Definition: Base.hh:116
gazebo::physics::Base::AddType
void AddType(EntityType _type)
Add a type specifier.
gazebo::physics::Base::Base
Base(BasePtr _parent)
Constructor.
gazebo::physics::Base::ENTITY
Entity type.
Definition: Base.hh:79
gazebo::physics::Base::SPHERE_SHAPE
SphereShape type.
Definition: Base.hh:130
gazebo::physics::Entity
Base class for all physics objects in Gazebo.
Definition: Entity.hh:52
gazebo::physics::Base::introspectionItems
std::vector< common::URI > introspectionItems
All the introspection items regsitered for this.
Definition: Base.hh:343
gazebo::physics::Base::SHAPE
Shape type.
Definition: Base.hh:114
gazebo::physics::Base::SetWorld
void SetWorld(const WorldPtr &_newWorld)
Set the world this object belongs to.
gazebo::physics::Base::POLYLINE_SHAPE
PolylineShape type.
Definition: Base.hh:134
gazebo::physics::Base::PLANE_SHAPE
PlaneShape type.
Definition: Base.hh:128
gazebo::physics::Base::HasType
bool HasType(const EntityType &_t) const
Returns true if this object's type definition has the given type.
gazebo::physics::Base::EntityType
EntityType
Unique identifiers for all entity types.
Definition: Base.hh:75
gazebo::physics::Base::RegisterIntrospectionItems
virtual void RegisterIntrospectionItems()
Register items in the introspection service.
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::physics::Base::SetParent
void SetParent(BasePtr _parent)
Set the parent.
gazebo::physics::Base::~Base
virtual ~Base()
Destructor.
gazebo::physics::Base::GetSaveable
bool GetSaveable() const
Get whether the object should be "saved", when the user selects to save the world to xml.
gazebo::physics::Base::SetSelected
virtual bool SetSelected(bool _show)
Set whether this entity has been selected by the user through the gui.
gazebo::physics::Base_V
std::vector< BasePtr > Base_V
Definition: PhysicsTypes.hh:201
gazebo::physics::EntityTypename
static std::string EntityTypename[]
String names for the different entity types.
Definition: Base.hh:41
gazebo::physics::Base::GetChild
BasePtr GetChild(unsigned int _i) const
Get a child by index.
gazebo::physics::Base::SENSOR_COLLISION
Indicates a collision shape used for sensing.
Definition: Base.hh:137
gazebo::physics::Base::world
WorldPtr world
Pointer to the world.
Definition: Base.hh:340