Program Listing for File SubGraph.h#
↰ Return to documentation for file (include/Karana/SOADyn/SubGraph.h)
/*
*Copyright(c)2024-2026KaranaDynamicsPtyLtd.Allrightsreserved.
*
*NOTICETOUSER:
*
*Thissourcecodeand/ordocumentation(the"LicensedMaterials")is
*theconfidentialandproprietaryinformationofKaranaDynamicsInc.
*UseoftheseLicensedMaterialsisgovernedbythetermsandconditions
*ofaseparatesoftwarelicenseagreementbetweenKaranaDynamicsandthe
*Licensee("LicenseAgreement").Unlessexpresslypermittedunderthat
*agreement,anyreproduction,modification,distribution,ordisclosure
*oftheLicensedMaterials,inwholeorinpart,toanythirdparty
*withoutthepriorwrittenconsentofKaranaDynamicsisstrictlyprohibited.
*
*THELICENSEDMATERIALSAREPROVIDED"ASIS"WITHOUTWARRANTYOFANYKIND.
*KARANADYNAMICSDISCLAIMSALLWARRANTIES,EXPRESSORIMPLIED,INCLUDING
*BUTNOTLIMITEDTOWARRANTIESOFMERCHANTABILITY,NON-INFRINGEMENT,AND
*FITNESSFORAPARTICULARPURPOSE.
*
*INNOEVENTSHALLKARANADYNAMICSBELIABLEFORANYDAMAGESWHATSOEVER,
*INCLUDINGBUTNOTLIMITEDTOLOSSOFPROFITS,DATA,ORUSE,EVENIF
*ADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES,WHETHERINCONTRACT,TORT,
*OROTHERWISEARISINGOUTOFORINCONNECTIONWITHTHELICENSEDMATERIALS.
*
*U.S.GovernmentEndUsers:TheLicensedMaterialsarea"commercialitem"
*asdefinedat48C.F.R.2.101,andareprovidedtotheU.S.Government
*onlyasacommercialenditemunderthetermsofthislicense.
*
*AnyuseoftheLicensedMaterialsinindividualorcommercialsoftwaremust
*include,intheuserdocumentationandinternalsourcecodecomments,
*thisNotice,Disclaimer,andU.S.GovernmentUseProvision.
*/
#pragmaonce
#include"Karana/SOADyn/SubTree.h"
namespaceKarana::Dynamics{
classBilateralConstraintBase;
classLoopConstraintBase;
classLoopConstraintCutJoint;
classLoopConstraintConVel;
classCoordinateConstraint;
classConstraintKinematicsSolver;
classMultiJacobianGenerator;
classSubGraph:publicSubTree{
//foraccessto_loop_constraint_list
friendclassLoopConstraintCutJoint;
friendclassLoopConstraintConVel;
friendclassCECompoundBody;
//foraccessto_enabled_cutjoint_loop_constraints_list
friendConstraintKinematicsSolver;
//foraccessto_Qrows
friendclassAlgorithms;
//foraccessto_resetSubhingeCharts
friendclassModelManager;
//foraccesstoJacobiangenerator
friendclassPartitionedCompoundBody;
public:
SubGraph(std::string_viewname,
kc::ks_ptr<BodyBase>root,
kc::ks_ptr<SubGraph>parent_sg=nullptr);
virtual~SubGraph(){};
boolisSubGraph()constoverride{returntrue;}
statickc::ks_ptr<SubGraph>
create(std::string_viewname,
kc::ks_ptr<SubGraph>parent_sg,
kc::ks_ptr<BodyBase>new_root,
conststd::vector<kc::ks_ptr<BodyBase>>&use_branches={},
conststd::vector<kc::ks_ptr<BodyBase>>&stop_at={},
boolinherit_constraints=true);
constkc::ks_ptr<CoordData>&cutjointCoordData()const;
kc::ks_ptr<SubGraph>
aggregationSubGraph(std::string_viewname,
std::vector<kc::ks_ptr<BilateralConstraintBase>>constraints,
boolwith_velocity_constraints);
kc::ks_ptr<BilateralConstraintBase>getEnabledConstraint(std::string_viewname)const;
std::vector<kc::ks_ptr<CoordinateConstraint>>
getBodyCoordinateConstraints(constPhysicalBody&body)const;
std::vector<kc::ks_ptr<LoopConstraintBase>>
getBodyLoopConstraints(constPhysicalBody&body)const;
std::vector<kc::ks_ptr<PhysicalBody>>
getLoopConstraintBodies(constLoopConstraintBase&c)const;
voiddisplayModel(std::string_viewprefix="")constoverride;
std::stringdumpString(std::string_viewprefix,
constKarana::Core::Base::DumpOptions*options)constoverride;
std::vector<kc::ks_ptr<BilateralConstraintBase>>enabledConstraints()const;
voidenableConstraint(constkc::ks_ptr<BilateralConstraintBase>constraint);
voiddisableConstraint(kc::ks_ptr<BilateralConstraintBase>constraint);
constkc::ks_ptr<ConstraintKinematicsSolver>&cks();
conststd::pair<kc::ks_ptr<CoordBase>,size_t>coordAt(size_tu_offset)constoverride;
conststd::pair<kc::ks_ptr<kc::LockingBase>,size_t>
constraintErrorAt(size_trow_offset)const;
conststd::pair<kc::ks_ptr<kc::LockingBase>,size_t>
constraintResidualAt(size_trow_offset)const;
km::MatconstraintsGc();
km::MatGamma();//NOLINT(readability-identifier-naming)
constkc::ks_ptr<CoordData>graphCoordData()const;
constkc::ks_ptr<CoordData>treeCoordData()constoverride;
constkc::ks_ptr<CoordData>articulationCoordData()constoverride;
voidarticulateSubhinge(kc::ks_ptr<SubhingeBase>shg,
size_tsubhinge_index,
booldisable_ik=false,
doublerange_q=.5,
doubled_q=.01,
doublepause=.01);
voiddumpTree(std::string_viewprefix="",
constDumpTreeOptionsoptions=
DumpTreeOptions(false,false,false,false,false))constoverride;
km::VecposeError()const;
km::VecvelError()const;
km::VecaccelError()const;
km::MatconstraintsErrorPoseGradient()const;
km::MatconstraintsErrorVelJacobian()const;
km::MatconstraintsErrorVelJacobianDot()const;
staticstd::vector<unsignedint>
complementaryIndices(size_tn_u,conststd::vector<unsignedint>&indep_indices);
conststd::vector<kc::ks_ptr<LoopConstraintCutJoint>>&
enabledCutJointLoopConstraints()const;
conststd::vector<kc::ks_ptr<LoopConstraintConVel>>&enabledConVelLoopConstraints()const;
conststd::vector<kc::ks_ptr<CoordinateConstraint>>&enabledCoordinateConstraints()const;
size_tnLoopConstraintResiduals()const;
voidenableSubhingeCharts(boolflag)override;
protected:
std::vector<kc::ks_ptr<CoordData>>_coordDataList()constoverride;
km::Mat_constraintsQmat()const;
kc::ks_ptr<MultiJacobianGenerator>_constraintsNodesTreeJacobianGen()const;
conststd::vector<kc::ks_ptr<ConstraintNode>>&_constraintNodes()const;
protected:
kc::ks_ptr<CoordinateConstraint>
_getEnabledCoordinateConstraint(std::string_viewname)const;
kc::ks_ptr<LoopConstraintCutJoint>
_getEnabledCutJointConstraint(std::string_viewname)const;
kc::ks_ptr<LoopConstraintConVel>_getEnabledConVelConstraint(std::string_viewname)const;
kc::ks_ptr<MultiJacobianGenerator>_cutjointConstraintsErrorJacobianGen()const;
kc::ks_ptr<MultiJacobianGenerator>_convelConstraintsJacobianGen()const;
km::Mat_getCoordinateConstraintsErrorJacobian()const;
km::Mat_getConVelLoopConstraintsErrorJacobian()const;
km::Mat_getConVelLoopConstraintsErrorJacobianDot()const;
protected:
void_inheritConstraints();
CoordData::CoordOffset_coordOffsets(kc::id_tid)constoverride;
void_resetSubhingeCharts()override;
void_clearExternals()override;
void_discard(kc::ks_ptr<Base>&base)override;
void_makeConstrainCoordData()const;
void_enableLoopConstraint(constkc::ks_ptr<LoopConstraintBase>constraint);
void_disableLoopConstraint(kc::ks_ptr<LoopConstraintBase>constraint);
void_enableCoordinateConstraint(constkc::ks_ptr<CoordinateConstraint>constraint);
void_disableCoordinateConstraint(kc::ks_ptr<CoordinateConstraint>constraint);
protected:
kc::RegistryList<LoopConstraintCutJoint>_enabled_cutjoint_loop_constraints_list;
kc::RegistryList<LoopConstraintConVel>_enabled_convel_loop_constraints_list;
kc::RegistryList<CoordinateConstraint>_enabled_coordinate_constraints_list;
bool_has_enabled_constraints=false;
size_t_rowsQ_loop=0;
size_t_rowsQ_coord=0;
kc::RegistryList<ConstraintNode>_loop_constraint_nodes_list;
kc::RegistryList<PhysicalSubhinge>_coordinate_constraint_subhinges_list;
mutablekc::ks_ptr<CoordData>_constraint_coord_data=nullptr;
kc::ks_ptr<ConstraintKinematicsSolver>_cks=nullptr;
mutablekc::ks_ptr<CoordData>_graph_coord_data=nullptr;
mutablekc::ks_ptr<MultiJacobianGenerator>_cutjoint_loops_multi_jacgen=nullptr;
mutablekc::ks_ptr<MultiJacobianGenerator>_non_cutjoint_loops_multi_jacgen=nullptr;
mutablekc::ks_ptr<MultiJacobianGenerator>_constraint_nodes_tree_multi_jacgen;
double_baumgarte_stabilization_enabled=false;
double_baumgarte_stiffness=km::notReadyNaN;
double_baumgarte_damping=km::notReadyNaN;
};
}//namespaceKarana::Dynamics