17 #ifndef GAZEBO_PHYSICS_LINK_HH_
18 #define GAZEBO_PHYSICS_LINK_HH_
29 #include <ignition/math/Matrix3.hh>
72 public:
virtual ~
Link();
76 public:
virtual void Load(sdf::ElementPtr _sdf);
79 public:
virtual void Init();
89 public:
void ResetPhysicsStates();
93 public:
virtual void UpdateParameters(sdf::ElementPtr _sdf);
107 public:
void SetScale(
const ignition::math::Vector3d &_scale);
111 public:
virtual void SetEnabled(
bool _enable)
const = 0;
115 public:
virtual bool GetEnabled()
const = 0;
120 public:
virtual bool SetSelected(
bool _set);
124 public:
virtual void SetGravityMode(
bool _mode) = 0;
128 public:
virtual bool GetGravityMode()
const = 0;
132 public:
virtual void SetWindMode(
const bool _mode);
136 public:
virtual bool WindMode()
const;
142 public:
virtual void SetSelfCollide(
bool _collide) = 0;
152 public:
void SetCollideMode(
const std::string &_mode);
161 public:
bool GetSelfCollide()
const;
165 public:
void SetLaserRetro(
float _retro);
175 public:
virtual void SetLinearVel(
176 const ignition::math::Vector3d &_vel) = 0;
181 public:
virtual void SetAngularVel(
const math::Vector3 &_vel)
186 public:
virtual void SetAngularVel(
187 const ignition::math::Vector3d &_vel) = 0;
224 public:
virtual void AddRelativeForce(
const math::Vector3 &_force)
231 public:
virtual void AddForceAtWorldPosition(
const math::Vector3 &_force,
239 public:
virtual void AddForceAtRelativePosition(
250 public:
virtual void AddLinkForce(
const math::Vector3 &_force,
264 public:
virtual void AddRelativeTorque(
const math::Vector3 &_torque)
269 public:
void SetLinearAccel(
const ignition::math::Vector3d &_accel);
273 public:
void SetAngularAccel(
const ignition::math::Vector3d &_accel);
277 public:
virtual void SetForce(
278 const ignition::math::Vector3d &_force) = 0;
282 public:
virtual void SetTorque(
283 const ignition::math::Vector3d &_torque) = 0;
287 public:
virtual void AddForce(
const ignition::math::Vector3d &_force) = 0;
292 public:
virtual void AddRelativeForce(
293 const ignition::math::Vector3d &_force) = 0;
298 public:
virtual void AddForceAtWorldPosition(
299 const ignition::math::Vector3d &_force,
300 const ignition::math::Vector3d &_pos) = 0;
306 public:
virtual void AddForceAtRelativePosition(
307 const ignition::math::Vector3d &_force,
308 const ignition::math::Vector3d &_relPos) = 0;
316 public:
virtual void AddLinkForce(
const ignition::math::Vector3d &_force,
317 const ignition::math::Vector3d &_offset =
318 ignition::math::Vector3d::Zero) = 0;
322 public:
virtual void AddTorque(
323 const ignition::math::Vector3d &_torque) = 0;
328 public:
virtual void AddRelativeTorque(
329 const ignition::math::Vector3d &_torque) = 0;
342 public: ignition::math::Pose3d WorldCoGPose()
const;
354 public:
virtual ignition::math::Vector3d WorldLinearVel()
const;
375 public:
virtual ignition::math::Vector3d WorldLinearVel(
376 const ignition::math::Vector3d &_offset)
const = 0;
397 public:
virtual ignition::math::Vector3d WorldLinearVel(
398 const ignition::math::Vector3d &_offset,
399 const ignition::math::Quaterniond &_q)
const = 0;
413 public:
virtual ignition::math::Vector3d WorldCoGLinearVel()
const = 0;
423 public: ignition::math::Vector3d RelativeLinearVel()
const;
433 public: ignition::math::Vector3d RelativeAngularVel()
const;
443 public: ignition::math::Vector3d RelativeLinearAccel()
const;
453 public: ignition::math::Vector3d WorldLinearAccel()
const;
463 public: ignition::math::Vector3d RelativeAngularAccel()
const;
479 public: ignition::math::Vector3d WorldAngularMomentum()
const;
498 public: ignition::math::Vector3d WorldAngularAccel()
const;
508 public: ignition::math::Vector3d RelativeForce()
const;
518 public:
virtual ignition::math::Vector3d WorldForce()
const = 0;
527 public: ignition::math::Vector3d RelativeTorque()
const;
537 public:
virtual ignition::math::Vector3d WorldTorque()
const = 0;
549 public:
void SetInertial(
const InertialPtr &_inertial);
557 public:
math::Pose GetWorldInertialPose() const GAZEBO_DEPRECATED(8.0);
564 public: ignition::math::Pose3d WorldInertialPose() const;
570 public: math::Matrix3 GetWorldInertiaMatrix() const
571 GAZEBO_DEPRECATED(8.0);
576 public: ignition::math::Matrix3d WorldInertiaMatrix() const;
583 public:
CollisionPtr GetCollisionById(
unsigned int _id) const;
589 public:
CollisionPtr GetCollision(const std::
string &_name);
594 public:
CollisionPtr GetCollision(
unsigned int _index) const;
603 public: virtual ignition::math::Box BoundingBox() const;
607 public: virtual
void SetLinearDamping(
double _damping) = 0;
611 public: virtual
void SetAngularDamping(
double _damping) = 0;
615 public:
double GetLinearDamping() const;
619 public:
double GetAngularDamping() const;
624 public: virtual
void SetKinematic(const
bool &_kinematic);
629 public: virtual
bool GetKinematic()
const {
return false;}
637 public:
unsigned int GetSensorCount()
const;
650 public: std::string GetSensorName(
unsigned int _index)
const;
655 public:
template<
typename T>
657 {
return enabledSignal.Connect(_subscriber);}
664 {enabledSignal.Disconnect(_conn->Id());}
668 public:
void FillMsg(msgs::Link &_msg);
672 public:
void ProcessMsg(
const msgs::Link &_msg);
676 public:
void AddChildJoint(
JointPtr _joint);
680 public:
void AddParentJoint(
JointPtr _joint);
684 public:
void RemoveParentJoint(
const std::string &_jointName);
688 public:
void RemoveChildJoint(
const std::string &_jointName);
691 public:
virtual void RemoveChild(
EntityPtr _child);
698 public:
void AttachStaticModel(
ModelPtr &_model,
704 public:
void AttachStaticModel(
ModelPtr &_model,
705 const ignition::math::Pose3d &_offset);
709 public:
void DetachStaticModel(
const std::string &_modelName);
712 public:
void DetachAllStaticModels();
716 public:
virtual void OnPoseChange();
720 public:
void SetState(
const LinkState &_state);
730 public:
virtual void SetAutoDisable(
bool _disable) = 0;
734 public:
Link_V GetChildJointsLinks()
const;
738 public:
Link_V GetParentJointsLinks()
const;
742 public:
void SetPublishData(
bool _enable);
745 public:
Joint_V GetParentJoints()
const;
748 public:
Joint_V GetChildJoints()
const;
752 public:
void RemoveCollision(
const std::string &_name);
757 public:
double GetWorldEnergyPotential()
const;
762 public:
double GetWorldEnergyKinetic()
const;
768 public:
double GetWorldEnergy()
const;
773 public: msgs::Visual GetVisualMessage(
const std::string &_name)
const;
778 public:
virtual void SetLinkStatic(
bool _static) = 0;
781 public:
virtual void SetStatic(
const bool &_static);
793 public:
void MoveFrame(
const math::Pose &_worldReferenceFrameSrc,
805 public:
void MoveFrame(
806 const ignition::math::Pose3d &_worldReferenceFrameSrc,
807 const ignition::math::Pose3d &_worldReferenceFrameDst);
823 public:
bool FindAllConnectedLinksHelper(
824 const LinkPtr &_originalParentLink,
825 Link_V &_connectedLinks,
bool _fistLink =
false);
829 public:
void SetWindEnabled(
const bool _enable);
834 public:
const ignition::math::Vector3d WorldWindLinearVel()
const;
838 public:
const ignition::math::Vector3d RelativeWindLinearVel()
const;
856 public:
size_t BatteryCount()
const;
862 public:
bool VisualId(
const std::string &_visName, uint32_t &_visualId)
869 public:
bool VisualPose(
const uint32_t _id,
870 ignition::math::Pose3d &_pose)
const;
876 public:
bool SetVisualPose(
const uint32_t _id,
877 const ignition::math::Pose3d &_pose);
880 private:
void PublishData();
884 private:
void LoadCollision(sdf::ElementPtr _sdf);
888 private:
void SetInertialFromCollisions();
892 private:
void OnCollision(ConstContactsPtr &_msg);
895 private:
void ParseVisuals();
901 private:
bool ContainsLink(
const Link_V &_vector,
const LinkPtr &_value);
905 private:
void UpdateVisualGeomSDF(
const ignition::math::Vector3d &_scale);
908 private:
void UpdateVisualMsg();
913 private:
void OnWrenchMsg(ConstWrenchPtr &_msg);
917 private:
void ProcessWrenchMsg(
const msgs::Wrench &_msg);
921 private:
void LoadBattery(
const sdf::ElementPtr _sdf);
924 protected:
virtual void RegisterIntrospectionItems();
952 private:
bool enabled;
955 private: std::vector<std::string> sensors;
958 private: std::vector<JointPtr> parentJoints;
961 private: std::vector<JointPtr> childJoints;
964 private: std::vector<ModelPtr> attachedModels;
970 private: msgs::LinkData linkDataMsg;
973 private:
bool publishData;
976 private: boost::recursive_mutex *publishDataMutex;
985 private: std::vector<msgs::Wrench> wrenchMsgs;
988 private: boost::mutex wrenchMsgMutex;
991 private: ignition::math::Vector3d windLinearVel;
997 private: std::vector<common::BatteryPtr> batteries;
1000 private: std::vector<util::OpenALSourcePtr> audioSources;
virtual void UpdateMass()
Update the mass matrix.
Definition: Link.hh:723
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
bool initialized
This flag is set to true when the link is initialized.
Definition: Link.hh:946
InertialPtr GetInertial() const
Get the inertia of the link.
Definition: Link.hh:545
Encapsulates a position and rotation in three space.
Definition: Pose.hh:42
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:44
Forward declarations for transport.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
std::vector< ignition::math::Pose3d > attachedModelsOffset
Offsets for the attached models.
Definition: Link.hh:943
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:117
event::ConnectionPtr ConnectEnabled(T _subscriber)
Connect to the add entity signal.
Definition: Link.hh:656
virtual void Update()
Update the object.
Definition: Base.hh:171
virtual void RemoveChild(unsigned int _id)
Remove a child from this entity.
Link class defines a rigid body entity, containing information on inertia, visual and collision prope...
Definition: Link.hh:65
void DisconnectEnabled(event::ConnectionPtr &_conn) GAZEBO_DEPRECATED(8.0)
Disconnect to the add entity signal.
Definition: Link.hh:662
Information for use in an update event.
Definition: UpdateInfo.hh:30
void SetStatic(const bool &_static)
Set whether this entity is static: immovable.
Visuals_M visuals
Link visual elements.
Definition: Link.hh:934
ignition::math::Vector3d linearAccel
Linear acceleration.
Definition: Link.hh:937
std::map< uint32_t, msgs::Visual > Visuals_M
Definition: Link.hh:931
virtual void UpdateSurface()
Update surface parameters.
Definition: Link.hh:726
std::vector< JointPtr > Joint_V
Definition: PhysicsTypes.hh:213
std::vector< CollisionPtr > Collision_V
Definition: PhysicsTypes.hh:229
A quaternion class.
Definition: Quaternion.hh:48
std::shared_ptr< Battery > BatteryPtr
Definition: CommonTypes.hh:125
boost::shared_ptr< Inertial > InertialPtr
Definition: PhysicsTypes.hh:157
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
Base class for all physics objects in Gazebo.
Definition: Entity.hh:56
ignition::math::Vector3d angularAccel
Angular acceleration.
Definition: Link.hh:940
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:85
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
std::shared_ptr< OpenALSink > OpenALSinkPtr
Definition: UtilTypes.hh:44
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
virtual void Reset()
Reset the entity.
static const Vector3 Zero
math::Vector3(0, 0, 0)
Definition: Vector3.hh:47
std::vector< LinkPtr > Link_V
Definition: PhysicsTypes.hh:225
Store state information of a physics::Link object.
Definition: LinkState.hh:47
boost::shared_ptr< Collision > CollisionPtr
Definition: PhysicsTypes.hh:113
InertialPtr inertial
Inertial properties.
Definition: Link.hh:927