Karana.Dynamics.Algorithms
==========================

.. py:module:: Karana.Dynamics.Algorithms

.. autoapi-nested-parse::

   Various dynamics algorithms.



Classes
-------

.. autoapisummary::

   Karana.Dynamics.Algorithms.ModalAnalysis


Functions
---------

.. autoapisummary::

   Karana.Dynamics.Algorithms.constraintKinematicsSolver
   Karana.Dynamics.Algorithms.evalCentroidalMomentum
   Karana.Dynamics.Algorithms.evalCentroidalMomentumMatrix
   Karana.Dynamics.Algorithms.evalCmLocation
   Karana.Dynamics.Algorithms.evalComputedTorque
   Karana.Dynamics.Algorithms.evalConstraintPoseGradientMatrix
   Karana.Dynamics.Algorithms.evalDependentVelCoordinatesMatrix
   Karana.Dynamics.Algorithms.evalExternalSpatialForce
   Karana.Dynamics.Algorithms.evalForwardDynamics
   Karana.Dynamics.Algorithms.evalFramesOSCM
   Karana.Dynamics.Algorithms.evalGravitationalPotentialEnergy
   Karana.Dynamics.Algorithms.evalGravityCompensation
   Karana.Dynamics.Algorithms.evalIndepPoseConstraintIndices
   Karana.Dynamics.Algorithms.evalIndepPoseCoordIndices
   Karana.Dynamics.Algorithms.evalIndepVelConstraintCoordIndices
   Karana.Dynamics.Algorithms.evalInverseDynamics
   Karana.Dynamics.Algorithms.evalKineticEnergy
   Karana.Dynamics.Algorithms.evalSerialChainMassMatrixInverse
   Karana.Dynamics.Algorithms.evalSpatialInertia
   Karana.Dynamics.Algorithms.evalSpatialMomentum
   Karana.Dynamics.Algorithms.evalSqueezeMatrix
   Karana.Dynamics.Algorithms.evalTreeMassMatrixCRB
   Karana.Dynamics.Algorithms.evalTreeMassMatrixInvDyn
   Karana.Dynamics.Algorithms.evalTreeMassMatrixInvFwdDyn
   Karana.Dynamics.Algorithms.evalTreeMassMatrixInverse
   Karana.Dynamics.Algorithms.evalVelCoordinatePartitioning
   Karana.Dynamics.Algorithms.evalVelocityConstraintMatrix
   Karana.Dynamics.Algorithms.jacobianGenerator
   Karana.Dynamics.Algorithms.stateSpaceGenerator
   Karana.Dynamics.Algorithms.modalAnalysis


Package Contents
----------------

.. py:function:: constraintKinematicsSolver(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph) -> Karana.Dynamics._SOADyn_pybind11_Py.ConstraintKinematicsSolver

   Return a constraint/inverse kinematics solver instance

   Creates a constraint kinematics (CK) solver for the specified SubGraph
   and its coordinates and loop constraints. The CK solver uses the
   CoordData for the SubGraph for the coordinates to solver for.
   Coordinates can be frozen during the solution process. Only the
   subhinge coordinates are solved for, and deformation coordinates - if
   any - are not used.


   See the :ref:`kinematics_algorithms_sec` section for more information.

   :param sg: SubGraph instance

   :returns: The constraint kinematics solver instance


.. py:function:: evalCentroidalMomentum(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Karana.Math.SpatialVector

   Calculate the centroidal spatial momentum for the SubTree

   This is the same as the sub-tree's spatial momentum (computed by
   evalSpatialMomentum()), except that this value is referenced about the
   sub-tree's center of mass location, though still represented in the
   virtual root frame. Note that this quantity is conserved in the
   absence of external forces on the system.

   This method does not support deformable bodies.


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: Spatial momentum.


