Program Listing for File Frame2Frame.h#
↰ Return to documentation for file (include/Karana/Frame/Frame2Frame.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/Frame/Frame.h"
#include"Karana/KCore/Base.h"
#include"Karana/KCore/DataCache.h"
#include"Karana/Math/HomTran.h"
#include"Karana/Math/SpatialVector.h"
#include<memory>
namespaceKarana::Frame{
namespacekc=Karana::Core;
namespacekm=Karana::Math;
classFrame2Frame:publickc::LockingBase{
public:
virtual~Frame2Frame();
constkc::ks_ptr<Frame>&oframe()const;
constkc::ks_ptr<Frame>&pframe()const;
std::optional<bool>subchainOrientation(constFrame2Frame&sub_f2f)const;
constkm::HomTran&relTransform()const;
constkm::SpatialVector&relSpVel()const;
km::Vec6oframeDerivRelRates()const;
constkm::SpatialVector&relSpAccel()const;
km::SpatialVectorpframeObservedRelSpVel()const;
km::SpatialVectorpframeObservedRelSpAccel()const;
constkm::SpatialVectortoPframeDerivSpVel(constkm::SpatialVector&oframe_V)const;
constkm::SpatialVectortoPframeDerivSpAccel(constkm::SpatialVector&oframe_A)const;
constkm::Vec3toOframeObserved(constkm::Vec3&pframe_X,
constkm::Vec3&pframe_Xdot)const;
constkc::ks_ptr<kc::DataCache<km::HomTran>>&transformCache()const{
return_transform_cache;
}
constkc::ks_ptr<kc::DataCache<km::SpatialVector>>&velocityCache()const{
return_velocity_cache;
}
constkc::ks_ptr<kc::DataCache<km::SpatialVector>>&accelCache()const{
return_accel_cache;
}
/*ThesemethodsareforExercise1.14(Spatialacceleration
transformations)whichfocusesoncombiningoframe/pframeaccel
alpha(o,p)withpframe/targetaccelalpha(p,t)toget
oframe/targetaccelalpha(o,t).Wehavevariantsforwhat
framesareeachdifferentiatedinsincetheCoriolisaccel
termswillallbedifferent.Ineachofthesecases,weare
workingwithV(o,p)andV(p,t),andtheacceldefinition
dependsonwhichframe'srepresentationofVarewe
differentiatingtogetalpha,i.e.whatistheobservation
framewhenobtainingtheacceleration.SoasinEq1.65in
Section1.5,weusethenotation
alpha_H(A,B)=d_HV(F,G)
-----------
dt
tospecifytheaccelerationoftheGframewrttheFframeas
observedintheHframe.ItisimportanttonotethattheH
frameinaboveacclerationis*NOT*involvedinV(F,G),and
thatthisisthespatialvelocityofGwrtFasobservedfrom
theFframe.
Ingeneral,differentchoicesoftheA,B,Cobservationframe
canbeusedinthefollowinggeneralexpressionrelatingthe
o/p/trelativeaccelerations
alpha_A(o,t)=\phi^*(p,t)alpha_B(o,p)+alpha_C(p,t)+a_ABC
The"a_ABC"denotestheCoriolisaccelerationtermforthe
specificchoiceoftheA/B/Cobservationframes.
Inourmultibodydynamicsimplementation,weworkwithbody
accelerationsthataretheaccelerationofthebodywrttothe
inertialbutobservedinthebodyframeandrepresentedinthe
bodyframe.Thus,whenpropagatingthebodyaccelerationsfrom
bodytobodyinascatterrecursion,wearecombiningthe
inertialaccelerationoftheparentbody(observedinthe
parentbodyframe),withthehingeinducedacceleration
(observedintheparentbodyframe)togetthethechildbody's
inertialaccelerationasobservedfromthechildbody's
frame.Inthiscase
A=childbody,B=parentbody,C=parentbody
andtheappropriateCoriolisacceltermwouldbefromthe
coriolisAccel_tpp().
Ontheotherhand,whencombiningtheoframe/pframe
oframeDerivSpAccelwiththepframe/targetrelSpAccel,wehave
A=oframe,B=oframe,C=pframe
andtheappropriateCoriolisacceltermwouldbefrom
coriolisAccel_oop().
*/
km::SpatialVectorcoriolisAccel_oop(constFrame&target,constFrame2Frame&p2t_f2f)const;
km::Mat66phiDotMatrix()const;
km::SpatialVectorcoriolisAccel_tpp(constFrame&target,
constFrame2Frame&p2t_f2f,
constFrame2Frame&o2t_f2f)const;
km::HomTransolveTransform(constFrame2Frame&sub_f2f,constkm::HomTran&desired_T)const;
km::SpatialVectorsolveSpVel(constFrame2Frame&sub_f2f,
constFrame2Frame&other_f2f,
constkm::SpatialVector&desired_V)const;
km::SpatialVectorsolveSpAccel(constFrame2Frame&sub_f2f,
constFrame2Frame&other_f2f,
constkm::SpatialVector&desired_A)const;
public:
structdumpOptions:LockingBase::dumpOptions{
dumpOptions()=default;
unsignedintdepth=
1;
booldata=true;
dumpOptions&operator=(constdumpOptions&p){
if(this!=&p){
LockingBase::dumpOptions::operator=(p);//Callbaseclassassignmentoperator
//AssignDerived-specificmembershere
depth=p.depth;
data=p.data;
}
return*this;
}
};
std::stringdumpString(conststd::string&prefix="",
constBase::dumpOptions*options=nullptr)constoverride;
voidfreezeDataCaches();
voidunfreezeDataCaches();
voidmakeZombie()override;
protected:
Frame2Frame(constkc::ks_ptr<Frame>&oframe,
constkc::ks_ptr<Frame>&pframe,
conststd::string&name=""
);
staticstd::string
_mkName(constFrame&oframe,constFrame&pframe,conststd::string&suffix);
virtualvoid_computeTransform(km::HomTran&)=0;
virtualvoid_computeVelocity(km::SpatialVector&)=0;
virtualvoid_computeAccel(km::SpatialVector&)=0;
km::SpatialVector_propagateVelocity_oop(constFrame&target,
constFrame2Frame&p2t_f2f,
constFrame2Frame&o2t_f2f)const;
km::SpatialVector_propagateAccel_oop(constFrame&target,
constFrame2Frame&p2t_f2f,
constFrame2Frame&o2t_f2f)const;
protected:
//kc::ks_ptr<kc::DataCache<int>>_junk_cache;
kc::ks_ptr<kc::DataCache<km::HomTran>>_transform_cache;
kc::ks_ptr<kc::DataCache<km::SpatialVector>>_velocity_cache;
kc::ks_ptr<kc::DataCache<km::SpatialVector>>_accel_cache;
protected:
kc::ks_ptr<Frame>_oframe;
kc::ks_ptr<Frame>_pframe;
};
}//namespaceKarana::Frame