Program Listing for File HingeNode.h#
↰ Return to documentation for file (include/Karana/SOADyn/HingeNode.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/KCore/DataCache.h"
#include"Karana/Math/SpatialVector.h"
#include"Karana/SOADyn/Node.h"
namespaceKarana::Frame{
classFrameToFrame;
}
namespaceKarana::Dynamics{
namespacekf=Karana::Frame;
namespacekm=Karana::Math;
classPhysicalHinge;
classPhysicalSubhinge;
classHingeOnode;
structHingeOnodeInvDynVectors{
km::SpatialVectorf;
};
structHingeOnodeATBIMatrices{
km::Mat66Pplus;//NOLINT(readability-identifier-naming)
};
structHingeOnodeUpsilonMatrices{
km::Mat66UpsilonPlus;//NOLINT(readability-identifier-naming)
};
structHingeOnodeATBIFilterVectors{
km::SpatialVectorzplus;
km::SpatialVectorzplus_extra;
};
structHingeOnodeATBISmootherVectors{
km::SpatialVectoralpha_plus;
km::SpatialVectoralpha_plus_extra;
};
structHingeOnodeATBIDataCaches{
kc::ks_ptr<kc::DataCache<HingeOnodeATBIMatrices>>matrix_cache=nullptr;
kc::ks_ptr<kc::DataCache<HingeOnodeATBIFilterVectors>>filter_cache=nullptr;
kc::ks_ptr<kc::DataCache<HingeOnodeATBISmootherVectors>>smoother_cache=nullptr;
/*DatacacheforATBIbasedinter-bodyforcecomputations*/
kc::ks_ptr<kc::DataCache<km::SpatialVector>>interbody_force_cache=nullptr;
kc::ks_ptr<kc::DataCache<HingeOnodeUpsilonMatrices>>upsilon_matrix_cache=nullptr;
};
classHingeNode:publicNode{
/*foraccessto_hinge*/
friendclassPhysicalBody;
public:
virtual~HingeNode();
std::string_viewtypeString()constnoexceptoverride{
staticstd::stringtype_string="Karana::Dynamics::HingeNode";
returntype_string;
}
constkc::ks_ptr<PhysicalHinge>&hinge()const{return_hinge;}
structDumpOptions:kf::Frame::DumpOptions{
//Addingsuppression,asCodeCheckercomplainsthismethodhasthesamenameasa
//methodinthebaseversion.ThisisjustaCodeCheckerfalsepositive.
//codechecker_suppress[cppcheck-duplInheritedMember]
DumpOptions&operator=(constDumpOptions&p){
if(this!=&p){
Frame::DumpOptions::operator=(p);//Callbaseclassassignmentoperator
//AssignDerived-specificmembershere
cache_deps=p.cache_deps;
}
return*this;
}
};
protected:
HingeNode(std::string_viewname,kc::ks_ptr<PhysicalBody>bd);
kc::ks_ptr<PhysicalHinge>_hinge=nullptr;
};
classHingePnode:publicHingeNode{
//foraccessto_pnode2body_f2f
friendclassPhysicalBody;
//foraccessto_invdyn_cache
friendclassPhysicalHinge;
friendclassHingeOnode;
friendclassCompoundBody;
//foraccessto_computeInvDynetc
friendclassMultibody;
friendclassSubTree;
friendclassPhysicalModalBody;
//foraccesstogyrocache
friendclassCompoundSubhinge;
//foraccesstoinvdynandotherdatacaches
friendclassNode;
//foraccessto_hinge
friendclassLoopConstraint;
//foraccesstoUpsilonmethod
friendclassPhysicalSubhinge;
public:
HingePnode(kc::ks_ptr<PhysicalBody>bd);
virtual~HingePnode();
std::string_viewtypeString()constnoexceptoverride{
staticstd::stringtype_string="Karana::Dynamics::HingePnode";
returntype_string;
}
boolisFinalized()constoverride;
public:
structInvDynVectors{
km::SpatialVectorf;
};
public:
structATBIMatrices{
km::Mat66P;//NOLINT(readability-identifier-naming)
};
structUpsilonMatrices{
km::Mat66Upsilon;//NOLINT(readability-identifier-naming)
};
structATBIFilterVectors{
km::SpatialVectorz;
};
structATBISmootherVectors{};
structATBIDataCaches{
kc::ks_ptr<kc::DataCache<ATBIMatrices>>matrix_cache=nullptr;
kc::ks_ptr<kc::DataCache<ATBIFilterVectors>>filter_cache=nullptr;
kc::ks_ptr<kc::DataCache<ATBISmootherVectors>>smoother_cache=nullptr;
kc::ks_ptr<kc::DataCache<UpsilonMatrices>>upsilon_matrix_cache=nullptr;
};
constkc::ks_ptr<kc::DataCache<ATBIMatrices>>atbiMatrixCache()const{
return_atbi_data_caches.matrix_cache;
}
constATBIMatrices&atbiMatrices()const{returnatbiMatrixCache()->get();}
constkc::ks_ptr<kc::DataCache<UpsilonMatrices>>upsilonMatrixCache()const{
return_atbi_data_caches.upsilon_matrix_cache;
}
constUpsilonMatrices&upsilonMatrices()const{returnupsilonMatrixCache()->get();}
constkc::ks_ptr<kc::DataCache<ATBIFilterVectors>>atbiFilterCache()const{
return_atbi_data_caches.filter_cache;
}
constATBIFilterVectors&atbiFilterVectors()const{returnatbiFilterCache()->get();}
constkc::ks_ptr<kc::DataCache<ATBISmootherVectors>>&atbiSmootherCache()const{
return_atbi_data_caches.smoother_cache;
}
constATBISmootherVectors&atbiSmootherVectors()const{
returnatbiSmootherCache()->get();
}
constkc::ks_ptr<kc::DataCache<InvDynVectors>>inverseDynamicsCache()const{
return_invdyn_data_cache;
}
constInvDynVectors&inverseDynamicsVectors()const{
returninverseDynamicsCache()->get();
}
constkm::Mat&crbInertiaMatrix()const{return_crb_inertia_matrix_cache->get();}
public:
std::stringdumpString(std::string_viewprefix,
constKarana::Core::Base::DumpOptions*options)constoverride;
protected:
void_oneTimeSetupDataCaches();
void_oneTimeTeardownDataCaches();
void_oneTimeTeardown();
km::SpatialVector_externalForces()const;
km::SpatialVector_constraintForces()const;
bool_isFloatingFrame()const;
protected:
//void_computeSpatialInertia(km::SpatialInertia&val);
void_computeMassMatrix(km::Mat66&val);
virtualvoid_computeGyroscopicForce(km::SpatialVector&)const;
virtualvoid_computeInvDynForces(InvDynVectors&val);
virtualvoid_computeATBIMatrices(ATBIMatrices&val);
void_computeATBIFilterVectors(ATBIFilterVectors&val);
void_computeATBISmootherVectors(ATBISmootherVectors&val);
virtualvoid_computeUpsilonMatrices(UpsilonMatrices&val);
void_computeCRBInertiaMatrix(km::Mat&val);
protected:
kc::ks_ptr<kf::FrameToFrame>_pnode2body_f2f;
kc::ks_ptr<kc::DataCache<km::SpatialVector>>_gyroscopic_force_cache;
kc::ks_ptr<kc::DataCache<km::Mat66>>_massmat_cache;
ATBIDataCaches_atbi_data_caches;
kc::ks_ptr<kc::DataCache<InvDynVectors>>_invdyn_data_cache=nullptr;
/*thepraentbody'sapparentmassdatatransformedtothepnode*/
km::Mat66_apparent_mass_data;
kc::ks_ptr<kc::DataCache<km::Mat>>_crb_inertia_matrix_cache=nullptr;
};
classHingeOnode:publicHingeNode{
//foraccessto_pnode2onode_f2f
friendclassHingePnode;
friendclassPhysicalBody;
//foraccessto_body2onode_f2f
friendclassPhysicalSubhinge;
//foraccessto_P_atbi
friendclassPhysicalHinge;
//foraccessto_computeInvDynetc
friendclassMultibody;
friendclassSubTree;
friendclassPhysicalModalBody;
//foraccesstodatacachesetupmethod
friendclassCompoundBody;
//foraccessto_saveExtraATBIVariables()
friendclassAlgorithms;
public:
HingeOnode(std::string_viewname,kc::ks_ptr<PhysicalBody>bd);
virtual~HingeOnode();
std::string_viewtypeString()constnoexceptoverride{
staticstd::stringtype_string="Karana::Dynamics::HingeOnode";
returntype_string;
}
std::stringdumpString(std::string_viewprefix,
constKarana::Core::Base::DumpOptions*options)constoverride;
boolisFinalized()constoverride;
constkc::ks_ptr<kc::DataCache<HingeOnodeATBIMatrices>>&atbiMatrixCache()const{
return_atbi_data_caches.matrix_cache;
}
constHingeOnodeATBIMatrices&atbiMatrices()const{returnatbiMatrixCache()->get();}
constkc::ks_ptr<kc::DataCache<HingeOnodeATBIFilterVectors>>&atbiFilterCache()const{
return_atbi_data_caches.filter_cache;
}
constHingeOnodeATBIFilterVectors&atbiFilterVectors()const{
returnatbiFilterCache()->get();
}
constkc::ks_ptr<kc::DataCache<HingeOnodeATBISmootherVectors>>atbiSmootherCache()const{
return_atbi_data_caches.smoother_cache;
}
constHingeOnodeATBISmootherVectors&atbiSmootherVectors()const{
returnatbiSmootherCache()->get();
}
constkm::SpatialVector&interBodyForce()const{
return_atbi_data_caches.interbody_force_cache->get();
}
constkc::ks_ptr<kc::DataCache<HingeOnodeUpsilonMatrices>>&upsilonMatrixCache()const{
return_atbi_data_caches.upsilon_matrix_cache;
}
constHingeOnodeUpsilonMatrices&upsilonMatrices()const{
returnupsilonMatrixCache()->get();
}
constkc::ks_ptr<kc::DataCache<HingeOnodeInvDynVectors>>inverseDynamicsCache()const{
return_invdyn_data_cache;
}
constHingeOnodeInvDynVectors&inverseDynamicsVectors()const{
returninverseDynamicsCache()->get();
}
km::SpatialVectorgetTAInterBodyForce();
protected:
void_saveExtraATBIVariables();
void_computeInvDynForces(HingeOnodeInvDynVectors&);
void_computeATBIMatrices(HingeOnodeATBIMatrices&val);
void_computeATBIFilterVectors(HingeOnodeATBIFilterVectors&val);
void_computeATBISmootherVectors(HingeOnodeATBISmootherVectors&val,boolis_root_onode);
virtualvoid_computeUpsilonMatrices(HingeOnodeUpsilonMatrices&val,boolis_root_onode);
protected:
km::SpatialVector_getInterBodyForce();
protected:
void_oneTimeSetupDataCaches();
void_oneTimeTeardownDataCaches();
void_oneTimeSetupDataCacheGatherCallbacks();
void_oneTimeTeardownDataCacheGatherCallbacks();
void_oneTimeTeardown();
void_setupDataCachesWithParentPnode();
void_teardownDataCachesWithParentPnode();
protected:
kc::ks_ptr<kf::OrientedChainedFrameToFrame>_pnode2onode_f2f=nullptr;
kc::ks_ptr<kf::FrameToFrame>_body2onode_f2f=nullptr;
HingeOnodeATBIDataCaches_atbi_data_caches;
kc::ks_ptr<kc::DataCache<HingeOnodeInvDynVectors>>_invdyn_data_cache=nullptr;
};
}//namespaceKarana::Dynamics