Class LoopConstraintCutJoint#

Inheritance Relationships#

Base Type#

Class Documentation#

class LoopConstraintCutJoint : public Karana::Dynamics::LoopConstraintBase#

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

hinge_loop_constraints_sec section for more discussion on cutjoint loop constraints.

Public Functions

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

Constructor.

Parameters:
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)#

Apply the input T 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 error

km::SpatialVector getInterBodyForceTAFwdDyn()#

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<LoopConstraintCutJoint> create(std::string_view name, kc::ks_ptr<Multibody> &mb, kc::ks_ptr<kf::FrameToFrame> constraint_f_to_f, HingeBase::HingeType htype, const std::vector<SubhingeBase::SubhingeType> &subhinge_types = std::vector<SubhingeBase::SubhingeType>())#

Factory method for creating a LoopConstraintCutJoint instance.

Parameters:
Returns:

a LoopConstraintCutJoint instance

static kc::ks_ptr<PhysicalHinge> toPhysicalHinge(kc::ks_ptr<LoopConstraintCutJoint> 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 discarded 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 nResiduals() size accel residual term for the constraint.

Used for computing the acceleration kinematics and the lambda (Lagrange multiplier) terms for the TA dynamics correction step

Returns:

The acceleration residual error

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 LoopConstraintCutJoint.

Parameters:

base – - Base pointer to the LoopConstraintCutJoint to discard.

virtual void _computeQMats(QMats &val) override#

Callback to compute the source and target Q matrices for the constraint.

Parameters:

val – the data buffer for the computed value

km::SpatialVector _constraintSpForceTToTarget(const km::Vec &T) const#

Get the full spatial force needed at the target constraint node for the generalized force being applied at the constraint hinge.

Parameters:

T – the applied generalized force

Returns:

the spatial force at the target constraint node

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

Get the full spatial force needed at the source constraint node for the spatial force being applied at the target constraint node.

Parameters:

tgt_f – the spatial force at the target constraint node

Returns:

the spatial force at the source constraint node

virtual km::Vec _poseResidual() const override#

Return the nResiduals() size pose residual term for the constraint.

Used for computing the Baumgarte error control term for TA dynamics

Returns:

The pose residual error

virtual km::Vec _velResidual() const override#

Return the nResiduals() size velocity residual term for the constraint.

Used for computing the Baumgarte error control term for TA dynamics

Returns:

The velocity residual error

Protected Attributes

kc::ks_ptr<kf::FrameToFrame> _error_f2f#

the f2f measure the error for the constraint. The constraint is satisfied when the transform etc values for this f2f are zero

std::optional<HingeBase::HingeType> _hinge_type = std::nullopt#

the cut-joint constraint’s hinge type