.. py:function:: evalCentroidalMomentumMatrix(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate the centroidal momentum matrix for the SubTree

   This returns the centroidal momentum matrix (CMM) that defines the
   mapping between the system generalized velocities and the system's
   centroidal momentum. Note that this matrix is configuration dependent.
   This matrix is used in the context the control of legged robots and
   managing the motion of their CM for stable walking.


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: The 6xnU centroidal momentum matrix (CMM).


.. py:function:: evalCmLocation(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]

   Return the location of the sub-tree CM from the virtual root.

   Return the current location of the center-of-mass frame for the
    whole sub-tree with respect to the virtual root.


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: The position of the CM with respect to the virtual root.


.. py:function:: evalComputedTorque(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]

   Calculate the computed torque using NE algorithm

   Method to compute the "computed torque", i.e. the generalized forces
   needed - usually for a specific generalized acceleration inputs. This
   assumes that the state (generalized coordinates (Q) and velocities (U)
   have been set to the desired values in the multibody system, as have
   the generalized accelerations (Udot). If the generalized forces are T
   in the system, the returned value from this method subtracts out the
   input T from the values computed by inverse dynamics.

   This method should not to be used for systems with deformable bodies.
   Systems with deformable bodies are under-actuated, while computed
   torque only applies to fully actuated systems. Prescribed subhinges
   and constraints are ignored in this computation.


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: The computed T generalized forces


.. py:function:: evalConstraintPoseGradientMatrix(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Compute the gradient matrix for the constraint pose errors.

   Compute the gradient matrix for the constraint pose errors for the
   bilateral constraints on the SubGraph.

   Note that the returned matrix may not have full row rank when the
   constraints are not all independent.

   The SubGraph::constraintErrorAt() and the
   SubGraph::constraintResidualAt() methods and can be used to look up
   the constraint instance associated with any specific row index in the
   returned matrix (based on whether with_constraint is 'true' or 'false'
   respectively). Similarly, the SubGraph::coordAt() method can be used
   to look up the coordinate instance for a specific column index in the
   returned matrix.

   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance

   :returns: The gradient matrix for the constraint pose errors.


.. py:function:: evalDependentVelCoordinatesMatrix(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph, indep_indices: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 1]] = ..., full: bool = False) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Compute the dependent velocity coordinates matrix map for the
   specified set of independent coordinates

   For a SubGraph with constraints, only a subset of the velocity
   coordinates are independent. This method computes the matrix X that
   can be used to compute the dependent velocity coordinates, U_d, for
   the specified set of independent velocity coordinates, U_i, via U_d =
   X * U_i,

   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance
   :param indep_indices: the list of independent U indices
   :param full: if true, the matrix also includes columns for the
                independent coordinates, else only for the dependent
                coordinates

   :returns: the dependent coordinates mapping matrix


.. py:function:: evalExternalSpatialForce(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Karana.Math.SpatialVector

   Calculate the overall external spatial force for for the SubTree about
   its CM

   The computed value includes external force contributions from all of
   the force nodes on all the bodies (including active contact nodes) as
   well as any constraint forces from constraint nodes. The returned
   value is referenced about, and represented in the sub-tree's center of
   mass frame.

   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: The overall external spatial force.


.. py:function:: evalForwardDynamics(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> None

   Compute the forward dynamics for a system.

   This uses tree-augmented forward dynamics if there are with loop
   constraints, and tree forward dynamics if there are no loop
   constraints.

   The tree-augmented algorithm solves the graph system forward dynamics
   using recursive {{ SOA }} recursive algorithms with exact enforcement
   of the loop constraints. This algorithm does not require the
   computation of inversion of the mass matrix.

   The tree forward dynamics uses Articulated Body Inertia (ATBI) based
   forward dynamics.

   See the :ref:`simulation_algorithms_sec` section for more information.

   :param st: SubTree instance


.. py:function:: evalFramesOSCM(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, body_frames: collections.abc.Sequence[Karana.Frame.Frame], subhinges: collections.abc.Sequence[Karana.Dynamics._SOADyn_pybind11_Py.PhysicalSubhinge] = []) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate the tree system operational space compliance matrix (OSCM)

   The OSCM is defined at J*M^{-1}*J^*, where J is the Jacobian matrix,
   and M is the mass matrix of the system. This method does not use this
   brute force expression. Instead it uses the {{ SOA }} recursive
   methods to do this computation without ever computing the mass matrix
   or its inverse, or even the Jacobian matrix itself.

   In addition, one or more subhinges can also be provided. The returned
   matrix will include additional mass matrix inverse rows and columns
   for these subhinges. This is equivalent to computing the OSCM for the
   "extended Jacobian" defined as [J \\ E], where E is a selector matrix
   that picks out a subset of the subhinges in the system. While the rows
   and columns associated with the frames define a mapping between
   spatial forces and spatial accelerations, the subhinge rows and
   columns define the mapping between generalized forces and generalized
   accelerations. The off-diagonal sub-blocks define cross-term mappings.

   If no subhinges are specified, the returned matrix is the regular
   OSCM, and if no frames are specified, the returned matrix is the sub-
   block of the mass matrix inverse with rows and columns for the
   specified subhinges. This more general form of the OSCM allows users
   to properly handle a mix of constraints from the task and joint
   spaces.


   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance
   :param body_frames: list of Frame instances to compute the OSCM for
   :param subhinges: list of physical subhinge mass matrix inverse
                     contributions to include

   :returns: The tree OSCM matrix


.. py:function:: evalGravitationalPotentialEnergy(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> float

   Calculate the overall gravitational potential energy of the component
   bodies in the SubTree

   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance

   :returns: Gravitational potential energy.


.. py:function:: evalGravityCompensation(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]

   Compute the gravity compensation torque for the system

   Compute the generalized forces needed to support the gravitational
   load on the system. This method automatically takes into account
   additional bodies that are attached or detached from the system.


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: The vector of generalized forces.


.. py:function:: evalIndepPoseConstraintIndices(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph) -> Annotated[numpy.typing.NDArray[numpy.int32], [m, 1]]

   Compute the indices for best independent bilateral constraints on the
   system based on the pose gradients matrix map.

   For a SubGraph with constraints, only a subset of the Q pose-level
   constraints may be independent. This method computes the indices of
   the independent constraints.

   Since the pose and velocity level constraints may not be the same, the
   results from this method may not match the constraint and coordinate
   indices returned by the evalIndepVelConstraintCoordIndices() method.

   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance

   :returns: a pair consisting of a list of independent constraint indices, and
             a list of independent coordinate indices based on the pose-level
             constraints


.. py:function:: evalIndepPoseCoordIndices(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph, available_indices: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 1]] = ...) -> Annotated[numpy.typing.NDArray[numpy.int32], [m, 1]]

   Compute the best indices for independent Q coordinates for the
   bilateral constraints on the system

   For a SubGraph with constraints, only a subset of the Q pose-level
   coordinates are independent. This method computes the indices of the
   coordinates in the Q vector that are best choice for independent
   coordinates (at the current configuration).  A non-empty
   available_indices list can be used to restrict the pool of indices to
   pick the independent coordinates from.

   Since the pose and velocity level constraints may not be the same, the
   results from this method may not match the constraint and coordinate
   indices returned by the evalIndepVelConstraintCoordIndices() method.

   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance
   :param available_indices: If non-empty, the indices to pick the
                             independent coordinates from

   :returns: a list of independent coordinate indices based on the pose-level
             constraints


.. py:function:: evalIndepVelConstraintCoordIndices(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph, available_indices: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 1]] = ...) -> tuple[Annotated[numpy.typing.NDArray[numpy.int32], [m, 1]], Annotated[numpy.typing.NDArray[numpy.int32], [m, 1]]]

   Compute the best indices for independent constraints and velocity
   coordinates using the velocity constraint matrix

   For a SubGraph with constraints, only a subset of the U velocity
   coordinates are independent (and not all constraints may be
   independent). This method computes the indices of the independent
   constraints, and the indices of the coordinates in the U vector that
   are best choice for independent velocity coordinates (at the current
   configuration).

   Since the pose and velocity level constraints may not be the same, the
   results from this method may not match the constraint and coordinate
   indices returned by the evalIndepPoseCoordIndices() and
   evalIndepPoseConstraintIndices() methods.

   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance
   :param available_indices: the list of indices to pick the independent
                             ones from

   :returns: a pair consisting of a list of independent constraint indices, and
             a list of independent coordinate indices  based on the velocity-
             level constraints


