Program Listing for File FrameToFrame.h#
↰ Return to documentation for file (include/Karana/Frame/FrameToFrame.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"
namespaceKarana::Frame{
namespacekc=Karana::Core;
namespacekm=Karana::Math;
classFrameToFrame:publickc::LockingBase{
//Foraccessto_empty
friendclassFrame;
public:
virtual~FrameToFrame();
constkc::ks_ptr<Frame>&oframe()const;
constkc::ks_ptr<Frame>&pframe()const;
std::optional<bool>subchainOrientation(constFrameToFrame&sub_f_to_f)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_x_dot)const;
km::Mat66phiDotMatrix()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;
}
/*TheCoriolisaccelmethodsbelowareforExercise1.14
(Spatialaccelerationtransformations)whichfocuseson
combiningoframe/pframeaccelalpha(o,p)withpframe/target
accelalpha(p,t)togetoframe/targetaccelalpha(o,t).We
havevariantsforwhatframesareeachobservedin
sincetheCoriolisacceltermswillallbedifferent.Ineach
ofthesecases,weareworkingwithV(o,p)andV(p,t),and
theacceldefinitiondependsonwhichframe'srepresentation
ofVarewedifferentiatingtogetalpha,i.e.whatisthe
observationframewhenobtainingtheacceleration.Soasin
Eq1.65inSection1.5,weusethenotation
alpha_H(A,B)=d_HV(F,G)
-----------
dt
tospecifytheaccelerationoftheGframewithrespecttotheFframeas
observedintheHframe.ItisimportanttonotethattheH
frameinaboveacclerationis*NOT*involvedinV(F,G),and
thatthisisthespatialvelocityofGwithrespecttoFasobservedfrom
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
accelerationsthataretheaccelerationofthebodywithrespecttothe
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::SpatialVectorcoriolisAccelOop(constFrame&target,
constFrameToFrame&p_to_t_f_to_f)const;
km::SpatialVectorcoriolisAccelTpp(constFrame&target,
constFrameToFrame&p_to_t_f_to_f,
constFrameToFrame&o_to_t_f_to_f)const;
km::HomTransolveTransform(constFrameToFrame&sub_f_to_f,constkm::HomTran&T)const;
km::SpatialVectorsolveSpVel(constFrameToFrame&sub_f_to_f,
constFrameToFrame&other_f_to_f,
constkm::SpatialVector&V)const;
km::SpatialVectorsolveSpAccel(constFrameToFrame&sub_f_to_f,
constFrameToFrame&other_f_to_f,
constkm::SpatialVector&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(std::string_viewprefix="",
constBase::DumpOptions*options=nullptr)constoverride;
voidfreezeDataCaches();
voidunfreezeDataCaches();
protected:
FrameToFrame(constkc::ks_ptr<Frame>&oframe,
constkc::ks_ptr<Frame>&pframe,
std::string_viewname=""
);
virtualvoid_empty();
void_makeCurrent()override;
staticstd::string
_mkName(constFrame&oframe,constFrame&pframe,std::string_viewsuffix);
virtualvoid_computeTransform(km::HomTran&T)=0;
virtualvoid_computeVelocity(km::SpatialVector&V)=0;
virtualvoid_computeAccel(km::SpatialVector&a)=0;
km::SpatialVector_propagateVelocity_oop(constFrame&target,
constFrameToFrame&p_to_t_f_to_f,
constFrameToFrame&o_to_t_f_to_f)const;
km::SpatialVector_propagateAccel_oop(constFrame&target,
constFrameToFrame&p_to_t_f_to_f,
constFrameToFrame&o_to_t_f_to_f)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