17 #ifndef GAZEBO_PHYSICS_MODEL_HH_
18 #define GAZEBO_PHYSICS_MODEL_HH_
24 #include <boost/function.hpp>
25 #include <boost/thread/recursive_mutex.hpp>
36 class recursive_mutex;
70 public:
void Load(sdf::ElementPtr _sdf)
override;
76 public:
virtual void Init()
override;
82 public:
virtual void Fini()
override;
90 public:
virtual const sdf::ElementPtr
GetSDF()
override;
174 public:
virtual ignition::math::AxisAlignedBox
BoundingBox()
const
208 public:
LinkPtr GetLinkById(
unsigned int _id)
const;
246 public:
virtual void FillMsg(msgs::Model &_msg);
257 double _position,
int _index = 0);
263 const std::map<std::string, double> &_jointPositions);
270 const std::map<std::string, common::NumericAnimationPtr> &_anims,
271 boost::function<
void()> _onComplete =
NULL);
291 ignition::math::Pose3d _offset);
307 public:
void SetScale(
const ignition::math::Vector3d &_scale,
308 const bool _publish =
false);
314 public: ignition::math::Vector3d
Scale()
const;
327 std::string _linkName);
382 const std::string &_name)
const;
427 const std::string &_name,
const std::string &_type,
440 sdf::ElementPtr _sdf);
483 ignition::msgs::Plugin_V &_plugins,
bool &_success);
495 private:
void LoadLinks();
498 private:
void LoadModels();
502 private:
void LoadJoint(sdf::ElementPtr _sdf);
506 private:
void LoadPlugin(sdf::ElementPtr _sdf);
510 private:
void LoadGripper(sdf::ElementPtr _sdf);
515 private:
void RemoveLink(
const std::string &_name);
518 private:
virtual void PublishScale();
530 private:
LinkPtr canonicalLink;
542 private: std::vector<GripperPtr> grippers;
545 private: std::vector<ModelPluginPtr> plugins;
548 private: std::map<std::string, common::NumericAnimationPtr>
552 private: boost::function<void()> onJointAnimationComplete;
558 private:
mutable boost::recursive_mutex updateMutex;
561 private: std::mutex receiveMutex;
566 private: std::unique_ptr<sdf::Model> modelSDFDomIsolated;
569 private:
const sdf::Model *modelSDFDom =
nullptr;
#define NULL
Definition: CommonTypes.hh:31
default namespace for gazebo
Forward declarations for transport.
A complete URI.
Definition: URI.hh:177
virtual void RemoveChild(unsigned int _id)
Remove a child from this entity.
Base class for all physics objects in Gazebo.
Definition: Entity.hh:53
virtual void Reset()
Reset the entity.
Store state information of a physics::Model object.
Definition: ModelState.hh:49
A model is a collection of links, joints, and plugins.
Definition: Model.hh:60
virtual ignition::math::Vector3d WorldLinearAccel() const override
Get the linear acceleration of the entity in the world frame.
void SetAngularVel(const ignition::math::Vector3d &_vel)
Set the angular velocity of the model, and all its links.
void SetScale(const ignition::math::Vector3d &_scale, const bool _publish=false)
Set the scale of model.
JointControllerPtr GetJointController()
Get a handle to the Controller for the joints in this model.
void DetachStaticModel(const std::string &_model)
Detach a static model from this model.
virtual gazebo::physics::JointPtr CreateJoint(sdf::ElementPtr _sdf)
Create a joint for this model.
virtual bool GetSelfCollide() const
If true, all links within the model will collide by default.
const Model_V & NestedModels() const
Get all the nested models.
void SetLaserRetro(const float _retro)
Set the laser retro reflectiveness of the model.
std::vector< ignition::math::Pose3d > attachedModelsOffset
used by Model::AttachStaticModel
Definition: Model.hh:524
virtual ignition::math::Vector3d RelativeAngularVel() const override
Get the angular velocity of the entity.
virtual void SetWindMode(const bool _mode)
Set whether wind affects this body.
void PluginInfo(const common::URI &_pluginUri, ignition::msgs::Plugin_V &_plugins, bool &_success)
Get information about plugins in this model or one of its children, according to the given _pluginUri...
virtual void OnPoseChange() override
Callback when the pose of the model has been changed.
virtual ignition::math::Vector3d WorldAngularAccel() const override
Get the angular acceleration of the entity in the world frame.
virtual void RemoveChild(EntityPtr _child)
Remove a child.
void Load(sdf::ElementPtr _sdf) override
Load the model.
void SetAutoDisable(bool _disable)
Allow the model the auto disable.
void ResetPhysicsStates()
Reset the velocity, acceleration, force and torque of all child links.
const Link_V & GetLinks() const
Construct and return a vector of Link's in this model Note this constructs the vector of Link's on th...
virtual ignition::math::AxisAlignedBox BoundingBox() const override
Get the size of the bounding box.
virtual ignition::math::Vector3d RelativeLinearAccel() const override
Get the linear acceleration of the entity.
virtual ignition::math::Vector3d RelativeAngularAccel() const override
Get the angular acceleration of the entity.
unsigned int GetJointCount() const
Get the number of joints.
LinkPtr CreateLink(const std::string &_name)
Create a new link for this model.
void ProcessMsg(const msgs::Model &_msg)
Update parameters from a model message.
Model(BasePtr _parent)
Constructor.
void SetJointAnimation(const std::map< std::string, common::NumericAnimationPtr > &_anims, boost::function< void()> _onComplete=NULL)
Joint Animation.
unsigned int GetSensorCount() const
Get the number of sensors attached to this model.
LinkPtr GetLink(const std::string &_name="canonical") const
Get a link by name.
double GetWorldEnergyKinetic() const
Returns sum of the kinetic energies of all links in this model.
virtual bool RemoveJoint(const std::string &_name)
Remove a joint for this model.
virtual ignition::math::Vector3d WorldLinearVel() const override
Get the linear velocity of the entity in the world frame.
virtual void StopAnimation() override
Stop the current animations.
JointPtr GetJoint(const std::string &name)
Get a joint.
void SetEnabled(bool _enabled)
Enable all the links in all the models.
virtual const sdf::ElementPtr UnscaledSDF()
virtual bool WindMode() const
Get the wind mode.
double GetWorldEnergy() const
Returns this model's total energy, or sum of Model::GetWorldEnergyPotential() and Model::GetWorldEner...
virtual void RegisterIntrospectionItems() override
Register items in the introspection service.
transport::PublisherPtr jointPub
Publisher for joint info.
Definition: Model.hh:527
void SetLinkWorldPose(const ignition::math::Pose3d &_pose, std::string _linkName)
Set the Pose of the entire Model by specifying desired Pose of a Link within the Model.
GripperPtr GetGripper(size_t _index) const
Get a gripper based on an index.
const Joint_V & GetJoints() const
Get the joints.
void SetLinearVel(const ignition::math::Vector3d &_vel)
Set the linear velocity of the model, and all its links.
virtual ~Model()
Destructor.
std::optional< sdf::SemanticPose > SDFSemanticPose() const override
Get the SDF SemanticPose object associated with the pose of this object.
double GetWorldEnergyPotential() const
Returns the potential energy of all links and joint springs in the model.
void SetState(const ModelState &_state)
Set the current model state.
virtual void SetSelfCollide(bool _self_collide)
Set this model's self_collide property.
virtual gazebo::physics::JointPtr CreateJoint(const std::string &_name, const std::string &_type, physics::LinkPtr _parent, physics::LinkPtr _child)
Create a joint for this model.
virtual void FillMsg(msgs::Model &_msg)
Fill a model message.
void Update() override
Update the model.
void SetJointPosition(const std::string &_jointName, double _position, int _index=0)
Set the positions of a Joint by name.
virtual void UpdateParameters(sdf::ElementPtr _sdf) override
Update the parameters using new sdf values.
virtual void Fini() override
Finalize the model.
std::vector< std::string > SensorScopedName(const std::string &_name) const
Get scoped sensor name(s) in the model that matches sensor name.
virtual const sdf::ElementPtr GetSDF() override
Get the SDF values for the model.
bool GetAutoDisable() const
Return the value of the SDF <allow_auto_disable> element.
const sdf::Model * GetSDFDom() const
Get the SDF DOM for the model.
void SetGravityMode(const bool &_value)
Set the gravity mode of the model.
size_t GetGripperCount() const
Get the number of grippers in this model.
boost::shared_ptr< Model > shared_from_this()
Allow Model class to share itself as a boost shared_ptr.
void SetJointPositions(const std::map< std::string, double > &_jointPositions)
Set the positions of a set of joints.
std::vector< ModelPtr > attachedModels
used by Model::AttachStaticModel
Definition: Model.hh:521
void AttachStaticModel(ModelPtr &_model, ignition::math::Pose3d _offset)
Attach a static model to this model.
virtual void Init() override
Initialize the model.
ModelPtr NestedModel(const std::string &_name) const
Get a nested model that is a direct child of this model.
ignition::math::Vector3d Scale() const
Get the scale of model.
virtual ignition::math::Vector3d WorldAngularVel() const override
Get the angular velocity of the entity in the world frame.
virtual ignition::math::Vector3d RelativeLinearVel() const override
Get the linear velocity of the entity.
void SetCollideMode(const std::string &_mode)
\TODO This is not implemented in Link, which means this function doesn't do anything.
unsigned int GetPluginCount() const
Get the number of plugins this model has.
void LoadJoints()
Load all the joints.
void SetLinkWorldPose(const ignition::math::Pose3d &_pose, const LinkPtr &_link)
Set the Pose of the entire Model by specifying desired Pose of a Link within the Model.
void Reset() override
Reset the model.
void LoadPlugins()
Load all plugins.
void LoadPlugins(unsigned int _timeout)
Load all plugins with a configurable timeout.
Definition: JointMaker.hh:45
std::vector< ModelPtr > Model_V
Definition: PhysicsTypes.hh:206
boost::shared_ptr< JointController > JointControllerPtr
Definition: PhysicsTypes.hh:122
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:110
boost::shared_ptr< Gripper > GripperPtr
Definition: PhysicsTypes.hh:198
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:78
std::vector< JointPtr > Joint_V
Definition: PhysicsTypes.hh:214
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:86
std::vector< LinkPtr > Link_V
Definition: PhysicsTypes.hh:226
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:94
boost::shared_ptr< Joint > JointPtr
Definition: PhysicsTypes.hh:118
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Forward declarations for the common classes.
Definition: Animation.hh:27