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

Error function that penalizes the jerk (third derivative) of joint positions across four consecutive frames using a standard finite difference stencil [1, -3, 3, -1]. More...

#include <jerk_sequence_error_function.h>

Inheritance diagram for momentum::JerkSequenceErrorFunctionT< T >:

Public Member Functions

 JerkSequenceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
 JerkSequenceErrorFunctionT (const Character &character)
void setTargetWeights (const Eigen::VectorX< T > &weights)
 Set the per-joint weights for the jerk error.
void setTargetJerk (const Eigen::Vector3< T > &jerk)
 Set a single target jerk applied to all joints.
void setTargetJerks (const std::vector< Eigen::Vector3< T > > &jerks)
 Set per-joint target jerks.
void reset ()
 Reset weights to ones and target jerks to zero.
const Eigen::VectorX< T > & getTargetWeights () const
const std::vector< Eigen::Vector3< T > > & getTargetJerks () const
Public Member Functions inherited from momentum::FiniteDifferenceSequenceErrorFunctionT< T >
 FiniteDifferenceSequenceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt, const std::vector< T > &stencilCoefficients)
 FiniteDifferenceSequenceErrorFunctionT (const Character &character, const std::vector< T > &stencilCoefficients)
size_t numFrames () const final
double getError (std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates) const final
double getGradient (std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates, Eigen::Ref< Eigen::VectorX< T > > gradient) const final
double getJacobian (std::span< const ModelParametersT< T > > modelParameters, std::span< const SkeletonStateT< T > > skelStates, std::span< const MeshStateT< T > > meshStates, Eigen::Ref< Eigen::MatrixX< T > > jacobian, Eigen::Ref< Eigen::VectorX< T > > residual, int &usedRows) const final
size_t getJacobianSize () const final
void setTargetWeights (const Eigen::VectorX< T > &weights)
 Set the per-joint weights for the derivative error.
void setTargetValue (const Eigen::Vector3< T > &targetValue)
 Set a single target value applied to all joints.
void setTargetValues (const std::vector< Eigen::Vector3< T > > &targetValues)
 Set per-joint target values.
void reset ()
 Reset weights to ones and target values to zero.
const Eigen::VectorX< T > & getTargetWeights () const
const std::vector< Eigen::Vector3< T > > & getTargetValues () const
const std::vector< T > & getStencilCoefficients () const
Public Member Functions inherited from momentum::SequenceErrorFunctionT< T >
 SequenceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SequenceErrorFunctionT ()=default
void setWeight (T w)
float getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual bool needsMesh () const
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const

Additional Inherited Members

Protected Attributes inherited from momentum::SequenceErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_ = 1.0f
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_

Detailed Description

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

Error function that penalizes the jerk (third derivative) of joint positions across four consecutive frames using a standard finite difference stencil [1, -3, 3, -1].

The jerk residual for each joint is computed as: jerk = pos[t-1] - 3*pos[t] + 3*pos[t+1] - pos[t+2] - targetJerk

This is useful for enforcing smoothness in acceleration changes, which produces more natural-looking motion. By default, the target jerk is zero, which penalizes any non-zero jerk (smoothness constraint on acceleration).

Note: This error function only constrains position jerk, not rotation jerk, as rotation derivatives involve significantly more complex mathematics.

Definition at line 29 of file jerk_sequence_error_function.h.

Constructor & Destructor Documentation

◆ JerkSequenceErrorFunctionT() [1/2]

template<typename T>
momentum::JerkSequenceErrorFunctionT< T >::JerkSequenceErrorFunctionT ( const Skeleton & skel,
const ParameterTransform & pt )

◆ JerkSequenceErrorFunctionT() [2/2]

template<typename T>
momentum::JerkSequenceErrorFunctionT< T >::JerkSequenceErrorFunctionT ( const Character & character)
explicit

Member Function Documentation

◆ getTargetJerks()

template<typename T>
const std::vector< Eigen::Vector3< T > > & momentum::JerkSequenceErrorFunctionT< T >::getTargetJerks ( ) const
inlinenodiscard

Definition at line 61 of file jerk_sequence_error_function.h.

◆ getTargetWeights()

template<typename T>
const Eigen::VectorX< T > & momentum::JerkSequenceErrorFunctionT< T >::getTargetWeights ( ) const
inlinenodiscard

Definition at line 57 of file jerk_sequence_error_function.h.

◆ reset()

template<typename T>
void momentum::JerkSequenceErrorFunctionT< T >::reset ( )
inline

Reset weights to ones and target jerks to zero.

Definition at line 53 of file jerk_sequence_error_function.h.

◆ setTargetJerk()

template<typename T>
void momentum::JerkSequenceErrorFunctionT< T >::setTargetJerk ( const Eigen::Vector3< T > & jerk)
inline

Set a single target jerk applied to all joints.

Parameters
jerkThe target jerk vector.

Definition at line 42 of file jerk_sequence_error_function.h.

◆ setTargetJerks()

template<typename T>
void momentum::JerkSequenceErrorFunctionT< T >::setTargetJerks ( const std::vector< Eigen::Vector3< T > > & jerks)
inline

Set per-joint target jerks.

Parameters
jerksVector of target jerks, one per joint.

Definition at line 48 of file jerk_sequence_error_function.h.

◆ setTargetWeights()

template<typename T>
void momentum::JerkSequenceErrorFunctionT< T >::setTargetWeights ( const Eigen::VectorX< T > & weights)
inline

Set the per-joint weights for the jerk error.

Parameters
weightsPer-joint weights vector. Size must match the number of joints.

Definition at line 36 of file jerk_sequence_error_function.h.


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