Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
momentum::ParameterTransformT< T > Struct Template Reference

A parameter transform is an abstraction of the joint parameters that maps a model_parameter vector to a joint_parameter vector. More...

#include <parameter_transform.h>

Public Member Functions

VectorX< bool > computeActiveJointParams (const ParameterSet &ps=allParams()) const
 Compute activeJointParams based on the transform and the input ParameterSet.
size_t getParameterIdByName (const std::string &nm) const
 Return the index of a model parameter from its name.
JointParametersT< T > apply (const ModelParametersT< T > &parameters) const
 Map model parameters to joint parameters using a linear transformation.
JointParametersT< T > apply (const CharacterParametersT< T > &parameters) const
 Map model parameters to joint parameters using a linear transformation.
JointParametersT< T > zero () const
 Return rest pose joint parameters.
JointParametersT< T > bindPose () const
 Return bind pose joint parameters (same as the rest pose here).
ParameterSet getScalingParameters () const
 Get a list of scaling parameters (with prefix "scale_").
ParameterSet getRigidParameters () const
 Get a list of root parameters (with prefix "root_").
ParameterSet getPoseParameters () const
 Return all parameters used for posing the body (excludes scaling parameters, blend shape parameters, or any parameters used for physics).
ParameterSet getBlendShapeParameters () const
 Get a list of blend shape parameters.
ParameterSet getFaceExpressionParameters () const
 Get a list of face expression parameters.
ParameterSet getSkinnedLocatorParameters () const
 Get a list of skinned locator parameters.
ParameterSet getParameterSet (const std::string &parameterSetName, bool allowMissing=false) const
 Get a parameter set, if allowMissing is set then it will return an empty parameter set if no such parameterset is found in the file.
template<typename T2>
ParameterTransformT< T2 > cast () const
ParameterTransformT< T > simplify (const ParameterSet &enabledParameters) const
 Create a simplified transform given the enabled parameters.
Eigen::Index numAllModelParameters () const
 Dimension of all model parameters, including pose, scaling, marker joints, and blendshape parameters for id and expressions.
Eigen::Index numJointParameters () const
 Dimension of the output jointParameters vector.
Eigen::Index numBlendShapeParameters () const
 Dimension of identity blendshape parameters.
Eigen::Index numFaceExpressionParameters () const
 Dimension of facial expression parameters.
Eigen::Index numSkinnedLocatorParameters () const
 Dimension of skinned locator parameters (3 per skinned locator: x, y, z).
Eigen::Index numSkeletonParameters () const
 Dimension of skeletal model parameters, including pose parameters, scaling parameters, locator joint parameters etc.
bool isApprox (const ParameterTransformT< T > &parameterTransform) const

Static Public Member Functions

static ParameterTransformT< T > empty (size_t nJointParameters)
 Return a ParameterTransform object with no model parameters.
static ParameterTransformT< T > identity (momentum::span< const std::string > jointNames)
 Return a ParameterTransform object where the model parameters are identical to the joint parameters.

Public Attributes

std::vector< std::string > name
 The list of model parameter names.
SparseRowMatrix< T > transform
 The sparse mapping matrix that maps model parameters to joint parameters.
Eigen::VectorX< T > offsets
VectorX< bool > activeJointParams
 The list of joint parameters that are actually active and influenced from the transform.
ParameterSets parameterSets
 Convenience grouping of model parameters.
PoseConstraints poseConstraints
 A set of predefined poses.
VectorXi blendShapeParameters
 The indices of the parameters that influence blend shapes; blendShapeParameters(0) is the parameter that controls the 0th blend shape, etc.
VectorXi faceExpressionParameters
 The indices of the parameters that influence face expressions; faceExpressionParameters(0) is the parameter that controls the 0th face expression parameter, etc.
VectorXi skinnedLocatorParameters
 Parameters that control the rest-space positions of the skinned locators.

Detailed Description

template<typename T>
struct momentum::ParameterTransformT< T >

A parameter transform is an abstraction of the joint parameters that maps a model_parameter vector to a joint_parameter vector.

It allows mapping a single model_parameter to multiple joints, and a single joint being influenced by multiple model_parameters. Joint parameters are calculated from model parameters in the following way: <joint_parameters> = <transform> * <model_parameters> + <offsets>

Parameter enablement hierarchy

