Class CECompoundBody#
Defined in File CECompoundBody.h
Inheritance Relationships#
Base Type#
public Karana::Dynamics::CompoundBody(Class CompoundBody)
Class Documentation#
-
class CECompoundBody : public Karana::Dynamics::CompoundBody#
Represents a compound body with embedded constraints (for constraint embedding).
This class is for compound bodies with embedded constraints
Public Functions
-
const km::VecInt &getIndependentIndicesU() const#
Return the indices of the independent Q coordinates.
- Returns:
the independent Q coordinate indices
-
const km::VecInt &getIndependentIndicesQ() const#
Return the indices of the independent U coordinates.
- Returns:
the independent U coordinate indices
-
void setIndependentIndices(const km::VecInt &indep_indices_U, const km::VecInt &indep_indices_Q = {})#
Set the independent Q and U coordinate indices.
If the Q indices are unspecified, they are assumed to be the same as the U indices.
- Parameters:
indep_indices_U – the independent U coordinate indices
indep_indices_Q – the independent Q coordinate indices
-
virtual ~CECompoundBody()#
Destructor.
-
CECompoundBody(std::string_view name, kc::ks_ptr<SubGraph> parent_sg, kc::ks_ptr<SubGraph> bodies_sg, const km::VecInt &indep_indices_U, const km::VecInt &indep_indices_Q = {}, double rank_threshold = 1e-8)#
Constructs a CECompoundBody with list of independent bodies. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance one of the classes derived from this.
The CECompoundBody will own the SubGraph passed in. That means the CECompoundBody will attempt to discard the SubGraph when it is discarded.
- Parameters:
name – instance name
parent_sg – the parent SubGraph this the body will belong to
bodies_sg – SubGraph with bodies being embedded
indep_indices_U – the list of independent U coordinate indices
indep_indices_Q – the list of independent Q coordinate indices
rank_threshold – threshold to use when computing error Jacobian rank
-
CECompoundBody(std::string_view name, kc::ks_ptr<SubGraph> parent_sg, kc::ks_ptr<SubGraph> bodies_sg, const std::vector<kc::ks_ptr<PhysicalBody>> &indep_bodies, double rank_threshold = 1e-8)#
Constructs a CECompoundBody with list of independent coord indices. The constructor is not meant to be called directly. Please use the create(…) method instead to create an instance one of the classes derived from this.
The CECompoundBody will own the SubGraph passed in. That means the CECompoundBody will attempt to discard the SubGraph when it is discarded.
-
virtual std::string dumpString(std::string_view prefix = "", const Karana::Core::Base::DumpOptions *options = nullptr) const override#
Return information about the object.
- Parameters:
prefix – A string to use as prefix for each output line
options – Struct with options to tailor the output
- Returns:
String with the information about the object.
-
inline kc::ks_ptr<CELoopKinematicsBase> loopSolver() const#
Return the CELoopKinematicsSolver for the compound body.
- Returns:
the CE loop solver
-
virtual void flatten(kc::ks_ptr<CompoundBody> &child_cpbd) override#
Replace the embedded child compound body with the embedded physical bodies it contains with this compound body.
The child compound body is discarded by this method after the transfer has been completed.
- Parameters:
child_cpbd – the embedded compound body to be flattened
Public Static Functions
-
static kc::ks_ptr<CECompoundBody> create(std::string_view name, kc::ks_ptr<SubGraph> parent_subtree, kc::ks_ptr<SubGraph> component_bodies, const std::vector<kc::ks_ptr<PhysicalBody>> &indep_bodies, double rank_threshold = 1e-8)#
Constructs a CECompoundBody with list of independent bodies.
The CECompoundBody will own the SubGraph passed in. That means the CECompoundBody will attempt to discard the SubGraph when it is discarded.
- Parameters:
- Returns:
a CECompoundBody instance
-
static kc::ks_ptr<CECompoundBody> create(std::string_view name, kc::ks_ptr<SubGraph> parent_subtree, kc::ks_ptr<SubGraph> component_bodies, const km::VecInt &indep_indices_U, const km::VecInt &indep_indices_Q = {}, double rank_threshold = 1e-8)#
Constructs a CECompoundBody with list of independent coord indices.
The option of specifying independent coordinates at the indices level gives finer-grain control than the other create() method. Also, this method allows specifying different values for the independent Q and U coordinates. The U coordinates are used if the Q list is empty. If empty indices are specified, then the required number of independent coordinate indices will be auto picked.
The CECompoundBody will own the SubGraph passed in. That means the CECompoundBody will attempt to discard the SubGraph when it is discarded.
- Parameters:
name – instance name
parent_subtree – the parent SubGraph this the body will belong to
component_bodies – SubGraph with bodies being embedded
indep_indices_U – the list of independent U coordinate indices
indep_indices_Q – the list of independent Q coordinate indices
rank_threshold – threshold to use when computing error Jacobian rank
- Returns:
a CECompoundBody instance
Protected Functions
-
const km::VecInt _computeIndependentIndicesU(double rank_threshold) const#
Compute the independent coordinates for the compound body’s constraints.
- Parameters:
rank_threshold – threshold to use when computing error Jacobian rank
- Returns:
the list of independent coordinate indices
-
virtual Karana::Core::ks_ptr<Karana::Core::BaseVars> _getVars() const override#
Create the vars for this object.
- Returns:
The vars for this object.
-
virtual void _discard(Karana::Core::ks_ptr<Karana::Core::Base> &base) override#
Discard the the object. Derived classes should implement this with the logic required to discard themselves if applicable.
- Parameters:
base – - A pointer to the object to discard.
-
virtual kc::ks_ptr<CompoundSubhinge> _createSubhinge(kc::ks_ptr<CompoundHinge> hinge) override#
Create the compound subhinge.
- Parameters:
hinge – the parent compound hinge
- Returns:
the new compound subhinge
-
km::Mat _matX() const#
Return the X matrix that maps the min independent U to the dependent U (without constraint dofs) for the compound body.
- Returns:
the non-constraint X matrix
-
const km::Mat &_constraintX() const#
Return the X matrix that maps the min independent U to the full U (independent, dependent, constraint dofs) for the compound body
- Returns:
the full constraint X matrix
-
const km::Vec &_constraintXdotU() const#
Return the Xdot*U product vector where Xdot is the time derivative of the X constraint matrix
- Returns:
the Xdot*U product
-
virtual km::Vec _getFprimeTreeFwdDyn() const override#
Get the f’ values from tree forward dynamics for all of the embedded bodies stacked into a single vector.
- Returns:
the stacked vector with f’ values
-
virtual void _updateBodiesTreeVirtualRoot(const kc::ks_ptr<BodyBase> &new_root) override#
Update the provided bodies_tree to use the provided new_root as its new virtual root.
This does so recursively, so if the bodies_tree provided has embedded CompoundBodys that use the same virtual root, then they will also be updated.
- Parameters:
new_root – The new body for _bodies_tree to use as its virtual root.
-
void _createCeLoopSolver(const km::VecInt &lindep_indices_U, const km::VecInt &lindep_indices_Q, double rank_threshold)#
Create the CE loop kinematics solver and assign it to _ce_loop_solver.
- Parameters:
lindep_indices_U – The independent velocity indices.
lindep_indices_Q – The independent coordinate indices.
rank_threshold – The threshold to use when computing the rank of the constraint matrix
Protected Attributes
-
kc::ks_ptr<kc::DataCache<km::Mat>> _cache_constraintX = nullptr#
the data cache for the constraint X matrix
-
kc::ks_ptr<kc::DataCache<km::Vec>> _cache_XdotU = nullptr#
the data cache for the constraint Xdot*U product
-
kc::ks_ptr<CELoopKinematicsBase> _ce_loop_solver = nullptr#
The CE loop constraints solver for the compound body
-
double _rank_threshold#
rank_threshold threshold to use when computing error Jacobian rank
-
const km::VecInt &getIndependentIndicesU() const#