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

The PlaneErrorFunction computes the point-on-plane error or point-in-half-plane error. More...

#include <plane_error_function.h>

Inheritance diagram for momentum::PlaneErrorFunctionT< T >:

Public Member Functions

 PlaneErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const bool above=false, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
 Constructor.
 PlaneErrorFunctionT (const Character &character, const bool above=false, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
 A convenience api where character contains info of the skeleton and parameter transform.
Public Member Functions inherited from momentum::JointErrorFunctionT< T, PlaneDataT< T >, 1 >
 JointErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const T &lossAlpha=GeneralizedLossT< T >::kL2, const T &lossC=T(1))
 Constructor.
double getError (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
 Computes the error function value l = w * loss(f^2).
double getGradient (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< VectorX< T > > gradient) final
 The gradient of the error function: dl/dq = dl/d[f^2] * 2f * df/dv * dv/dq.
double getJacobian (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< MatrixX< T > > jacobian, Ref< VectorX< T > > residual, int &usedRows) final
 For least-square problems, we assume l is the square of a vector function F.
size_t getJacobianSize () const final
 The number of rows in the jacobian is the dimension of f, FuncDim, times the number of constraints.
void addConstraint (const PlaneDataT< T > &constr)
 Adds a constraint to the list.
void addConstraints (std::span< const PlaneDataT< T > > constrs)
 Appends a list of constraints.
void setConstraints (std::span< const PlaneDataT< T > > constrs)
 Replace the current list of constraints with the input.
const std::vector< PlaneDataT< T > > & getConstraints () const
size_t getNumConstraints () const
void clearConstraints ()
 Clear the current list of constraints.
PlaneDataT< T > & getConstraint (size_t index)
 Mutable access to a constraint by index, for in-place updates.
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 double getGradient (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::VectorX< T > >)
virtual double getJacobian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >, Eigen::Ref< Eigen::VectorX< T > >, int &usedRows)
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)
virtual bool needsMesh () const

Static Public Attributes

static constexpr T kLegacyWeight = 1e-4
 Default constant weight in MarkerErrorFunction.
Static Public Attributes inherited from momentum::JointErrorFunctionT< T, PlaneDataT< T >, 1 >
static constexpr size_t kFuncDim
static constexpr size_t kNumVec
static constexpr size_t kNumPos

Protected Member Functions

void evalFunction (size_t constrIndex, const JointStateT< T > &state, Vector< T, 1 > &f, std::array< Vector3< T >, 1 > &v, std::array< Eigen::Matrix< T, 1, 3 >, 1 > &dfdv) const final
Protected Member Functions inherited from momentum::JointErrorFunctionT< T, PlaneDataT< T >, 1 >
virtual void evalFunction (size_t constrIndex, const JointStateT< T > &state, FuncType &f, std::array< VType, 1 > &v, std::array< DfdvType, 1 > &dfdv) const=0
 Evaluate the constraint residual and derivatives for a single constraint.

Additional Inherited Members

Public Types inherited from momentum::JointErrorFunctionT< T, PlaneDataT< T >, 1 >
using FuncType
using VType
using DfdvType
Protected Attributes inherited from momentum::JointErrorFunctionT< T, PlaneDataT< T >, 1 >
std::vector< PlaneDataT< T > > constraints_
 List of constraints.
const GeneralizedLossT< T > loss_
 The generalized loss function that transforms f^2.
VectorX< T > jointGrad_
 Intermediate storage of the gradient from this error function.
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::PlaneErrorFunctionT< T >

The PlaneErrorFunction computes the point-on-plane error or point-in-half-plane error.

For point-on-plane error (above = false), it computes the signed distance of a point to a plane using the plane equation. For half-plane error (above = true), the error is zero when the distance is greater than zero (ie. the point being above).

Definition at line 47 of file plane_error_function.h.

Constructor & Destructor Documentation

◆ PlaneErrorFunctionT() [1/2]

template<typename T>
momentum::PlaneErrorFunctionT< T >::PlaneErrorFunctionT ( const Skeleton & skel,
const ParameterTransform & pt,
const bool above = false,
const T & lossAlpha = GeneralizedLossT<T>::kL2,
const T & lossC = T(1) )
inlineexplicit

Constructor.

Parameters
[in]skelcharacter skeleton
[in]ptcharacter parameter transformation
[in]abovetrue means "above the plane" (half plane inequality), false means "on the plane" (equality).
[in]lossAlphaalpha parameter for the loss function
[in]lossCc parameter for the loss function

Definition at line 57 of file plane_error_function.h.

◆ PlaneErrorFunctionT() [2/2]

template<typename T>
momentum::PlaneErrorFunctionT< T >::PlaneErrorFunctionT ( const Character & character,
const bool above = false,
const T & lossAlpha = GeneralizedLossT<T>::kL2,
const T & lossC = T(1) )
inlineexplicit

A convenience api where character contains info of the skeleton and parameter transform.

Parameters
[in]charactercharacter definition
[in]abovetrue means "above the plane" (half plane inequality), false means "on the plane" (equality).
[in]lossAlphaalpha parameter for the loss function
[in]lossCc parameter for the loss function

Definition at line 72 of file plane_error_function.h.

Member Function Documentation

◆ evalFunction()

template<typename T>
void momentum::PlaneErrorFunctionT< T >::evalFunction ( size_t constrIndex,
const JointStateT< T > & state,
Vector< T, 1 > & f,
std::array< Vector3< T >, 1 > & v,
std::array< Eigen::Matrix< T, 1, 3 >, 1 > & dfdv ) const
finalprotected

Member Data Documentation

◆ kLegacyWeight

template<typename T>
T momentum::PlaneErrorFunctionT< T >::kLegacyWeight = 1e-4
staticconstexpr

Default constant weight in MarkerErrorFunction.

This can be used for backwards compatibility in setWeight().

Definition at line 86 of file plane_error_function.h.


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