##

Entity.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_ENTITY_HH_
#define GAZEBO_PHYSICS_ENTITY_HH_
#include <string>
#include <vector>
#include <ignition/math/Box.hh>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>
#include <ignition/transport/Node.hh>
#include <boost/function.hpp>
#include "gazebo/msgs/msgs.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/common/CommonTypes.hh"
#include "gazebo/common/UpdateInfo.hh"
#include "gazebo/physics/PhysicsTypes.hh"
#include "gazebo/physics/Base.hh"
#include "gazebo/util/system.hh"
namespace boost
{
class recursive_mutex;
}
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE Entity : public Base
{
public: explicit Entity(BasePtr _parent);
public: virtual ~Entity();
public: virtual void Load(sdf::ElementPtr _sdf);
public: virtual void Fini();
public: virtual void Reset();
using Base::Reset;
public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
public: virtual void SetName(const std::string &_name);
public: void SetStatic(const bool &_static);
public: bool IsStatic() const;
public: void SetInitialRelativePose(const ignition::math::Pose3d &_pose);
public: ignition::math::Pose3d InitialRelativePose() const;
public: virtual ignition::math::Box BoundingBox() const;
public: inline virtual const ignition::math::Pose3d &WorldPose() const
{
return this->worldPose;
}
public: ignition::math::Pose3d RelativePose() const;
public: void SetRelativePose(const ignition::math::Pose3d &_pose,
const bool _notify = true,
const bool _publish = true);
public: void SetWorldPose(const ignition::math::Pose3d &_pose,
const bool _notify = true,
const bool _publish = true);
public: virtual ignition::math::Vector3d RelativeLinearVel() const;
public: virtual ignition::math::Vector3d WorldLinearVel() const;
public: virtual ignition::math::Vector3d RelativeAngularVel() const;
public: virtual ignition::math::Vector3d WorldAngularVel() const;
public: virtual ignition::math::Vector3d RelativeLinearAccel() const;
public: virtual ignition::math::Vector3d WorldLinearAccel() const;
public: virtual ignition::math::Vector3d RelativeAngularAccel() const;
public: virtual ignition::math::Vector3d WorldAngularAccel() const;
public: void SetCanonicalLink(bool _value);
public: inline bool IsCanonicalLink() const
{return this->isCanonicalLink;}
public: void SetAnimation(const common::PoseAnimationPtr &_anim,
boost::function<void()> _onComplete);
public: void SetAnimation(common::PoseAnimationPtr _anim);
public: virtual void StopAnimation();
public: ModelPtr GetParentModel();
public: CollisionPtr GetChildCollision(const std::string &_name);
public: LinkPtr GetChildLink(const std::string &_name);
public: void GetNearestEntityBelow(double &_distBelow,
std::string &_entityName);
public: void PlaceOnNearestEntityBelow();
public: void PlaceOnEntity(const std::string &_entityName);
public: ignition::math::Box CollisionBoundingBox() const;
public: void SetWorldTwist(const ignition::math::Vector3d &_linear,
const ignition::math::Vector3d &_angular,
const bool _updateChildren = true);
public: const ignition::math::Pose3d &DirtyPose() const;
protected: virtual void OnPoseChange() = 0;
private: virtual void PublishPose();
private: ignition::math::Box CollisionBoundingBoxHelper(
BasePtr _base) const;
private: void SetWorldPoseModel(const ignition::math::Pose3d &_pose,
const bool _notify,
const bool _publish);
private: void SetWorldPoseCanonicalLink(
const ignition::math::Pose3d &_pose,
const bool _notify, const bool _publish);
private: void SetWorldPoseDefault(const ignition::math::Pose3d &_pose,
const bool _notify, const bool _publish);
private: void OnPoseMsg(ConstPosePtr &_msg);
private: void UpdatePhysicsPose(bool update_children = true);
private: void UpdateAnimation(const common::UpdateInfo &_info);
protected: EntityPtr parentEntity;
protected: mutable ignition::math::Pose3d worldPose;
protected: transport::NodePtr node;
protected: transport::PublisherPtr visPub;
protected: transport::PublisherPtr requestPub;
protected: msgs::Visual *visualMsg;
protected: common::PoseAnimationPtr animation;
protected: common::Time prevAnimationTime;
protected: ignition::math::Pose3d animationStartPose;
protected: std::vector<event::ConnectionPtr> connections;
protected: event::ConnectionPtr animationConnection;
protected: ignition::math::Pose3d dirtyPose;
protected: ignition::math::Vector3d scale;
private: bool isStatic;
private: bool isCanonicalLink;
private: ignition::math::Pose3d initialRelativePose;
private: transport::PublisherPtr posePub;
private: transport::SubscriberPtr poseSub;
private: boost::function<void()> onAnimationComplete;
private: void (Entity::*setWorldPoseFunc)(const ignition::math::Pose3d &,
const bool, const bool);
// Place ignition::transport objects at the end of this file to
// guarantee they are destructed first.
protected: ignition::transport::Node nodeIgn;
protected: ignition::transport::Node::Publisher visPubIgn;
protected: ignition::transport::Node::Publisher requestPubIgn;
private: ignition::transport::Node::Publisher posePubIgn;
};
}
}
#endif
gazebo::physics::Entity::Fini
virtual void Fini()
Finalize the entity.
gazebo::physics::Entity::scale
ignition::math::Vector3d scale
Scale of the entity.
Definition: Entity.hh:318
gazebo::physics::Entity::~Entity
virtual ~Entity()
Destructor.
gazebo::physics::Entity::WorldAngularAccel
virtual ignition::math::Vector3d WorldAngularAccel() const
Get the angular acceleration of the entity in the world frame.
gazebo::physics::Entity::PlaceOnNearestEntityBelow
void PlaceOnNearestEntityBelow()
Move this entity to be ontop of the nearest entity below.
UpdateInfo.hh
gazebo::physics::Entity::animationConnection
event::ConnectionPtr animationConnection
Connection used to update an animation.
Definition: Entity.hh:312
gazebo::physics::Entity::dirtyPose
ignition::math::Pose3d dirtyPose
The pose set by a physics engine.
Definition: Entity.hh:315
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::Entity::BoundingBox
virtual ignition::math::Box BoundingBox() const
Return the bounding box for the entity.
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::physics::Entity::Entity
Entity(BasePtr _parent)
Constructor.
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::physics::Entity::SetWorldPose
void SetWorldPose(const ignition::math::Pose3d &_pose, const bool _notify=true, const bool _publish=true)
Set the world pose of the entity.
gazebo::physics::Entity::OnPoseChange
virtual void OnPoseChange()=0
This function is called when the entity's (or one of its parents) pose of the parent has changed.
gazebo::physics::Entity::node
transport::NodePtr node
Communication node.
Definition: Entity.hh:288
gazebo::physics::Entity::SetWorldTwist
void SetWorldTwist(const ignition::math::Vector3d &_linear, const ignition::math::Vector3d &_angular, const bool _updateChildren=true)
Set angular and linear rates of an physics::Entity.
gazebo::physics::Entity::GetChildLink
LinkPtr GetChildLink(const std::string &_name)
Get a child linke entity, if one exists.
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
gazebo::physics::Entity::SetCanonicalLink
void SetCanonicalLink(bool _value)
Set to true if this entity is a canonical link for a model.
gazebo::physics::Entity::RelativeLinearAccel
virtual ignition::math::Vector3d RelativeLinearAccel() const
Get the linear acceleration of the entity.
TransportTypes.hh
Forward declarations for transport.
gazebo::physics::Entity::animationStartPose
ignition::math::Pose3d animationStartPose
Start pose of an animation.
Definition: Entity.hh:306
boost
Definition: JointMaker.hh:44
system.hh
msgs.hh
CommonTypes.hh
gazebo::transport::SubscriberPtr
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
gazebo::physics::Entity::Reset
virtual void Reset()
Reset the entity.
PhysicsTypes.hh
default namespace for gazebo
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::physics::Entity::WorldAngularVel
virtual ignition::math::Vector3d WorldAngularVel() const
Get the angular velocity of the entity in the world frame.
gazebo::physics::Entity::IsStatic
bool IsStatic() const
Return whether this entity is static.
gazebo::physics::Entity::PlaceOnEntity
void PlaceOnEntity(const std::string &_entityName)
Move this entity to be ontop of another entity by name.
gazebo::physics::Entity::RelativePose
ignition::math::Pose3d RelativePose() const
Get the pose of the entity relative to its parent.
gazebo::physics::Entity::UpdateParameters
virtual void UpdateParameters(sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
gazebo::physics::Base::Reset
virtual void Reset()
Reset the object.
gazebo::physics::Entity::animation
common::PoseAnimationPtr animation
Current pose animation.
Definition: Entity.hh:300
gazebo::physics::Entity::IsCanonicalLink
bool IsCanonicalLink() const
A helper function that checks if this is a canonical body.
Definition: Entity.hh:165
gazebo::physics::Entity::Load
virtual void Load(sdf::ElementPtr _sdf)
Load the entity.
gazebo::physics::Entity::StopAnimation
virtual void StopAnimation()
Stop the current animation, if any.
gazebo::physics::Entity::GetNearestEntityBelow
void GetNearestEntityBelow(double &_distBelow, std::string &_entityName)
Get the distance to the nearest entity below (along the Z-axis) this entity.
gazebo::physics::Base
Base class for most physics classes.
Definition: Base.hh:71
gazebo::physics::Entity::SetName
virtual void SetName(const std::string &_name)
Set the name of the entity.
gazebo::physics::Entity::SetAnimation
void SetAnimation(const common::PoseAnimationPtr &_anim, boost::function< void()> _onComplete)
Set an animation for this entity.
gazebo::physics::Entity::RelativeAngularVel
virtual ignition::math::Vector3d RelativeAngularVel() const
Get the angular velocity of the entity.
gazebo::physics::Entity::connections
std::vector< event::ConnectionPtr > connections
All our event connections.
Definition: Entity.hh:309
gazebo::physics::Entity::GetParentModel
ModelPtr GetParentModel()
Get the parent model, if one exists.
gazebo::physics::Entity::nodeIgn
ignition::transport::Node nodeIgn
Ignition communication node.
Definition: Entity.hh:346
gazebo::physics::Entity::SetRelativePose
void SetRelativePose(const ignition::math::Pose3d &_pose, const bool _notify=true, const bool _publish=true)
Set the pose of the entity relative to its parent.
Base.hh
gazebo::physics::BasePtr
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
gazebo::physics::Entity::requestPub
transport::PublisherPtr requestPub
Request publisher.
Definition: Entity.hh:294
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::physics::Entity::WorldLinearVel
virtual ignition::math::Vector3d WorldLinearVel() const
Get the linear velocity of the entity in the world frame.
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::Entity::InitialRelativePose
ignition::math::Pose3d InitialRelativePose() const
Get the initial relative pose.
gazebo::physics::Entity::WorldLinearAccel
virtual ignition::math::Vector3d WorldLinearAccel() const
Get the linear acceleration of the entity in the world frame.
gazebo::physics::Entity::SetInitialRelativePose
void SetInitialRelativePose(const ignition::math::Pose3d &_pose)
Set the initial pose.
gazebo::physics::Entity::parentEntity
EntityPtr parentEntity
A helper that prevents numerous dynamic_casts.
Definition: Entity.hh:282
gazebo::physics::EntityPtr
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:85
gazebo::physics::Entity
Base class for all physics objects in Gazebo.
Definition: Entity.hh:52
gazebo::physics::Entity::DirtyPose
const ignition::math::Pose3d & DirtyPose() const
Returns Entity::dirtyPose.
gazebo::physics::Entity::requestPubIgn
ignition::transport::Node::Publisher requestPubIgn
Request publisher.
Definition: Entity.hh:352
gazebo::physics::CollisionPtr
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
gazebo::physics::Entity::worldPose
ignition::math::Pose3d worldPose
World pose of the entity.
Definition: Entity.hh:285
gazebo::physics::Entity::visualMsg
msgs::Visual * visualMsg
Visual message container.
Definition: Entity.hh:297
gazebo::physics::Entity::visPubIgn
ignition::transport::Node::Publisher visPubIgn
Visual publisher.
Definition: Entity.hh:349
gazebo::physics::Entity::RelativeLinearVel
virtual ignition::math::Vector3d RelativeLinearVel() const
Get the linear velocity of the entity.
gazebo::physics::Entity::WorldPose
virtual const ignition::math::Pose3d & WorldPose() const
Get the absolute pose of the entity.
Definition: Entity.hh:102
gazebo::physics::Entity::CollisionBoundingBox
ignition::math::Box CollisionBoundingBox() const
Returns collision bounding box.
gazebo::physics::Entity::RelativeAngularAccel
virtual ignition::math::Vector3d RelativeAngularAccel() const
Get the angular acceleration of the entity.
gazebo::common::UpdateInfo
Information for use in an update event.
Definition: UpdateInfo.hh:30
gazebo::physics::Entity::SetStatic
void SetStatic(const bool &_static)
Set whether this entity is static: immovable.
gazebo::common::PoseAnimationPtr
boost::shared_ptr< PoseAnimation > PoseAnimationPtr
Definition: CommonTypes.hh:109
gazebo::physics::Entity::visPub
transport::PublisherPtr visPub
Visual publisher.
Definition: Entity.hh:291
gazebo::physics::Entity::prevAnimationTime
common::Time prevAnimationTime
Previous time an animation was updated.
Definition: Entity.hh:303
gazebo::physics::Entity::GetChildCollision
CollisionPtr GetChildCollision(const std::string &_name)
Get a child collision entity, if one exists.