Momentum has three levels of parameter enablement that interact:

  1. Model parameters (ParameterSet): A bitset over the ~200 model parameters. The solver's setEnabledParameters() operates at this level. A model parameter being disabled means it won't be optimized.
  2. Joint parameters (activeJointParams): A boolean vector over all numJoints * 7 joint parameters. Computed from the transform sparse matrix — if any model parameter drives joint J's RX column, then activeJointParams[J*7+3] is true. Error functions check this to skip zero Jacobian columns. Recomputed via computeActiveJointParams(enabledModelParams).
  3. Solver active set (SolverT::activeParameters_): The solver's internal copy of the enabled model parameters. Passed to SolverFunctionT which forwards to error functions.

When adding a new error function, you typically check activeJointParams_ (level 2) to determine which joint parameter columns to compute Jacobians for. You do NOT need to check model-level enablement — the solver handles that mapping.

Definition at line 62 of file parameter_transform.h.

Member Function Documentation

◆ apply() [1/2]

template<typename T>
JointParametersT< T > momentum::ParameterTransformT< T >::apply ( const CharacterParametersT< T > & parameters) const
nodiscard

◆ apply() [2/2]

◆ bindPose()

◆ cast()

template<typename T>
template<typename T2>
template ParameterTransformT< double > momentum::ParameterTransformT< T >::cast ( ) const
nodiscard

◆ computeActiveJointParams()

template<typename T>
VectorX< bool > momentum::ParameterTransformT< T >::computeActiveJointParams ( const ParameterSet & ps = allParams()) const
nodiscard

Compute activeJointParams based on the transform and the input ParameterSet.

Definition at line 97 of file parameter_transform.cpp.

References transform.

Referenced by momentum::addRigidTransformNode(), momentum::removeJoints(), and momentum::replaceSkeletonHierarchy().

◆ empty()

template<typename T>
ParameterTransformT< T > momentum::ParameterTransformT< T >::empty ( size_t nJointParameters)
staticnodiscard

Return a ParameterTransform object with no model parameters.

The model can still perform FK with JointParameters, but it does not have any degrees of freedom for IK.

Definition at line 67 of file parameter_transform.cpp.

References activeJointParams, name, offsets, and transform.

◆ getBlendShapeParameters()

◆ getFaceExpressionParameters()

template<typename T>
ParameterSet momentum::ParameterTransformT< T >::getFaceExpressionParameters ( ) const
nodiscard

◆ getParameterIdByName()

template<typename T>
size_t momentum::ParameterTransformT< T >::getParameterIdByName ( const std::string & nm) const
nodiscard

◆ getParameterSet()

template<typename T>
ParameterSet momentum::ParameterTransformT< T >::getParameterSet ( const std::string & parameterSetName,
bool allowMissing = false ) const
nodiscard

Get a parameter set, if allowMissing is set then it will return an empty parameter set if no such parameterset is found in the file.

Definition at line 55 of file parameter_transform.cpp.

References MT_THROW_IF, and parameterSets.

Referenced by momentum::calibrateModel(), and momentum::trackSequence().

◆ getPoseParameters()

template<typename T>
ParameterSet momentum::ParameterTransformT< T >::getPoseParameters ( ) const
nodiscard

Return all parameters used for posing the body (excludes scaling parameters, blend shape parameters, or any parameters used for physics).

Definition at line 217 of file parameter_transform.cpp.

References getBlendShapeParameters(), getFaceExpressionParameters(), getScalingParameters(), and getSkinnedLocatorParameters().

Referenced by momentum::calibrateLocators(), momentum::calibrateModel(), momentum::trackPosesForFrames(), and momentum::trackSequence().

◆ getRigidParameters()

template<typename T>
ParameterSet momentum::ParameterTransformT< T >::getRigidParameters ( ) const
nodiscard

Get a list of root parameters (with prefix "root_").

Definition at line 173 of file parameter_transform.cpp.

References name.

Referenced by momentum::solveRigidInitialization(), and momentum::trackPosesForFrames().

◆ getScalingParameters()

◆ getSkinnedLocatorParameters()

template<typename T>
ParameterSet momentum::ParameterTransformT< T >::getSkinnedLocatorParameters ( ) const
nodiscard

Get a list of skinned locator parameters.

Definition at line 513 of file parameter_transform.cpp.

References skinnedLocatorParameters.

