##

Joint.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_JOINT_HH_
#define GAZEBO_PHYSICS_JOINT_HH_
#include <string>
#include <vector>
#include <boost/any.hpp>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector3.hh>
#include "gazebo/common/Event.hh"
#include "gazebo/common/Events.hh"
#include "gazebo/msgs/MessageTypes.hh"
#include "gazebo/physics/JointState.hh"
#include "gazebo/physics/Base.hh"
#include "gazebo/physics/JointWrench.hh"
#include "gazebo/util/system.hh"
#define MAX_JOINT_AXIS 2
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE Joint : public Base
{
public: enum Attribute
{
FUDGE_FACTOR,
SUSPENSION_ERP,
SUSPENSION_CFM,
STOP_ERP,
STOP_CFM,
ERP,
CFM,
FMAX,
VEL,
HI_STOP,
LO_STOP
};
public: explicit Joint(BasePtr _parent);
public: virtual ~Joint();
public: void Load(LinkPtr _parent, LinkPtr _child,
const ignition::math::Pose3d &_pose);
public: virtual void Load(sdf::ElementPtr _sdf);
public: virtual void Init();
public: virtual void Fini();
public: void Update();
public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
public: virtual void Reset();
using Base::Reset;
public: void SetState(const JointState &_state);
public: void SetModel(ModelPtr _model);
public: virtual LinkPtr GetJointLink(unsigned int _index) const = 0;
public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const = 0;
public: virtual void Attach(LinkPtr _parent, LinkPtr _child);
public: virtual void Detach();
public: virtual void SetAxis(const unsigned int _index,
const ignition::math::Vector3d &_axis) = 0;
public: virtual void SetDamping(unsigned int _index, double _damping) = 0;
public: double GetDamping(unsigned int _index);
public: virtual void ApplyStiffnessDamping();
public: virtual void SetStiffnessDamping(unsigned int _index,
double _stiffness, double _damping, double _reference = 0) = 0;
public: virtual void SetStiffness(unsigned int _index,
const double _stiffness) = 0;
public: double GetStiffness(unsigned int _index);
public: double GetSpringReferencePosition(unsigned int _index) const;
public: template<typename T>
event::ConnectionPtr ConnectJointUpdate(T _subscriber)
{return jointUpdate.Connect(_subscriber);}
public: ignition::math::Vector3d LocalAxis(const unsigned int _index)
const;
public: virtual ignition::math::Vector3d GlobalAxis(
unsigned int _index) const = 0;
public: virtual void SetAnchor(const unsigned int _index,
const ignition::math::Vector3d &_anchor) = 0;
public: virtual ignition::math::Vector3d Anchor(
const unsigned int _index) const = 0;
public: virtual double GetEffortLimit(unsigned int _index);
public: virtual void SetEffortLimit(unsigned int _index, double _effort);
public: virtual double GetVelocityLimit(unsigned int _index);
public: virtual void SetVelocityLimit(unsigned int _index,
double _velocity);
public: virtual void SetVelocity(unsigned int _index, double _vel) = 0;
public: virtual double GetVelocity(unsigned int _index) const = 0;
public: virtual void SetForce(unsigned int _index, double _effort) = 0;
public: double CheckAndTruncateForce(unsigned int _index, double _effort);
public: virtual double GetForce(unsigned int _index);
public: virtual JointWrench GetForceTorque(unsigned int _index) = 0;
public: virtual double Position(const unsigned int _index = 0) const
final;
public: virtual unsigned int DOF() const = 0;
public: virtual bool SetPosition(
const unsigned int _index, const double _position,
const bool _preserveWorldVelocity = false);
protected: bool SetPositionMaximal(
const unsigned int _index, double _position,
const bool _preserveWorldVelocity = false);
protected: bool SetVelocityMaximal(unsigned int _index, double _velocity);
public: virtual ignition::math::Vector3d LinkForce(
const unsigned int _index) const = 0;
public: virtual ignition::math::Vector3d LinkTorque(
const unsigned int _index) const = 0;
public: virtual bool SetParam(const std::string &_key,
unsigned int _index,
const boost::any &_value) = 0;
public: virtual double GetParam(const std::string &_key,
unsigned int _index);
public: LinkPtr GetChild() const;
public: LinkPtr GetParent() const;
public: msgs::Joint::Type GetMsgType() const;
public: virtual void FillMsg(msgs::Joint &_msg);
public: double GetInertiaRatio(const unsigned int _index) const;
public: double InertiaRatio(const ignition::math::Vector3d &_axis) const;
public: virtual double LowerLimit(unsigned int _index = 0) const;
public: virtual double UpperLimit(const unsigned int _index = 0) const;
public: virtual void SetLowerLimit(const unsigned int _index,
const double _limit);
public: virtual void SetUpperLimit(const unsigned int _index,
const double _limit);
public: virtual void SetProvideFeedback(bool _enable);
public: virtual void CacheForceTorque();
public: void SetStopStiffness(unsigned int _index, double _stiffness);
public: void SetStopDissipation(unsigned int _index, double _dissipation);
public: double GetStopStiffness(unsigned int _index) const;
public: double GetStopDissipation(unsigned int _index) const;
public: ignition::math::Pose3d InitialAnchorPose() const;
public: ignition::math::Pose3d WorldPose() const;
public: ignition::math::Pose3d ParentWorldPose() const;
public: ignition::math::Pose3d AnchorErrorPose() const;
public: ignition::math::Quaterniond AxisFrame(
const unsigned int _index) const;
public: ignition::math::Quaterniond AxisFrameOffset(
const unsigned int _index) const;
public: double GetWorldEnergyPotentialSpring(unsigned int _index) const;
protected: virtual double PositionImpl(const unsigned int _index = 0)
const = 0;
protected: bool FindAllConnectedLinks(const LinkPtr &_originalParentLink,
Link_V &_connectedLinks);
protected: ignition::math::Pose3d ChildLinkPose(
const unsigned int _index, const double _position);
protected: virtual void RegisterIntrospectionItems();
private: void RegisterIntrospectionPosition(const unsigned int _index);
private: void RegisterIntrospectionVelocity(const unsigned int _index);
private: void LoadImpl(const ignition::math::Pose3d &_pose);
protected: LinkPtr childLink;
protected: LinkPtr parentLink;
protected: ModelPtr model;
protected: ignition::math::Vector3d anchorPos;
protected: ignition::math::Pose3d anchorPose;
protected: ignition::math::Pose3d parentAnchorPose;
protected: LinkPtr anchorLink;
protected: double dissipationCoefficient[MAX_JOINT_AXIS];
protected: double stiffnessCoefficient[MAX_JOINT_AXIS];
protected: double springReferencePosition[MAX_JOINT_AXIS];
protected: gazebo::event::ConnectionPtr applyDamping;
protected: double effortLimit[MAX_JOINT_AXIS];
protected: double velocityLimit[MAX_JOINT_AXIS];
protected: double lowerLimit[MAX_JOINT_AXIS];
protected: double upperLimit[MAX_JOINT_AXIS];
protected: JointWrench wrench;
protected: bool axisParentModelFrame[MAX_JOINT_AXIS];
private: static sdf::ElementPtr sdfJoint;
protected: bool provideFeedback;
private: std::vector<std::string> sensors;
private: event::EventT<void ()> jointUpdate;
private: double staticPosition;
private: double stopStiffness[MAX_JOINT_AXIS];
private: double stopDissipation[MAX_JOINT_AXIS];
};
}
}
#endif
gazebo::physics::Joint::AreConnected
virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const =0
Determines of the two bodies are connected by a joint.
gazebo::physics::Joint::velocityLimit
double velocityLimit[2]
Store Joint velocity limit as specified in SDF.
Definition: Joint.hh:672
gazebo::physics::Joint::SetAnchor
virtual void SetAnchor(const unsigned int _index, const ignition::math::Vector3d &_anchor)=0
Set the anchor point.
gazebo::physics::Joint::SetParam
virtual bool SetParam(const std::string &_key, unsigned int _index, const boost::any &_value)=0
Set a non-generic parameter for the joint.
MAX_JOINT_AXIS
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition: Joint.hh:39
gazebo::physics::Joint::springReferencePosition
double springReferencePosition[2]
joint spring reference (zero load) position
Definition: Joint.hh:663
gazebo::physics::Joint::DOF
virtual unsigned int DOF() const =0
Get the number of degrees of freedom for this joint.
gazebo::physics::Joint::GlobalAxis
virtual ignition::math::Vector3d GlobalAxis(unsigned int _index) const =0
Get the axis of rotation in global cooridnate frame.
gazebo::physics::Joint::GetJointLink
virtual LinkPtr GetJointLink(unsigned int _index) const =0
Get the link to which the joint is attached according the _index.
gazebo::physics::Joint::GetMsgType
msgs::Joint::Type GetMsgType() const
Get the joint type as msgs::Joint::Type.
ignition
Definition: Model.hh:40
gazebo::physics::Joint::HI_STOP
Upper joint limit.
Definition: Joint.hh:84
Events.hh
gazebo::physics::Joint::SetPosition
virtual bool SetPosition(const unsigned int _index, const double _position, const bool _preserveWorldVelocity=false)
The child links of this joint are updated based on desired position.
gazebo::physics::Joint::GetStopDissipation
double GetStopDissipation(unsigned int _index) const
Get joint stop dissipation.
gazebo::physics::Joint::GetSpringReferencePosition
double GetSpringReferencePosition(unsigned int _index) const
Get joint spring reference position.
gazebo::physics::Joint::SetUpperLimit
virtual void SetUpperLimit(const unsigned int _index, const double _limit)
Set the joint's upper limit.
gazebo::physics::Joint::CacheForceTorque
virtual void CacheForceTorque()
Cache Joint Force Torque Values if necessary for physics engine.
gazebo::physics::Joint::FillMsg
virtual void FillMsg(msgs::Joint &_msg)
Fill a joint message.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::Joint::SetDamping
virtual void SetDamping(unsigned int _index, double _damping)=0
Set the joint damping.
gazebo::physics::Joint::SetAxis
virtual void SetAxis(const unsigned int _index, const ignition::math::Vector3d &_axis)=0
Set the axis of rotation where axis is specified in local joint frame.
gazebo::physics::JointState
keeps track of state of a physics::Joint
Definition: JointState.hh:36
gazebo::physics::Joint::STOP_CFM
Stop limit constraint force mixing.
Definition: Joint.hh:69
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::physics::Joint::AxisFrame
ignition::math::Quaterniond AxisFrame(const unsigned int _index) const
Get orientation of reference frame for specified axis, relative to world frame.
gazebo::physics::Joint::GetParent
LinkPtr GetParent() const
Get the parent link.
gazebo::physics::Joint::InertiaRatio
double InertiaRatio(const ignition::math::Vector3d &_axis) const
Computes moment of inertia (MOI) across an arbitrary axis specified in the world frame.
gazebo::physics::Joint::SetVelocityMaximal
bool SetVelocityMaximal(unsigned int _index, double _velocity)
Helper function for maximal coordinate solver SetVelocity.
sensors
sensors
Definition: SensorManager.hh:35
gazebo::physics::Joint::SetPositionMaximal
bool SetPositionMaximal(const unsigned int _index, double _position, const bool _preserveWorldVelocity=false)
Helper function for maximal coordinate solver SetPosition.
gazebo::physics::Joint::FindAllConnectedLinks
bool FindAllConnectedLinks(const LinkPtr &_originalParentLink, Link_V &_connectedLinks)
internal helper to find all links connected to the child link branching out from the children of the ...
gazebo::physics::Joint::lowerLimit
double lowerLimit[2]
Store Joint position lower limit as specified in SDF.
Definition: Joint.hh:675
gazebo::physics::Joint::provideFeedback
bool provideFeedback
Provide Feedback data for contact forces.
Definition: Joint.hh:694
gazebo::physics::Joint::CheckAndTruncateForce
double CheckAndTruncateForce(unsigned int _index, double _effort)
check if the force against velocityLimit and effortLimit, truncate if necessary.
gazebo::physics::Joint::Update
void Update()
Update the joint.
gazebo::physics::Joint::AxisFrameOffset
ignition::math::Quaterniond AxisFrameOffset(const unsigned int _index) const
Get orientation of joint axis reference frame relative to joint frame.
gazebo::physics::Joint::LocalAxis
ignition::math::Vector3d LocalAxis(const unsigned int _index) const
Get the axis of rotation.
gazebo::physics::Joint::Detach
virtual void Detach()
Detach this joint from all links.
gazebo::physics::Joint::UpperLimit
virtual double UpperLimit(const unsigned int _index=0) const
Get the joint's upper limit.
boost
Definition: JointMaker.hh:44
gazebo::physics::Joint::SetStiffnessDamping
virtual void SetStiffnessDamping(unsigned int _index, double _stiffness, double _damping, double _reference=0)=0
Set the joint spring stiffness.
system.hh
gazebo::physics::Joint::Position
virtual double Position(const unsigned int _index=0) const final
Get the position of an axis according to its index.
gazebo::physics::Joint::SetLowerLimit
virtual void SetLowerLimit(const unsigned int _index, const double _limit)
Set the joint's lower limit.
gazebo::physics::Joint::PositionImpl
virtual double PositionImpl(const unsigned int _index=0) const =0
Helper function to get the position of an axis.
gazebo::physics::Joint::SetState
void SetState(const JointState &_state)
Set the joint state.
gazebo::physics::Joint::SetVelocity
virtual void SetVelocity(unsigned int _index, double _vel)=0
Set the velocity of an axis(index).
gazebo::physics::Joint::ApplyStiffnessDamping
virtual void ApplyStiffnessDamping()
Callback to apply spring stiffness and viscous damping effects to joint.
gazebo::physics::Joint::effortLimit
double effortLimit[2]
Store Joint effort limit as specified in SDF.
Definition: Joint.hh:669
gazebo::physics::Joint::childLink
LinkPtr childLink
The first link this joint connects to.
Definition: Joint.hh:631
gazebo::physics::Joint::ChildLinkPose
ignition::math::Pose3d ChildLinkPose(const unsigned int _index, const double _position)
internal function to help us compute child link pose if a joint position change is applied.
gazebo::physics::Base::Reset
virtual void Reset()
Reset the object.
gazebo::physics::Joint::GetDamping
double GetDamping(unsigned int _index)
Returns the current joint damping coefficient.
gazebo::physics::Joint::SUSPENSION_ERP
Suspension error reduction parameter.
Definition: Joint.hh:60
gazebo::physics::Joint::GetVelocity
virtual double GetVelocity(unsigned int _index) const =0
Get the rotation rate of an axis(index)
gazebo::physics::Joint::SUSPENSION_CFM
Suspension constraint force mixing.
Definition: Joint.hh:63
gazebo::physics::Joint::GetForce
virtual double GetForce(unsigned int _index)
gazebo::physics::Joint::Reset
virtual void Reset()
Reset the joint.
gazebo::physics::Joint::wrench
JointWrench wrench
Cache Joint force torque values in case physics engine clears them at the end of update step.
Definition: Joint.hh:682
gazebo::physics::Joint::parentAnchorPose
ignition::math::Pose3d parentAnchorPose
Anchor pose relative to parent link frame.
Definition: Joint.hh:651
gazebo::physics::Joint::LO_STOP
Lower joint limit.
Definition: Joint.hh:87
gazebo::physics::Joint::GetEffortLimit
virtual double GetEffortLimit(unsigned int _index)
Get the effort limit on axis(index).
gazebo::physics::Joint::GetStiffness
double GetStiffness(unsigned int _index)
Returns the current joint spring stiffness coefficient.
gazebo::physics::Joint
Base class for all joints.
Definition: Joint.hh:50
gazebo::physics::Base
Base class for most physics classes.
Definition: Base.hh:71
gazebo::physics::Joint::anchorLink
LinkPtr anchorLink
Anchor link.
Definition: Joint.hh:654
gazebo::physics::Joint::FUDGE_FACTOR
Fudge factor.
Definition: Joint.hh:57
gazebo::physics::Joint::WorldPose
ignition::math::Pose3d WorldPose() const
Get pose of joint frame relative to world frame.
gazebo::physics::Joint::SetStopDissipation
void SetStopDissipation(unsigned int _index, double _dissipation)
Set joint stop dissipation.
gazebo::physics::Joint::SetModel
void SetModel(ModelPtr _model)
Set the model this joint belongs too.
gazebo::physics::Joint::GetChild
LinkPtr GetChild() const
Get the child link.
gazebo::physics::Joint::upperLimit
double upperLimit[2]
Store Joint position upper limit as specified in SDF.
Definition: Joint.hh:678
gazebo::physics::Joint::Load
void Load(LinkPtr _parent, LinkPtr _child, const ignition::math::Pose3d &_pose)
Set pose, parent and child links of a physics::Joint.
gazebo::physics::Joint::FMAX
Maximum force.
Definition: Joint.hh:78
gazebo::event::EventT::Connect
ConnectionPtr Connect(const std::function< T > &_subscriber)
Connect a callback to this event.
Definition: Event.hh:558
gazebo::physics::Joint::GetStopStiffness
double GetStopStiffness(unsigned int _index) const
Get joint stop stiffness.
gazebo::physics::Joint::SetProvideFeedback
virtual void SetProvideFeedback(bool _enable)
Set whether the joint should generate feedback.
gazebo::physics::Joint::AnchorErrorPose
ignition::math::Pose3d AnchorErrorPose() const
Get pose offset between anchor pose on child and parent, expressed in the parent link frame.
gazebo::physics::Joint::Init
virtual void Init()
Initialize a joint.
gazebo::physics::Joint::UpdateParameters
virtual void UpdateParameters(sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
gazebo::physics::Joint::anchorPos
ignition::math::Vector3d anchorPos
Anchor pose.
Definition: Joint.hh:641
gazebo::physics::Joint::GetWorldEnergyPotentialSpring
double GetWorldEnergyPotentialSpring(unsigned int _index) const
Returns this joint's spring potential energy, based on the reference position of the spring.
gazebo::physics::Joint::CFM
Constraint force mixing.
Definition: Joint.hh:75
Base.hh
gazebo::physics::BasePtr
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
gazebo::physics::Joint::~Joint
virtual ~Joint()
Destructor.
gazebo::physics::Joint::GetInertiaRatio
double GetInertiaRatio(const unsigned int _index) const
Computes moment of inertia (MOI) across a specified joint axis.
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::physics::Base::sdf
sdf::ElementPtr sdf
The SDF values for this object.
Definition: Base.hh:331
gazebo::physics::Joint::anchorPose
ignition::math::Pose3d anchorPose
Anchor pose specified in SDF <joint><pose> tag.
Definition: Joint.hh:648
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::physics::Joint::SetStopStiffness
void SetStopStiffness(unsigned int _index, double _stiffness)
Set joint stop stiffness.
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::Joint::Attribute
Attribute
Joint attribute types.
Definition: Joint.hh:54
gazebo::physics::Joint::GetVelocityLimit
virtual double GetVelocityLimit(unsigned int _index)
Get the velocity limit on axis(index).
gazebo::physics::Joint::parentLink
LinkPtr parentLink
The second link this joint connects to.
Definition: Joint.hh:634
gazebo::physics::Joint::GetForceTorque
virtual JointWrench GetForceTorque(unsigned int _index)=0
get internal force and torque values at a joint.
JointWrench.hh
gazebo::physics::Joint::ERP
Error reduction parameter.
Definition: Joint.hh:72
gazebo::physics::Joint::Attach
virtual void Attach(LinkPtr _parent, LinkPtr _child)
Attach the two bodies with this joint.
gazebo::physics::Joint::GetParam
virtual double GetParam(const std::string &_key, unsigned int _index)
Get a non-generic parameter for the joint.
gazebo::physics::Joint::Joint
Joint(BasePtr _parent)
Constructor.
gazebo::physics::Joint::ConnectJointUpdate
event::ConnectionPtr ConnectJointUpdate(T _subscriber)
Connect a boost::slot the the joint update signal.
Definition: Joint.hh:213
gazebo::physics::Joint::stiffnessCoefficient
double stiffnessCoefficient[2]
joint stiffnessCoefficient
Definition: Joint.hh:660
gazebo::physics::Joint::RegisterIntrospectionItems
virtual void RegisterIntrospectionItems()
Register items in the introspection service.
gazebo::physics::Link_V
std::vector< LinkPtr > Link_V
Definition: PhysicsTypes.hh:225
gazebo::physics::Joint::dissipationCoefficient
double dissipationCoefficient[2]
joint viscous damping coefficient
Definition: Joint.hh:657
Event.hh
gazebo::physics::Joint::LowerLimit
virtual double LowerLimit(unsigned int _index=0) const
Get the joint's lower limit.
gazebo::physics::Joint::applyDamping
gazebo::event::ConnectionPtr applyDamping
apply damping for adding viscous damping forces on updates
Definition: Joint.hh:666
gazebo::physics::Joint::Fini
virtual void Fini()
Finialize the object.
gazebo::physics::Joint::model
ModelPtr model
Pointer to the parent model.
Definition: Joint.hh:637
gazebo::physics::Joint::SetForce
virtual void SetForce(unsigned int _index, double _effort)=0
Set the force applied to this physics::Joint.
gazebo::physics::Joint::SetEffortLimit
virtual void SetEffortLimit(unsigned int _index, double _effort)
Set the effort limit on a joint axis.
gazebo::physics::JointWrench
Wrench information from a joint. These are forces and torques on parent and child Links,...
Definition: JointWrench.hh:40
gazebo::physics::Joint::LinkForce
virtual ignition::math::Vector3d LinkForce(const unsigned int _index) const =0
Get the forces applied to the center of mass of a physics::Link due to the existence of this Joint.
gazebo::physics::Joint::LinkTorque
virtual ignition::math::Vector3d LinkTorque(const unsigned int _index) const =0
Get the torque applied to the center of mass of a physics::Link due to the existence of this Joint.
gazebo::physics::Joint::ParentWorldPose
ignition::math::Pose3d ParentWorldPose() const
Get anchor pose on parent link relative to world frame.
JointState.hh
gazebo::physics::Joint::axisParentModelFrame
bool axisParentModelFrame[2]
Flags that are set to true if an axis value is expressed in the parent model frame.
Definition: Joint.hh:687
gazebo::physics::Joint::InitialAnchorPose
ignition::math::Pose3d InitialAnchorPose() const
Get initial Anchor Pose specified by model <joint><pose>...</pose></joint>
gazebo::physics::Joint::SetStiffness
virtual void SetStiffness(unsigned int _index, const double _stiffness)=0
Set the joint spring stiffness.
gazebo::physics::Joint::STOP_ERP
Stop limit error reduction parameter.
Definition: Joint.hh:66
gazebo::physics::Joint::VEL
Velocity.
Definition: Joint.hh:81
gazebo::physics::Joint::Anchor
virtual ignition::math::Vector3d Anchor(const unsigned int _index) const =0
Get the anchor point.
gazebo::physics::Joint::SetVelocityLimit
virtual void SetVelocityLimit(unsigned int _index, double _velocity)
Set the velocity limit on a joint axis.