##

ODEJoint.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 _ODEJOINT_HH_
#define _ODEJOINT_HH_
#include <boost/any.hpp>
#include <string>
#include "gazebo/physics/ode/ODEPhysics.hh"
#include "gazebo/physics/Joint.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace physics
{
class GZ_PHYSICS_VISIBLE ODEJoint : public Joint
{
public: enum CFMMode
{
NONE = 0x00000000,
DAMPING_ACTIVE = 0x00000001,
JOINT_LIMIT = 0x00000002
};
public: explicit ODEJoint(BasePtr _parent);
public: virtual ~ODEJoint();
// Documentation inherited.
public: virtual void Load(sdf::ElementPtr _sdf) override;
// Documentation inherited.
public: virtual void Fini() override;
// Documentation inherited.
public: virtual void Reset() override;
// Documentation inherited.
public: virtual LinkPtr GetJointLink(unsigned int _index) const override;
// Documentation inherited.
public: virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const
override;
// Documentation inherited.
public: virtual void CacheForceTorque() override;
public: virtual double GetParam(unsigned int _parameter) const;
public: virtual void SetParam(unsigned int _parameter, double _value);
// Documentation inherited
public: virtual void SetDamping(unsigned int _index, double _damping)
override;
// Documentation inherited.
public: virtual bool SetPosition(
const unsigned int _index,
const double _position,
const bool _preserveWorldVelocity = false)
override;
// Documentation inherited.
public: virtual void SetStiffness(unsigned int _index,
const double _stiffness) override;
// Documentation inherited.
public: virtual void SetStiffnessDamping(unsigned int _index,
double _stiffness, double _damping, double _reference = 0) override;
// Documentation inherited.
public: virtual void Attach(LinkPtr _parent, LinkPtr _child) override;
// Documentation inherited.
public: virtual void Detach() override;
public: void SetERP(double _erp);
public: double GetERP();
public: void SetCFM(double _cfm);
public: double GetCFM();
public: dJointFeedback *GetFeedback();
public: bool UsesImplicitSpringDamper();
public: void UseImplicitSpringDamper(const bool _implicit);
public: void ApplyImplicitStiffnessDamping();
public: void ApplyExplicitStiffnessDamping();
public: double GetStopCFM()
{
return this->stopCFM;
}
public: double GetStopERP()
{
return this->stopERP;
}
private: double ApplyAdaptiveDamping(unsigned int _index,
const double _damping);
private: void KpKdToCFMERP(const double _dt,
const double _kp, const double _kd,
double &_cfm, double &_erp);
private: void CFMERPToKpKd(const double _dt,
const double _cfm, const double _erp,
double &_kp, double &_kd);
private: int implicitDampingState[MAX_JOINT_AXIS];
private: double currentKd[MAX_JOINT_AXIS];
private: double currentKp[MAX_JOINT_AXIS];
private: bool stiffnessDampingInitialized;
private: bool useImplicitSpringDamper;
// Documentation inherited.
public: virtual void SetUpperLimit(const unsigned int _index,
const double _limit) override;
// Documentation inherited.
public: virtual void SetLowerLimit(const unsigned int _index,
const double _limit) override;
// Documentation inherited.
public: virtual ignition::math::Vector3d LinkForce(
const unsigned int _index) const override;
// Documentation inherited.
public: virtual ignition::math::Vector3d LinkTorque(
const unsigned int _index) const override;
// Documentation inherited.
public: virtual void SetAxis(const unsigned int _index,
const ignition::math::Vector3d &_axis) override;
// Documentation inherited.
public: virtual bool SetParam(const std::string &_key,
unsigned int _index,
const boost::any &_value) override;
// Documentation inherited.
public: virtual double GetParam(const std::string &_key,
unsigned int _index) override;
// Documentation inherited.
public: virtual void SetProvideFeedback(bool _enable) override;
// Documentation inherited.
public: virtual JointWrench GetForceTorque(unsigned int _index) override;
// Documentation inherited.
public: virtual void SetForce(unsigned int _index, double _force)
override;
// Documentation inherited.
public: virtual double GetForce(unsigned int _index) override;
// Documentation inherited.
public: virtual void ApplyStiffnessDamping() override;
// Documentation inherited.
protected: virtual void SetForceImpl(
unsigned int _index, double _force) = 0;
private: void SaveForce(unsigned int _index, double _force);
protected: dJointID jointId;
private: dJointFeedback *feedback;
private: double stopCFM;
private: double stopERP;
private: double forceApplied[MAX_JOINT_AXIS];
private: common::Time forceAppliedTime;
};
}
}
#endif
gazebo::physics::ODEJoint::ODEJoint
ODEJoint(BasePtr _parent)
Constructor.
gazebo::physics::ODEJoint::SetDamping
virtual void SetDamping(unsigned int _index, double _damping) override
Set the joint damping.
gazebo::physics::ODEJoint::SetLowerLimit
virtual void SetLowerLimit(const unsigned int _index, const double _limit) override
Set the joint's lower limit.
MAX_JOINT_AXIS
#define MAX_JOINT_AXIS
maximum number of axis per joint anticipated.
Definition: Joint.hh:39
gazebo::physics::ODEJoint::GetFeedback
dJointFeedback * GetFeedback()
Get the feedback data structure for this joint, if set.
gazebo::physics::ODEJoint
ODE joint interface.
Definition: ODEJoint.hh:35
gazebo::physics::ODEJoint::Load
virtual void Load(sdf::ElementPtr _sdf) override
Load physics::Joint from a SDF sdf::Element.
gazebo::physics::ODEJoint::LinkTorque
virtual ignition::math::Vector3d LinkTorque(const unsigned int _index) const override
Get the torque applied to the center of mass of a physics::Link due to the existence of this Joint.
gazebo::physics::ODEJoint::GetJointLink
virtual LinkPtr GetJointLink(unsigned int _index) const override
Get the link to which the joint is attached according the _index.
gazebo::physics::ODEJoint::CFMMode
CFMMode
internal variables used for implicit damping
Definition: ODEJoint.hh:38
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
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::ODEJoint::SetAxis
virtual void SetAxis(const unsigned int _index, const ignition::math::Vector3d &_axis) override
Set the axis of rotation where axis is specified in local joint frame.
gazebo::physics::ODEJoint::CacheForceTorque
virtual void CacheForceTorque() override
Cache Joint Force Torque Values if necessary for physics engine.
gazebo::physics::ODEJoint::Reset
virtual void Reset() override
Reset the joint.
system.hh
gazebo::physics::ODEJoint::SetERP
void SetERP(double _erp)
Set the ERP of this joint.
gazebo::physics::ODEJoint::UsesImplicitSpringDamper
bool UsesImplicitSpringDamper()
Get flag indicating whether implicit spring damper is enabled.
gazebo::physics::ODEJoint::ApplyExplicitStiffnessDamping
void ApplyExplicitStiffnessDamping()
simulating a joint spring and damper explicitly.
gazebo::physics::ODEJoint::DAMPING_ACTIVE
implicit damping active, joints within limits
Definition: ODEJoint.hh:43
gazebo::physics::ODEJoint::UseImplicitSpringDamper
void UseImplicitSpringDamper(const bool _implicit)
Set flag indicating whether implicit spring damper is enabled.
gazebo::physics::ODEJoint::~ODEJoint
virtual ~ODEJoint()
Destructor.
gazebo::physics::ODEJoint::jointId
dJointID jointId
This is our ODE ID.
Definition: ODEJoint.hh:275
gazebo::physics::ODEJoint::SetPosition
virtual bool SetPosition(const unsigned int _index, const double _position, const bool _preserveWorldVelocity=false) override
The child links of this joint are updated based on desired position.
gazebo::physics::ODEJoint::GetCFM
double GetCFM()
Get the CFM of this joint.
gazebo::physics::ODEJoint::GetForce
virtual double GetForce(unsigned int _index) override
gazebo::physics::Joint
Base class for all joints.
Definition: Joint.hh:50
gazebo::physics::ODEJoint::AreConnected
virtual bool AreConnected(LinkPtr _one, LinkPtr _two) const override
Determines of the two bodies are connected by a joint.
gazebo::physics::ODEJoint::SetStiffnessDamping
virtual void SetStiffnessDamping(unsigned int _index, double _stiffness, double _damping, double _reference=0) override
Set the joint spring stiffness.
gazebo::physics::ODEJoint::Fini
virtual void Fini() override
Finialize the object.
gazebo::physics::ODEJoint::GetParam
virtual double GetParam(unsigned int _parameter) const
Get an ODE joint parameter.
gazebo::physics::ODEJoint::GetForceTorque
virtual JointWrench GetForceTorque(unsigned int _index) override
get internal force and torque values at a joint.
Joint.hh
gazebo::physics::ODEJoint::SetParam
virtual void SetParam(unsigned int _parameter, double _value)
Set an ODE joint paramter.
gazebo::physics::ODEJoint::SetStiffness
virtual void SetStiffness(unsigned int _index, const double _stiffness) override
Set the joint spring stiffness.
gazebo::physics::BasePtr
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
gazebo::physics::ODEJoint::LinkForce
virtual ignition::math::Vector3d LinkForce(const unsigned int _index) const override
Get the forces applied to the center of mass of a physics::Link due to the existence of this Joint.
ODEPhysics.hh
gazebo::physics::ODEJoint::SetCFM
void SetCFM(double _cfm)
Set the CFM of this joint.
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::ODEJoint::GetStopCFM
double GetStopCFM()
Get access to stopCFM.
Definition: ODEJoint.hh:152
gazebo::physics::ODEJoint::Detach
virtual void Detach() override
Detach this joint from all links.
gazebo::physics::ODEJoint::Attach
virtual void Attach(LinkPtr _parent, LinkPtr _child) override
Attach the two bodies with this joint.
gazebo::physics::ODEJoint::GetStopERP
double GetStopERP()
Get access to stopERP.
Definition: ODEJoint.hh:159
gazebo::physics::ODEJoint::SetUpperLimit
virtual void SetUpperLimit(const unsigned int _index, const double _limit) override
Set the joint's upper limit.
gazebo::physics::JointWrench
Wrench information from a joint. These are forces and torques on parent and child Links,...
Definition: JointWrench.hh:40
gazebo::physics::ODEJoint::NONE
implicit damping not active
Definition: ODEJoint.hh:41
gazebo::physics::ODEJoint::ApplyStiffnessDamping
virtual void ApplyStiffnessDamping() override
Callback to apply spring stiffness and viscous damping effects to joint.
gazebo::physics::ODEJoint::SetForceImpl
virtual void SetForceImpl(unsigned int _index, double _force)=0
Set the force applied to this physics::Joint.
gazebo::physics::ODEJoint::JOINT_LIMIT
implicit damping not active, enforcing joints limits
Definition: ODEJoint.hh:45
gazebo::physics::ODEJoint::SetForce
virtual void SetForce(unsigned int _index, double _force) override
Set the force applied to this physics::Joint.
gazebo::physics::ODEJoint::SetProvideFeedback
virtual void SetProvideFeedback(bool _enable) override
Set whether the joint should generate feedback.
gazebo::physics::ODEJoint::GetERP
double GetERP()
Get the ERP of this joint.
gazebo::physics::ODEJoint::ApplyImplicitStiffnessDamping
void ApplyImplicitStiffnessDamping()
simulate implicit spring and damper with CFM/ERP and meddling with Joint limits.