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

Error function that penalizes deviation of mesh vertex SDF distance from a target value. More...

#include <vertex_sdf_error_function.h>

Inheritance diagram for momentum::VertexSDFErrorFunctionT< T >:

Public Member Functions

 VertexSDFErrorFunctionT (const Character &character, const SDFColliderT< float > &sdfCollider)
 Constructor.
 ~VertexSDFErrorFunctionT () override=default
 Destructor.
void addConstraint (const VertexSDFConstraintT< T > &constraint)
 Add a constraint specifying a target distance for a vertex.
void clearConstraints ()
 Clear all constraints.
const std::vector< VertexSDFConstraintT< T > > & getConstraints () const
 Returns the current constraints.
size_t getNumConstraints () const
 Returns the number of constraints.
double getError (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) override
 Computes the error for the given model parameters and skeleton state.
double getGradient (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::VectorX< T > > gradient) override
 Computes the error and its gradient.
double getJacobian (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) override
 Computes the Jacobian and residual.
size_t getJacobianSize () const override
 Returns the maximum number of Jacobian rows needed.
bool needsMesh () const override
 Returns true because this error function requires mesh state.
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
virtual const Character * getCharacter () const
 For mesh-based error functions, get access to the underlying character.
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)

Static Public Attributes

static constexpr T kVertexSDFWeight = T(5e-3)
 Weight constant for vertex SDF penalties.

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::VertexSDFErrorFunctionT< T >

Error function that penalizes deviation of mesh vertex SDF distance from a target value.

Takes a single SDFCollider (with optional parent joint and offset transform) and allows adding constraints that specify target signed distance values for individual vertices. Error per constraint: weight * kVertexSDFWeight * (distance - targetDistance)^2

Definition at line 33 of file vertex_sdf_error_function.h.

Constructor & Destructor Documentation

◆ VertexSDFErrorFunctionT()

template<typename T>
momentum::VertexSDFErrorFunctionT< T >::VertexSDFErrorFunctionT ( const Character & character,
const SDFColliderT< float > & sdfCollider )
explicit

Constructor.

Parameters
characterThe character containing skeleton, mesh, and skin weights
sdfColliderThe SDF collider to test against (with optional parent joint and offset)

Definition at line 57 of file vertex_sdf_error_function.cpp.

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

◆ ~VertexSDFErrorFunctionT()

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

Destructor.

Member Function Documentation

◆ addConstraint()

template<typename T>
void momentum::VertexSDFErrorFunctionT< T >::addConstraint ( const VertexSDFConstraintT< T > & constraint)

Add a constraint specifying a target distance for a vertex.

Definition at line 70 of file vertex_sdf_error_function.cpp.

References MT_CHECK, and momentum::VertexSDFConstraintT< T >::vertexIndex.

◆ clearConstraints()

template<typename T>
void momentum::VertexSDFErrorFunctionT< T >::clearConstraints ( )

Clear all constraints.

Definition at line 81 of file vertex_sdf_error_function.cpp.

◆ getConstraints()

template<typename T>
const std::vector< VertexSDFConstraintT< T > > & momentum::VertexSDFErrorFunctionT< T >::getConstraints ( ) const
nodiscard

Returns the current constraints.

Definition at line 86 of file vertex_sdf_error_function.cpp.

◆ getError()

template<typename T>
double momentum::VertexSDFErrorFunctionT< T >::getError ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState )
nodiscardoverridevirtual

Computes the error for the given model parameters and skeleton state.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 240 of file vertex_sdf_error_function.cpp.

References kVertexSDFWeight, MT_CHECK_NOTNULL, MT_PROFILE_FUNCTION, momentum::MeshStateT< T >::posedMesh_, and momentum::SkeletonErrorFunctionT< T >::weight_.

◆ getGradient()

◆ getJacobian()

◆ getJacobianSize()

template<typename T>
size_t momentum::VertexSDFErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardoverridevirtual

Returns the maximum number of Jacobian rows needed.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 448 of file vertex_sdf_error_function.cpp.

◆ getNumConstraints()

template<typename T>
size_t momentum::VertexSDFErrorFunctionT< T >::getNumConstraints ( ) const
nodiscard

Returns the number of constraints.

Definition at line 91 of file vertex_sdf_error_function.cpp.

◆ needsMesh()

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

Returns true because this error function requires mesh state.

Reimplemented from momentum::SkeletonErrorFunctionT< T >.

Definition at line 87 of file vertex_sdf_error_function.h.

Member Data Documentation

◆ kVertexSDFWeight

template<typename T>
T momentum::VertexSDFErrorFunctionT< T >::kVertexSDFWeight = T(5e-3)
staticconstexpr

Weight constant for vertex SDF penalties.

Definition at line 36 of file vertex_sdf_error_function.h.

Referenced by getError(), getGradient(), and getJacobian().


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