.. py:function:: evalInverseDynamics(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> None

   Evaluate Newton-Euler inverse dynamics


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance


.. py:function:: evalKineticEnergy(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> float

   Calculate the overall kinetic energy of the component bodies in the
   SubTree

   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance

   :returns: Kinetic energy.


.. py:function:: evalSerialChainMassMatrixInverse(subtree: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, coord_data: Karana.Dynamics._SOADyn_pybind11_Py.CoordData = None) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate serial-chain system mass matrix inverse using {{ SOA }}
   operator-based decomposition expressions

   This method does not require the mass matrix or matrix inversions to
   compute the mass matrix inverse! The algorithm instead takes advantage
   of an analytical operator based decomposition of the mass matrix
   inverse to carry out the computation much lower cost.

   A CoordData argument can be specified to set the specific order for
   the rows and columns in the computed mass matrix inverse. This method
   cannot be used for systems containing deformable bodies. This mass
   matrix inverse computation can also be done via the more general
   evalTreeMassMatrixInverse() which also works for deformable bodies. We
   however also have this method since it is considerably simpler for the
   simpler serial-chain topology.

   This method does not allow internal 6 dof hinges to avoid ambiguities
   about whether mass properties should be coupled across such hinges.
   Also the prescribed motion flag for any subhinge that has been enabled
   is reset. This is to ensure that the mass matrix computed from this
   method are consistent with the results from the alternative dynamics
   based computation methods.


   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance
   :param coord_data: CoordData to specify the order of the mass matrix
                      inverse's rows and columns

   :returns: The serial-chain mass matrix inverse


.. py:function:: evalSpatialInertia(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, ref_frame: Karana.Frame.Frame = None) -> Karana.Math.SpatialInertia

   Calculate the overall  spatial inertia for a sub-tree

   Return the overall spatial inertia of all the bodies in the sub-tree
   about the reference frame. The multibody virtual root serves as the
   default reference frame.


   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance
   :param ref_frame: reference frame for the spatial inertia (default: the
                     virtual root)

   :returns: The overall tree spatial inertia


.. py:function:: evalSpatialMomentum(st: Karana.Dynamics._SOADyn_pybind11_Py.SubTree) -> Karana.Math.SpatialVector

   Calculate the overall spatial momentum for the SubTree

   The returned value is by default is referenced about, and represented
   in the virtual root frame. Note that this quantity is conserved in the
   absence of external forces on the system.


   See the :ref:`embedded_control_algorithms_sec` section for more
   information.

   :param st: SubTree instance

   :returns: Spatial momentum.


.. py:function:: evalSqueezeMatrix(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Return a matrix for computing squeeze generalized forces

   Compute the squeeze matrix, S, whose column space consists of
   "squeeze" generalized forces, i.e. generalized forces that only effect
   internal forces within the constrained multibody and do not induce any
   motion. Thus, the generalized force, S*x, for any vector x will not
   induce any motion. The row dimension is nU(), while the column
   dimension is the size of the constraints on the system.

   Note that the returned matrix may not have full column rank when the
   constraints are not all independent. The
   evalIndepVelConstraintCoordIndices() method can be used to check for
   the columns that are independent.


   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance

   :returns: The squeeze matrix.


.. py:function:: evalTreeMassMatrixCRB(subtree: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, coord_data: Karana.Dynamics._SOADyn_pybind11_Py.CoordData = None) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate the tree system mass matrix using CRB approach

   This method uses the composite rigid body inertias (CRB) recursive
   method for computing the mass matrix

   See the :ref:`mass_prop_algorithms_sec` section for more information.

   This method does not allow internal 6 dof hinges to avoid ambiguities
   about whether mass properties should be coupled across such hinges.
   Also the prescribed motion flag for any subhinge that has been enabled
   is reset. This is to ensure that the mass matrix computed from this
   method are consistent with the results from the alternative dynamics
   based computation methods.

   :param st: SubTree instance
   :param coord_data: CoordData to specify the order of the mass matrix rows
                      and columns

   :returns: The tree mass matrix


.. py:function:: evalTreeMassMatrixInvDyn(subtree: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, coord_data: Karana.Dynamics._SOADyn_pybind11_Py.CoordData = None) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate the tree system mass matrix using Newton-Euler inverse
   dynamics

   Calculate the tree system mass matrix using NE inverse dynamics. A
   CoordData argument can be specified to set the specific order for the
   rows and columns in the computed mass matrix.

   This method does not currently support deformable bodies.

   This method does not allow internal 6 dof hinges to avoid ambiguities
   about whether mass properties should be coupled across such hinges.
   Also the prescribed motion flag for any subhinge that has been enabled
   is reset. This is to ensure that the mass matrix computed from this
   method are consistent with the results from the alternative dynamics
   based computation methods.


   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance
   :param coord_data: CoordData to specify the order of the mass matrix rows
                      and columns

   :returns: The tree mass matrix


.. py:function:: evalTreeMassMatrixInvFwdDyn(subtree: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, coord_data: Karana.Dynamics._SOADyn_pybind11_Py.CoordData = None) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate the tree system mass matrix inverse using forward dynamics

   Calculate the tree system mass matrix inverse using ATBI forward
   dynamics. A CoordData argument can be specified to set the specific
   order for the rows and columns in the computed mass matrix inverse.
   This method currently supports physical rigid and flexible bodies, but
   not compound bodies.

   This method does not allow internal 6 dof hinges to avoid ambiguities
   about whether mass properties should be coupled across such hinges.
   Also the prescribed motion flag for any subhinge that has been enabled
   is reset. This is to ensure that the mass matrix computed from this
   method are consistent with the results from the alternative dynamics
   based computation methods.


   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance
   :param coord_data: CoordData to specify the order of the mass matrix
                      inverse's rows and columns

   :returns: The tree mass matrix inverse


.. py:function:: evalTreeMassMatrixInverse(subtree: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, coord_data: Karana.Dynamics._SOADyn_pybind11_Py.CoordData = None) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Calculate the tree system mass matrix inverse using {{ SOA }}
   decomposition expressions

   This method does not require the mass matrix or matrix inversions to
   compute the mass matrix inverse! The algorithm instead takes advantage
   of an analytical operator based decomposition of the mass matrix
   inverse to carry out the computation much lower cost. For serial-chain
   system, the mass matrix inverse can also be computed using the
   evalSerialChainMassMatrixInverse() specifically for such systems.

   A CoordData argument can be specified to set the specific order for
   the rows and columns in the computed mass matrix inverse. This method
   is currently limited to physical and rigid bodies.

   This method supports both rigid and deformable bodies.

   This method does not allow internal 6 dof hinges to avoid ambiguities
   about whether mass properties should be coupled across such hinges.
   Also the prescribed motion flag for any subhinge that has been enabled
   is reset. This is to ensure that the mass matrix computed from this
   method are consistent with the results from the alternative dynamics
   based computation methods.


   See the :ref:`mass_prop_algorithms_sec` section for more information.

   :param st: SubTree instance
   :param coord_data: CoordData to specify the order of the mass matrix
                      inverse's rows and columns

   :returns: The tree mass matrix inverse


.. py:function:: evalVelCoordinatePartitioning(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph, available_indices: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 1]] = ...) -> tuple[Annotated[numpy.typing.NDArray[numpy.int32], [m, 1]], Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]]

   Compute the best indices for independent and dependent velocity
   coordinates matrix map

   For a SubGraph with constraints, only a subset of the velocity
   coordinates are independent. This method computes the indices of the
   coordinates in the U vector that are best choice for independent
   velocity coordinates (at the current configuration). It also returns a
   matrix X that can be used to compute the dependent velocity
   coordinates, U_d, for a set of independent velocity coordinates, U_i,
   via U_d = X * U_i,


   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance
   :param available_indices: the list of indices to pick the independent
                             ones from

   :returns: The list of independent coordinate indices and the dependent
             coordinate mapping matrix