Referenced by momentum::addSkinnedLocatorParameters(), and getPoseParameters().

◆ identity()

template<typename T>
ParameterTransformT< T > momentum::ParameterTransformT< T >::identity ( momentum::span< const std::string > jointNames)
staticnodiscard

Return a ParameterTransform object where the model parameters are identical to the joint parameters.

Definition at line 77 of file parameter_transform.cpp.

References activeJointParams, momentum::kJointParameterNames, momentum::kParametersPerJoint, name, offsets, and transform.

◆ isApprox()

template<typename T>
bool momentum::ParameterTransformT< T >::isApprox ( const ParameterTransformT< T > & parameterTransform) const
nodiscard

◆ numAllModelParameters()

template<typename T>
Eigen::Index momentum::ParameterTransformT< T >::numAllModelParameters ( ) const
inlinenodiscard

◆ numBlendShapeParameters()

template<typename T>
Eigen::Index momentum::ParameterTransformT< T >::numBlendShapeParameters ( ) const
nodiscard

Dimension of identity blendshape parameters.

Definition at line 201 of file parameter_transform.cpp.

References blendShapeParameters.

Referenced by momentum::ParameterTransformT< float >::numSkeletonParameters().

◆ numFaceExpressionParameters()

template<typename T>
Eigen::Index momentum::ParameterTransformT< T >::numFaceExpressionParameters ( ) const
nodiscard

Dimension of facial expression parameters.

Definition at line 206 of file parameter_transform.cpp.

References faceExpressionParameters.

Referenced by momentum::ParameterTransformT< float >::numSkeletonParameters().

◆ numJointParameters()

template<typename T>
Eigen::Index momentum::ParameterTransformT< T >::numJointParameters ( ) const
inlinenodiscard

◆ numSkeletonParameters()

template<typename T>
Eigen::Index momentum::ParameterTransformT< T >::numSkeletonParameters ( ) const
inlinenodiscard

Dimension of skeletal model parameters, including pose parameters, scaling parameters, locator joint parameters etc.

basically everything but blendshapes (ids and expressions).

Definition at line 178 of file parameter_transform.h.

◆ numSkinnedLocatorParameters()

template<typename T>
Eigen::Index momentum::ParameterTransformT< T >::numSkinnedLocatorParameters ( ) const
nodiscard

Dimension of skinned locator parameters (3 per skinned locator: x, y, z).

Definition at line 211 of file parameter_transform.cpp.

References skinnedLocatorParameters.

Referenced by momentum::ParameterTransformT< float >::numSkeletonParameters().

◆ simplify()

template<typename T>
ParameterTransformT< T > momentum::ParameterTransformT< T >::simplify ( const ParameterSet & enabledParameters) const
nodiscard

Create a simplified transform given the enabled parameters.

Definition at line 223 of file parameter_transform.cpp.

References momentum::subsetParameterTransform().

Referenced by momentum::applyModelParameterScales(), and momentum::jointIdentityToModelIdentity().

◆ zero()

template<typename T>
JointParametersT< T > momentum::ParameterTransformT< T >::zero ( ) const
nodiscard

Return rest pose joint parameters.

Definition at line 146 of file parameter_transform.cpp.

References MT_CHECK, offsets, and transform.

Referenced by momentum::PlaneCollisionQueryT< T >::PlaneCollisionQueryT().

Member Data Documentation

◆ activeJointParams

◆ blendShapeParameters

◆ faceExpressionParameters

◆ name

◆ offsets

◆ parameterSets

◆ poseConstraints

◆ skinnedLocatorParameters

template<typename T>
VectorXi momentum::ParameterTransformT< T >::skinnedLocatorParameters

Parameters that control the rest-space positions of the skinned locators.

This array will be either empty or have the same size as the number of skinned locators. Each entry maps from a skinned locator index to the first of the three (x,y,z) parameters that control its position. Skinned locators that aren't controlled by the paramete transform will have skinnedLocatorParameters[i] = -1.

Definition at line 95 of file parameter_transform.h.

Referenced by momentum::addSkinnedLocatorParameters(), cast(), getSkinnedLocatorParameters(), isApprox(), momentum::mapParameterTransformJoints(), numSkinnedLocatorParameters(), and momentum::subsetParameterTransform().

◆ transform


The documentation for this struct was generated from the following files: