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

Error function for character height constraints. More...

#include <height_error_function.h>

Inheritance diagram for momentum::HeightErrorFunctionT< T >:

Public Member Functions

 HeightErrorFunctionT (const Character &character, T targetHeight, const Eigen::Vector3< T > &upDirection=Eigen::Vector3< T >::UnitY(), size_t k=1)
 Construct a height error function.
 ~HeightErrorFunctionT () override
 HeightErrorFunctionT (const HeightErrorFunctionT &other)=delete
 HeightErrorFunctionT (HeightErrorFunctionT &&other) noexcept=delete
HeightErrorFunctionT & operator= (const HeightErrorFunctionT &other)=delete
HeightErrorFunctionT & operator= (HeightErrorFunctionT &&other)=delete
double getError (const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
double getGradient (const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) final
double getJacobian (const ModelParametersT< T > &modelParameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) final
size_t getJacobianSize () const final
void setTargetHeight (T height)
 Set the target height.
T getTargetHeight () const
 Get the target height.
void setUpDirection (const Eigen::Vector3< T > &upDirection)
 Set the up direction for height measurement.
const Eigen::Vector3< T > & getUpDirection () const
 Get the up direction.
const Character * getCharacter () const override
 Get the character.
bool needsMesh () const override
 Override to indicate this function does NOT require mesh state (we maintain our own meshes).
Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T >
 SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SkeletonErrorFunctionT ()=default
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const
void setWeight (T w)
T getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual void getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >)
virtual double getSolverDerivatives (const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad)

Additional Inherited Members

Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_
bool useHessian_ {false}

Detailed Description

template<typename T>
class momentum::HeightErrorFunctionT< T >

Error function for character height constraints.

This error function measures the height of a character mesh by projecting all vertices onto a specified "up" direction and computing the difference between the maximum and minimum projections.

IMPORTANT: Unlike most error functions, this one only depends on specific active parameters that are automatically determined in the constructor. Specifically, it uses blend shape, face expression, and scale parameters only (not pose parameters). The error function achieves this by zeroing out all inactive parameters before computing the skeleton and mesh state. This allows us to constrain height independent of pose, e.g. the solver doesn't try to fix height by having the character bend over.

Definition at line 36 of file height_error_function.h.

Constructor & Destructor Documentation

◆ HeightErrorFunctionT() [1/3]

template<typename T>
momentum::HeightErrorFunctionT< T >::HeightErrorFunctionT ( const Character & character,
T targetHeight,
const Eigen::Vector3< T > & upDirection = Eigen::Vector3<T>::UnitY(),
size_t k = 1 )
explicit

Construct a height error function.

Parameters
characterThe character to measure height for
targetHeightThe target height for the character (required)
upDirectionThe direction to measure height along (defaults to Y-axis)
kNumber of vertices to average for min/max height calculation (defaults to 1)

This error function automatically uses blend shape, face expression, and scale parameters only. All other parameters (pose, etc.) are kept inactive.

Definition at line 70 of file height_error_function.cpp.

References momentum::ParameterTransformT< T >::getBlendShapeParameters(), momentum::ParameterTransformT< T >::getFaceExpressionParameters(), momentum::ParameterTransformT< T >::getScalingParameters(), momentum::Character::mesh, MT_CHECK, momentum::Character::parameterTransform, and momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().

◆ ~HeightErrorFunctionT()

template<typename T>
momentum::HeightErrorFunctionT< T >::~HeightErrorFunctionT ( )
overridedefault

◆ HeightErrorFunctionT() [2/3]

template<typename T>
momentum::HeightErrorFunctionT< T >::HeightErrorFunctionT ( const HeightErrorFunctionT< T > & other)
delete

◆ HeightErrorFunctionT() [3/3]

template<typename T>
momentum::HeightErrorFunctionT< T >::HeightErrorFunctionT ( HeightErrorFunctionT< T > && other)
deletenoexcept

Member Function Documentation

◆ getCharacter()

template<typename T>
const Character * momentum::HeightErrorFunctionT< T >::getCharacter ( ) const
inlinenodiscardoverridevirtual

Get the character.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 98 of file height_error_function.h.

◆ getError()

template<typename T>
double momentum::HeightErrorFunctionT< T >::getError ( const ModelParametersT< T > & modelParameters,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState )
nodiscardfinalvirtual

◆ getGradient()

template<typename T>
double momentum::HeightErrorFunctionT< T >::getGradient ( const ModelParametersT< T > & modelParameters,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState,
Eigen::Ref< Eigen::VectorX< T > > gradient )
finalvirtual

◆ getJacobian()

template<typename T>
double momentum::HeightErrorFunctionT< T >::getJacobian ( const ModelParametersT< T > & modelParameters,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState,
Eigen::Ref< Eigen::MatrixX< T > > jacobian,
Eigen::Ref< Eigen::VectorX< T > > residual,
int & usedRows )
finalvirtual

◆ getJacobianSize()

template<typename T>
size_t momentum::HeightErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardfinalvirtual

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 319 of file height_error_function.cpp.

◆ getTargetHeight()

template<typename T>
T momentum::HeightErrorFunctionT< T >::getTargetHeight ( ) const
inlinenodiscard

Get the target height.

Definition at line 84 of file height_error_function.h.

◆ getUpDirection()

template<typename T>
const Eigen::Vector3< T > & momentum::HeightErrorFunctionT< T >::getUpDirection ( ) const
inlinenodiscard

Get the up direction.

Definition at line 93 of file height_error_function.h.

◆ needsMesh()

template<typename T>
bool momentum::HeightErrorFunctionT< T >::needsMesh ( ) const
inlinenodiscardoverridevirtual

Override to indicate this function does NOT require mesh state (we maintain our own meshes).

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 104 of file height_error_function.h.

◆ operator=() [1/2]

template<typename T>
HeightErrorFunctionT & momentum::HeightErrorFunctionT< T >::operator= ( const HeightErrorFunctionT< T > & other)
delete

◆ operator=() [2/2]

template<typename T>
HeightErrorFunctionT & momentum::HeightErrorFunctionT< T >::operator= ( HeightErrorFunctionT< T > && other)
delete

◆ setTargetHeight()

template<typename T>
void momentum::HeightErrorFunctionT< T >::setTargetHeight ( T height)

Set the target height.

Parameters
heightThe desired height

Definition at line 95 of file height_error_function.cpp.

◆ setUpDirection()

template<typename T>
void momentum::HeightErrorFunctionT< T >::setUpDirection ( const Eigen::Vector3< T > & upDirection)

Set the up direction for height measurement.

Parameters
upDirectionThe direction to measure height along (will be normalized)

Definition at line 100 of file height_error_function.cpp.


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