.. py:function:: evalVelocityConstraintMatrix(sg: Karana.Dynamics._SOADyn_pybind11_Py.SubGraph, with_constraints: bool) -> Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]

   Compute the velocity constraint matrix.

   Compute the velocity constraint matrix, Gc, such that Gc * U = 0, i.e.
   the matrix whose null space contains the generalized velocity U values
   that satisfy the loop and coordinate constraints on the SubGraph.

   If "with_constraints" is true, then Gc's columns include ones for the
   loop hinge constraint coordinates, and the block row for each
   constraint contain the mapping to their constraint errors.

   On the other hand, if "with_constraints" is false, Gc's columns
   exclude ones for the constraint coordinates, and the block row for
   each loop hinge constraint maps to the residual vector for each
   constraint. In the latter case, the number of columns and rows shrink
   equally by the number of constraint coordinates.

   Note that the returned matrix may not have full row rank when the
   constraints are not all independent. The
   evalIndepVelConstraintCoordIndices() method can be used to check for
   the rows that are independent.

   The SubGraph::constraintErrorAt() and the
   SubGraph::constraintResidualAt() methods and can be used to look up
   the constraint instance associated with any specific row index in the
   returned matrix (based on whether with_constraint is 'true' or 'false'
   respectively). Similarly, the SubGraph::coordAt() method can be used
   to look up the coordinate instance for a specific column index in the
   returned matrix.

   See the :ref:`constraints_kin_algorithms_sec` section for more
   information.

   :param sg: SubGraph instance
   :param with_constraints: If true, columns for the cutjoint loop
                            constraint coords are included

   :returns: The velocity constraint matrix.


