Class LoopConstraintHinge#

Inheritance Relationships#

Base Type#

Class Documentation#

class LoopConstraintHinge : public Karana::Dynamics::LoopConstraintBase#

Class for loop constraints that are based on a hinge to define the constraint See the.

Hinge loop-constraints section for more discussion on hinge loop constraints.

Public Functions

LoopConstraintHinge(kc::ks_ptr<Multibody> &mb, kc::ks_ptr<kf::FrameToFrame> constrainet_f_to_f, std::string_view name, HingeBase::HingeType htype, const std::vector<SubhingeBase::SubhingeType> &subhinge_types = std::vector<SubhingeBase::SubhingeType>())#

Constructor.

Parameters:
inline virtual std::string_view typeString() const noexcept override#

Returns the type string of Base.

Returns:

The type string.

inline virtual bool hasHinge() const override#

Return true if the loop constraint is based on a hinge.

Returns:

true if the loop constraint is based on a hinge

inline kc::ks_ptr<FramePairHinge> hinge() const#

Return the FramePairHinge hinge associated with this loop constraint.

When the constraint is satisfied, the relative configuration, velocity and accel values across the f2f are constrained to those satisfied by the associated constraint hinge

Returns:

the FramePairHinge instance

inline kc::ks_ptr<kf::FrameToFrame> errorFrameToFrame() const#

the Karana::Frame::FrameToFrame that measures the constraint residual error

The constraint is fully satisfied only when this f2f relative transform, spatial velocity and acceleration values are zero, i.e. its oframe and pframe are coincident

Returns:

the error FrameToFrame instance

void spExternalForceFromT(const km::Vec &T, bool no_accumulate = true)#

ApplyT generalized force at the constraint hinge as an external force.

This method is used to handle any generalized forces at cut-joints. Once the joint is cut, its generalized forces are no longer included in the normal dynamics. The workaround is to convert the cut-joint generalized forces into equivalent equal and opposite external forces at the constraint nodes for the cut-joint.

Parameters:
  • T – the input generalized forces

  • no_accumulate – if true, then accumulate the input forces at the constraint nodes

virtual km::Vec poseError() const override#

Return the 6 size pose residual term for the constraint.

Used for computing the pose configuration kinematics

Returns:

The pose eror

km::SpatialVector getTAInterBodyForce()#

Return the interbody spatial force at the source node for TA dynamics.

This method returns the interbody force at the source when doing TA dynamics for the loop constraint. The force has the sign as if acting on the target node (this is consistent with our general convention to book keep the pnode’s inter-body force at the onode). The term also includes contributions from any generalized forces at the cut-joint.

The method should only be called after TA forward dynamics has been called, since it expects the constraint forces to be set in the constraint nodes. Also this method assumes that the T value in the CoordData member is the cutjoint generalized force value.

Returns:

the inter-body spatial force

inline virtual size_t nResiduals() const override#

Return the size of residuals for the constraint.

Returns:

the residuals size for the constraint

virtual km::Vec velError() const override#

Return the current constraint spatial velocity error.

Returns:

the spatial velocity error as a 6-vector

virtual km::Vec accelError() const override#

Return the current constraint spatial acceleration error.

Returns:

the spatial acceleration error as a 6-vector

Public Static Functions

static const kc::ks_ptr<LoopConstraintHinge> create(kc::ks_ptr<Multibody> &mb, kc::ks_ptr<kf::FrameToFrame> constraint_f_to_f, std::string_view name, HingeBase::HingeType htype, const std::vector<SubhingeBase::SubhingeType> &subhinge_types = std::vector<SubhingeBase::SubhingeType>())#

Factory method for creating a LoopConstraintHinge instance.

Parameters:
Returns:

a LoopConstraintHinge instance

static kc::ks_ptr<PhysicalHinge> toPhysicalHinge(kc::ks_ptr<LoopConstraintHinge> lc, bool reverse)#

Convert this loop constraint into an inter-body PhysicalHinge.

Replaces the loop constraint with a hinge between the constraint nodes to make one body the child of the other. This method can only be called when the new child body (either of source or target) is a base body with a 6 dof hinge. This requirement allows us to preserve the system’s tree topology. If reverse false, the target node’s body is made the child of the source node’s body, and the converse if reverse is true. The original loop constraint is discared by this method.

Parameters:
  • lc – The loop constraint to replace with a hinge

  • reverse – If true, reverse the polarity of the hinge

Returns:

the new hinge

Protected Functions

virtual km::Vec _accelResidual() const override#

Return the (6-nU) size accel residual term for the constraint.

Used for computing the lambda (Lagrnage multiplier) terms for the TA dynamics correction step

Returns:

The acceleraton residual eror

void _updateInvDynT()#

Update the generalized force values for the constraint hinge from the constraint forces. This is used when running inverse dynamics with loops, to recover the constraint hinge generalized forces from the constraint forces.

void _discard(kc::ks_ptr<Base> &base) override#

Discard the provided LoopConstraintHinge.

Parameters:

base – - Base pointer to the LoopConstraintHinge to discard.

virtual void _computeQMats(QMats &val) override#
km::SpatialVector _constraintSpForceT2Target(const km::Vec &T) const#

Get the full spatial force needed at the source and target constraint nodes for the generalized force being applied at the constraint hinge

km::SpatialVector _constraintSpForceT2Source(const km::SpatialVector &tgt_f) const#

Protected Attributes

kc::ks_ptr<kf::FrameToFrame> _error_f2f#
std::optional<HingeBase::HingeType> _hinge_type = std::nullopt#