Program Listing for File SubGraph.h#
↰ Return to documentation for file (include/Karana/SOADyn/SubGraph.h)
/*
*Copyright(c)2024-2025KaranaDynamicsPtyLtd.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;
classLoopConstraintHinge;
classLoopConstraintConVel;
classCoordinateConstraint;
classConstraintKinematicsSolver;
classMultiJacobianGenerator;
classSubGraph:publicSubTree{
//foraccessto_loop_constraint_list
friendclassLoopConstraintHinge;
friendclassLoopConstraintConVel;
friendclassLoopsCompoundBody;
//foraccessto_enabled_hinge_loop_constraints_list
friendConstraintKinematicsSolver;
//foraccessto_Qrows
friendclassAlgorithms;
//foraccessto_resetSubhingeCharts
friendclassStatePropagator;
public:
SubGraph(conststd::string&name,
kc::ks_ptr<BodyBase>root,
kc::ks_ptr<SubGraph>parent_subgraph=nullptr);
virtual~SubGraph(){};
conststd::string&typeString()constnoexceptoverride{
staticstd::stringtype_string="Karana::Dynamics::SubGraph";
returntype_string;
}
boolisSubGraph()constoverride{returntrue;}
statickc::ks_ptr<SubGraph>
create(kc::ks_ptr<SubGraph>parent_sg,
conststd::string&name,
kc::ks_ptr<BodyBase>new_root,
conststd::vector<kc::ks_ptr<BilateralConstraintBase>>&constraints={},
conststd::vector<kc::ks_ptr<BodyBase>>&use_branches={},
conststd::vector<kc::ks_ptr<BodyBase>>&stop_at={});
constkc::ks_ptr<CoordData>&constraintCoordData()const;
kc::ks_ptr<SubGraph>
aggregationSubGraph(conststd::string&name,
std::vector<kc::ks_ptr<BilateralConstraintBase>>constraints);
kc::ks_ptr<BilateralConstraintBase>getEnabledConstraint(conststd::string&name)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;
voidinheritConstraints();
voiddisplayModel(conststd::string&prefix="")constoverride;
std::stringdumpString(conststd::string&prefix,
constKarana::Core::Base::dumpOptions*options)constoverride;
std::vector<kc::ks_ptr<CoordData>>coordDataList()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();
constkc::ks_ptr<CoordData>graphCoordData()const;
voidarticulateSubhinge(kc::ks_ptr<SubhingeBase>shg,
size_tsubhinge_index,
booldisable_ik=false,
doublerangeQ=.5,
doubledQ=.01,
doublepause=.01);
//TODO-getridofthismethod,andhavethediscardmethoddo
//theworkoncewegetitworking
voidresetCks();
voiddumpTree(conststd::string&prefix="",
constdumpTreeOptionsoptions=
dumpTreeOptions(false,false,false,false,false))constoverride;
km::VecposeError()const;
km::VecvelError()const;
km::VecaccelError()const;
km::MatconstraintsErrorPoseGradient()const;
km::MatconstraintsErrorVelJacobian()const;
staticstd::vector<unsignedint>
dependentIndices(size_tnU,conststd::vector<unsignedint>&indep_indices);
conststd::vector<kc::ks_ptr<LoopConstraintHinge>>&enabledHingeLoopConstraints()const;
conststd::vector<kc::ks_ptr<LoopConstraintConVel>>&enabledConVelLoopConstraints()const;
conststd::vector<kc::ks_ptr<CoordinateConstraint>>&enabledCoordinateConstraints()const;
size_tnLoopConstraintResiduals()const;
protected:
kc::ks_ptr<MultiJacobianGenerator>_hingeLoopConstraintsErrorJacobianGen()const;
kc::ks_ptr<MultiJacobianGenerator>_nonHingeLoopConstraintsJacobianGen()const;
km::Mat_getCoordinateConstraintsErrorJacobian()const;
km::Mat_getNonHingeLoopConstraintsErrorJacobian()const;
#if0
km::Mat_getVelocityResidualsJacobian()const;
#endif
//km::Mat_velJacobianNumDiff()const;
//boolcheckVelJacobian(doubletolerance=1e-6)const;
protected:
CoordData::CoordOffset_coordOffsets(kc::id_tid)constoverride;
void_resetSubhingeCharts()override;
void_clearExternals()override;
void_discard(kc::ks_ptr<Base>&base)override;
void_makeConstrainCoordData()const;
km::Mat_constraintsQmat()const;
kc::ks_ptr<CoordinateConstraint>
_getEnabledCoordinateConstraint(conststd::string&name)const;
kc::ks_ptr<LoopConstraintBase>_getEnabledLoopConstraint(conststd::string&name)const;
conststd::vector<kc::ks_ptr<LoopConstraintBase>>&_enabledLoopConstraints()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<LoopConstraintBase>_enabled_loop_constraints_list;
kc::RegistryList<LoopConstraintHinge>_enabled_hinge_loop_constraints_list;
kc::RegistryList<LoopConstraintConVel>_enabled_nonhinge_loop_constraints_list;
kc::RegistryList<CoordinateConstraint>_enabled_coordinate_constraints_list;
size_t_Qrows_loop=0;
size_t_Qrows_coord=0;
kc::RegistryList<Node>_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>_hinge_loops_multi_jacgen=nullptr;
mutablekc::ks_ptr<MultiJacobianGenerator>_non_hinge_loops_multi_jacgen=nullptr;
};
}//namespaceKarana::Dynamics