.. py:function:: jacobianGenerator(f2fs: collections.abc.Sequence[Karana.Frame.FrameToFrame], cd: Karana.Dynamics._SOADyn_pybind11_Py.CoordData) -> Karana.Dynamics._SOADyn_pybind11_Py.MultiJacobianGenerator

   Return a Jacobian generator for the subtree

   Create a Jacobian generator object for the specified SubGraph and its
   coordinates and the list source/target frame pairs in the list of
   frame2frames. Note that the resulting jacobian and pose gradient
   matrices will exclude columns for any coordinates frozen in the coord
   data of the subtree.


   See the :ref:`kinematics_algorithms_sec` section for more information.

   :param f2fs: list of FrameToFrames to compute the Jacobian for
   :param cd: the CoordData that specify the columns in the computed
              Jacobian

   :returns: The Jacobian generator instance


.. py:function:: stateSpaceGenerator(mm: Karana.Dynamics._SOADyn_pybind11_Py.ModelManager, n_inputs: SupportsInt | SupportsIndex, n_outputs: SupportsInt | SupportsIndex, u_fn: collections.abc.Callable[[Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]], Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]]], None], y_fn: collections.abc.Callable[[Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]], Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]], Annotated[numpy.typing.NDArray[numpy.float64], [m, 1], flags.writeable]], None]) -> Karana.Math.StateSpace

   Create generator for linearized state space representation of the
   system

   Method to create a StateSpace object for creating (A,B,C,D) state
   space linear system matrices for sub-tree multibody system. The
   returned state space generation object's generate(x,u) can be called
   to compute the state space matrices at the state and input vector set
   point values about which the linearization should be carried out.

   The first two inputs are the size of the inputs and outputs for the
   state space system. The u_fn argument is a user-defined function that
   takes (x,u) arguments and sets the appropriate forces, gravity etc
   values for the in the multibody system for dynamics computations. The
   y_fn argument takes (x, u, y) arguments and computes the outputs y for
   the (x, u) and state and input values.


   See the :ref:`gnc_algorithms_sec` section for more information.

   :param mm: The ModelManager whose SubTree and models will be used to
              generate the StateSpace.
   :param n_inputs: number of inputs
   :param n_outputs: number of outputs
   :param u_fn: function to evaluate the state derivative value for an input
                value
   :param y_fn: function to evaluate the output value for a given state

   :returns: State space generator instance


