Class ConstraintKinematicsSolver#
Defined in File ConstraintKinematicsSolver.h
Inheritance Relationships#
Base Type#
public Karana::Core::LockingBase(Class LockingBase)
Class Documentation#
-
class ConstraintKinematicsSolver : public Karana::Core::LockingBase#
Class for solving for coordinates that satisfy closure constraints.
This class is the base class for bodies from which physical and compound body classes are derived. See Constraint kinematics section for more information.
Public Functions
-
ConstraintKinematicsSolver(std::string_view name, kc::ks_ptr<SubGraph> sg)#
Constructor.
- Parameters:
name – instance name
sg – the subgraph to use for coordinates and constraints
-
~ConstraintKinematicsSolver()#
Destructor.
-
double solveQ()#
Solve for the Q generalized cordinates to satisfy constraints.
See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.
- Returns:
The final error.
-
double solveU()#
Solve for the U velocity cordinates to satisfy velocity level constraints.
See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.
- Returns:
The final error.
-
double solveUdot()#
Solve for the Udot accel cordinates to satisfy accel level constraints.
Solve for the Udot gen accel coordinates to zero out constraints acceleration error. Unlike, solveQ() and solveU(), this method does change the frozen gen accel values.
See Generalized Q, U etc coordinates section for discussion on Q, U etc coordinates.
- Returns:
The final error.
-
void freezeCoord(kc::ks_ptr<CoordBase> coord, size_t index)#
Method to freeze a coordinate component.
The frozen coordinate element values are not changed by the solveQ(), solveU() and solveUdot() methods used for solving the constraint kinematics.
- Parameters:
coord – The coordinate whose element is being frozen
index – The index for the coordinate element being frozen
-
void unfreezeCoord(kc::ks_ptr<CoordBase> coord, size_t index)#
Method to unfreeze a coordinate component.
- Parameters:
coord – The coordinate whose element is being unfrozen
index – The index for the coordinate element being unfrozen
-
void clearFrozenCoords()#
Method to empty out list of frozen coordinates.
-
std::vector<unsigned int> frozenCoords() const#
Return the list of frozen coordinate indices.
- Returns:
the list of frozen coordinate indices.
-
size_t nonfrozenNU() const#
The number of U velocity coords for the CoordBase.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Returns:
the number of velocity coordinates
-
km::Vec getNonfrozenQ() const#
Return the Q coordinates as an array.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Returns:
Array of values
-
void setNonfrozenQ(const Eigen::Ref<const km::Vec> &Q)#
Set the Q coordinates.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Parameters:
Q – Array of values.
-
km::Vec getNonfrozenU() const#
Return the U velocity coordinates as an array.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Returns:
Array of values
-
void setNonfrozenU(const Eigen::Ref<const km::Vec> &U)#
Set the U velocity coordinates.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Parameters:
U – Array of values.
-
km::Vec getNonfrozenUdot() const#
Return the Udot acceleration coordinates as an array.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Returns:
Array of values
-
void setNonfrozenUdot(const Eigen::Ref<const km::Vec> &u_dot)#
Set the Udot acceleration coordinates.
See Generalized Q, U etc coordinates section for more on Q, U etc generalized coordinates.
- Parameters:
u_dot – Array of values.
-
void dump(std::string_view prefix = "") const#
Print out information about the CK solver.
- Parameters:
prefix – the prefix to use for each line of output
-
bool checkVelJacobian(double tolerance = 1e-6) const#
Verify that the velocity Jacobian values from the analytical and numerical differencing approaches agree.
- Parameters:
tolerance – the comparison tolerance to use
- Returns:
return true if the Jacobians agree
Public Static Functions
-
static kc::ks_ptr<ConstraintKinematicsSolver> create(std::string_view name, kc::ks_ptr<SubGraph> sg)#
Factory method to create a ConstraintKinematicsSolver instance.
Creates constraint kinematics solver for the specified subgraph’s coordinates and constraints. Frozen_coordinates can be set in the subgraph’s CoordData to specify ones that should be frozen and not changed by the kinematics solver.
- Parameters:
name – instance name
sg – the subgraph to use for coordinates and constraints
- Returns:
new ConstraintKinematicsSolver instance.
Protected Functions
-
inline kc::ks_ptr<km::NonlinearSolver> _nlSolver()#
Return the nonlinear solver instance configured to solver the constraint kinematics problem
-
void _discard(kc::ks_ptr<Base> &base) override#
Discard the provided ConstraintKinematicsSolver.
- Parameters:
base – - Base pointer to the ConstraintKinematicsSolver to discard.
-
virtual void _makeCurrent() override#
Derived classes override this to define how to make themselves current.
-
void _setup()#
Method to tear down and recreate cached data inclduing the Jacobian generator and the nonliner solver. This method is called by _makeCurrent() when the constraints or coord base elements change.
-
void _makeNlSolver()#
-
void _updateDependentCoordsQ()#
Update the list of depenendt Q coordinates to use by the non-linear solver.
Update the list of indices of Q coords that should be used by the non-linear solver to satisfy the coord constraints. This method picks the complement of the best independent Q coord indices. It also skips the frozen coords since they are not supposed to change. This method can be called to update this list of dependent coordinates since the choice is configuration state dependent.
-
km::Mat _velJacobianNumDiff() const#
selet the sub-set of CoordBase coordinate values that are allowed to change for IK solutions. assemble the overall velocity Jacobian matrix for all the constraints using numerical approach. All subhinge columns are included.
-
void _recomputeNonFrozenCoord()#
recompute _nonfrozen_indices from _frozen_indices
Protected Attributes
-
kc::ks_ptr<MultiJacobianGenerator> _hinge_loops_multi_jacgen = nullptr#
MutliJacobianGenerator for hinge-based loop constraints
-
kc::ks_ptr<MultiJacobianGenerator> _non_hinge_loops_multi_jacgen = nullptr#
MutliJacobianGenerator for nonhinge-based loop constraints
-
kc::ks_ptr<km::NonlinearSolver> _nl_solver = nullptr#
-
std::vector<unsigned int> _dependent_Q_coord_indices#
list of indices of dependent coordinate that are allowed to change when solving for Q values when enforing the configuraton level constraints.
-
std::vector<unsigned int> _frozen_indices#
list of indices of coordinates that are frozen by the application by calls to freezeCoords(). These are used to compute _nonfrozen_indices that us used by solveU() and solveUdot() methods.
-
std::vector<unsigned int> _nonfrozen_indices#
list of indices of coordinates that are not frozen by the application. These are used by solveU() and solveUdot() methods.
-
ConstraintKinematicsSolver(std::string_view name, kc::ks_ptr<SubGraph> sg)#