Program Listing for File Multibody.h#
↰ Return to documentation for file (include/Karana/SOADyn/Multibody.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/UsageTrackingMap.h"
#include"Karana/ProxyScene/ProxyScene.h"
#include"Karana/SOADyn/HingeNode.h"
#include"Karana/SOADyn/SubGraph.h"
#include"Karana/Scene/Color.h"
#include"Karana/Scene/Layer.h"
namespaceKarana::Frame{
classFrameContainer;
}
namespaceKarana::Dynamics{
namespacekc=Karana::Core;
namespacekf=Karana::Frame;
namespaceks=Karana::Scene;
classPhysicalBody;
classLoopConstraintHinge;
classLoopConstraintConVel;
classCoordinateConstraint;
classMultibody:publicSubGraph{
//foraccesstotrackUsagePhysicalBody()
friendclassPhysicalBody;
friendclassPhysicalModalBody;
friendclassPhysicalApparentMassBody;
//foraccesstobody2parent_map
friendclassPhysicalHinge;
//foraccessto_tree
friendclassPhysicalSubhinge;
//foraccessto_algorithmic_subtree
friendclassSubTree;
//foraccessto_existing_loop_constraints_list
friendclassLoopConstraintConVel;
friendclassLoopConstraintHinge;
//foraccesstousagetracker
friendclassCoordinateConstraint;
//foraccessto_detached_nodes_list
friendclassNode;
//foraccessto_detached_constraint_nodes_list
friendclassConstraintNode;
public:
Multibody(std::string_viewname,kc::ks_ptr<kf::FrameContainer>fc);
virtual~Multibody(){};
statickc::ks_ptr<Multibody>create(std::string_viewname,//
kc::ks_ptr<kf::FrameContainer>fc,
kc::ks_ptr<kf::Frame>mbroot_frame=nullptr,
kc::ks_ptr<kf::Frame>newtonian_frame=nullptr);
statickc::ks_ptr<Multibody>
fromUrdf(conststd::filesystem::path&filename,
constkc::ks_ptr<kf::FrameContainer>&fc,
constkc::ks_ptr<kf::Frame>&newtonian_frame=nullptr,
constkc::ks_ptr<ks::ProxyScene>&scene=nullptr);
voidtoUrdf(conststd::filesystem::path&filename);
std::string_viewtypeString()constnoexceptoverride{
staticstd::stringtype_string="Karana::Dynamics::Multibody";
returntype_string;
}
voidtoFullyAugmentedModel();
std::string
dumpString(std::string_viewprefix="",
constKarana::Core::Base::DumpOptions*options=nullptr)constoverride;
kc::ks_ptr<Node>getNodeAncestor(constkc::ks_ptr<kf::Frame>&frame)const;
constkc::ks_ptr<kf::Frame>&getNewtonianFrame()const;
constkc::ks_ptr<kf::FrameContainer>&frameContainer()const;
std::vector<kc::ks_ptr<BilateralConstraintBase>>constraints()const;
kc::ks_ptr<BilateralConstraintBase>getConstraint(std::string_viewname)const;
structStickPartsConfig{
StickPartsConfig(){};
ks::Colorbody_color=ks::Color::DARKMAGENTA;
ks::Colorjoint_color=ks::Color::ORANGERED;
ks::Colorconstraint_color=ks::Color::RED;
ks::Colorsensor_node_color=ks::Color::GREEN;
ks::Colorforce_node_color=ks::Color::BLUE;
floatbody_stick_radius=0.02f;
floatpin_hinge_length=0.1f;
floatpin_hinge_radius=0.05f;
floatsphere_hinge_radius=0.07f;
floathinge_axes_length=0.2f;
floatnode_radius=0.04f;
ks::layer_tlayers=ks::LAYER_STICK_FIGURE;
};
voidcreateStickParts(constStickPartsConfig&c=StickPartsConfig());
voidsetScene(constkc::ks_ptr<ks::ProxyScene>&scene);
kc::ks_ptr<ks::ProxyScene>&getScene();
std::vector<kc::ks_ptr<PhysicalBody>>addPhysicalBodiesChain(
conststd::function<kc::ks_ptr<PhysicalBody>(std::string_viewnm)>&create_body,
std::string_viewname,
size_tnbodies,
PhysicalBody&root,
HingeBase::HingeTypehtype,
constPhysicalBodyParams¶ms);
std::vector<kc::ks_ptr<PhysicalBody>>addPhysicalBodiesTree(
conststd::function<kc::ks_ptr<PhysicalBody>(std::string_viewnm)>&create_body,
std::string_viewname,
size_tbranch_length,
size_tnbranches,
size_tdepth,
PhysicalBody&root,
HingeBase::HingeTypehtype,
constPhysicalBodyParams¶ms);
protected:
void_trackUsageCoordinateConstraint(kc::ks_ptr<CoordinateConstraint>c);
void_trackUsagePhysicalBody(kc::ks_ptr<PhysicalBody>bd);
void_makeCurrent()override;
void_makeStale()override;
void_discardCmFrame()overridefinal;
void_discard(kc::ks_ptr<Base>&base)override;
private:
void_createStickPartsBody(constkc::ks_ptr<PhysicalBody>&bd,
constMultibody::StickPartsConfig&c);
void_createStickPartsHinge(constFramePairHinge&hge,
constMultibody::StickPartsConfig&c,
boolconstraint);
void_trackUsageLoopConstraintBase(kc::ks_ptr<LoopConstraintBase>lc);
conststd::vector<kc::ks_ptr<LoopConstraintBase>>&_loopConstraints()const;
std::vector<kc::ks_ptr<CoordinateConstraint>>_coordinateConstraints()const;
kc::ks_ptr<CoordinateConstraint>_getCoordinateConstraint(std::string_viewname)const;
kc::ks_ptr<LoopConstraintBase>_getLoopConstraint(std::string_viewname)const;
protected:
//-------------------------------
//-------------------------------
kc::ks_ptr<kf::FrameContainer>_fc=nullptr;
kc::ks_ptr<kf::Frame>_newtonian_frame=nullptr;
kc::RegistryList<PhysicalBody>_physical_unsorted_bodies_list;
kc::RegistryList<SubTree>_algorithmic_subtrees;
kc::RegistryList<Node>_detached_nodes_list;
kc::RegistryList<ConstraintNode>
_detached_constraint_nodes_list;
kc::RegistryList<LoopConstraintBase>_existing_loop_constraints_list;
kc::ks_ptr<ks::ProxyScene>_scene=nullptr;
kc::UsageTrackingMap<kc::id_t,CoordinateConstraint>_coordinate_constraint_usage_map;
kc::UsageTrackingMap<kc::id_t,LoopConstraintBase>_loop_constraint_base_usage_map;
};
}//namespaceKarana::Dynamics