.. py:class:: ModalAnalysis(w: Karana.Math.Ktyping.Vec | Karana.Math.Ktyping.AngularVelocity[Karana.Math.Ktyping.Vec], phi: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, n]], coord_data: Karana.Dynamics._SOADyn_pybind11_Py.CoordData, q_i: Annotated[numpy.typing.ArrayLike, numpy.float64, [m, 1]])

   .. py:attribute:: coord_data
      :type:  Karana.Dynamics._SOADyn_pybind11_Py.CoordData


   .. py:method:: showMode(mode: SupportsInt | SupportsIndex, scene: Karana.Scene.ProxyScene, amplitude: SupportsFloat | SupportsIndex = 1.0, steps: SupportsInt | SupportsIndex = 100, pause: SupportsFloat | SupportsIndex | numpy.timedelta64 = 0.01) -> None

      Show the mode shape using a sine wave.

      :param mode: The mode to show.
      :param scene: The ProxyScene to update when showing the mode
      :param amplitude: The amplitude of the sine wave.
      :param steps: The number of steps to take.
      :param pause: The time to sleep between steps.



   .. py:property:: phi
      :type: Annotated[numpy.typing.NDArray[numpy.float64], [m, n]]



   .. py:property:: q_i
      :type: Annotated[numpy.typing.NDArray[numpy.float64], [m, 1]]



   .. py:property:: w
      :type: Karana.Math.Ktyping.AngularVelocity[Karana.Math.Ktyping.Vec]



