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

Error function that constrains the minimum vertex height to a target value. More...

#include <floor_error_function.h>

Inheritance diagram for momentum::FloorErrorFunctionT< T >:

Public Member Functions

 FloorErrorFunctionT (const Character &character, std::vector< size_t > vertexIndices, T targetHeight=T(0), const Eigen::Vector3< T > &upDirection=Eigen::Vector3< T >::UnitY(), size_t k=5)
 Construct a floor error function.
 ~FloorErrorFunctionT () override
 FloorErrorFunctionT (const FloorErrorFunctionT &other)=delete
 FloorErrorFunctionT (FloorErrorFunctionT &&other) noexcept=delete
FloorErrorFunctionT & operator= (const FloorErrorFunctionT &other)=delete
FloorErrorFunctionT & operator= (FloorErrorFunctionT &&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 for the minimum vertices.
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.
void setVertexIndices (std::vector< size_t > indices)
 Set the candidate vertex indices.
const std::vector< size_t > & getVertexIndices () const
 Get the candidate vertex indices.
const Character * getCharacter () const override
 Get the character.
bool needsMesh () const override
 This function requires the solver to provide a posed mesh.
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::FloorErrorFunctionT< T >

Error function that constrains the minimum vertex height to a target value.

Given a set of candidate vertex indices (e.g. foot vertices), this error function finds the k lowest vertices along a specified "up" direction and penalizes the difference between their average projection and a target height. This is useful for ground contact constraints where feet should touch the floor (target_height = 0) while allowing individual feet to lift off the ground.

Unlike HeightErrorFunction, this function:

  • Uses the solver's posed mesh (needsMesh() = true), so it responds to all model parameters including pose
  • Only constrains the minimum projection (not the height = max - min)
  • Operates on a specified subset of vertices rather than all vertices

Definition at line 35 of file floor_error_function.h.

Constructor & Destructor Documentation

◆ FloorErrorFunctionT() [1/3]

template<typename T>
momentum::FloorErrorFunctionT< T >::FloorErrorFunctionT ( const Character & character,
std::vector< size_t > vertexIndices,
T targetHeight = T(0),
const Eigen::Vector3< T > & upDirection = Eigen::Vector3<T>::UnitY(),
size_t k = 5 )
explicit

Construct a floor error function.

Parameters
characterThe character (must have a mesh)
vertexIndicesIndices of candidate vertices to consider (e.g. foot vertices). The k lowest among these will be constrained.
targetHeightTarget height for the minimum vertices (default: 0)
upDirectionDirection to measure height along (default: Y-axis)
kNumber of lowest vertices to average (default: 5)

Definition at line 26 of file floor_error_function.cpp.

References momentum::Character::mesh, MT_CHECK, and momentum::SkeletonErrorFunctionT< T >::SkeletonErrorFunctionT().

◆ ~FloorErrorFunctionT()

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

◆ FloorErrorFunctionT() [2/3]

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

◆ FloorErrorFunctionT() [3/3]

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

Member Function Documentation

◆ getCharacter()

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

Get the character.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 106 of file floor_error_function.h.

◆ getError()

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

◆ getGradient()

template<typename T>
double momentum::FloorErrorFunctionT< 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::FloorErrorFunctionT< 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::FloorErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardfinalvirtual

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 187 of file floor_error_function.cpp.

◆ getTargetHeight()

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

Get the target height.

Definition at line 83 of file floor_error_function.h.

◆ getUpDirection()

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

Get the up direction.

Definition at line 93 of file floor_error_function.h.

◆ getVertexIndices()

template<typename T>
const std::vector< size_t > & momentum::FloorErrorFunctionT< T >::getVertexIndices ( ) const
inlinenodiscard

Get the candidate vertex indices.

Definition at line 101 of file floor_error_function.h.

◆ needsMesh()

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

This function requires the solver to provide a posed mesh.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 111 of file floor_error_function.h.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ setTargetHeight()

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

Set the target height for the minimum vertices.

Definition at line 47 of file floor_error_function.cpp.

◆ setUpDirection()

template<typename T>
void momentum::FloorErrorFunctionT< 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 52 of file floor_error_function.cpp.

◆ setVertexIndices()

template<typename T>
void momentum::FloorErrorFunctionT< T >::setVertexIndices ( std::vector< size_t > indices)

Set the candidate vertex indices.

Definition at line 57 of file floor_error_function.cpp.

References MT_CHECK.


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