.. py:function:: modalAnalysis(mm: Karana.Dynamics._SOADyn_pybind11_Py.ModelManager, tol: SupportsFloat | SupportsIndex = 0.001, step_size: SupportsFloat | SupportsIndex | None = None) -> ModalAnalysis
                 modalAnalysis(body: Karana.Dynamics._SOAFlexDyn_pybind11_Py.PhysicalModalBody, tol: SupportsFloat | SupportsIndex = 0.001, step_size: SupportsFloat | SupportsIndex | None = None) -> ModalAnalysis
                 modalAnalysis(subtree: Karana.Dynamics._SOADyn_pybind11_Py.SubTree, tol: SupportsFloat | SupportsIndex = 0.001, step_size: SupportsFloat | SupportsIndex | None = None) -> ModalAnalysis

   Perform a modal analysis for the provided SubTree.

   This creates a state space model for the SubTree about the current
   configuration, and then solves an eigenproblem to its the frequencies
   and mode shapes.


   See the :ref:`gnc_algorithms_sec` section for more information.

   :param subtree: The SubTree to do the modal analysis for.
   :param tol: The tolerance used to eliminate rigid-body modes.
   :param step_size: The step size to use for finite differences when
                     performing the modal analysis.

   :returns: the eigen problem solution for the state space modal


