|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Base class for error functions that penalize finite difference derivatives of joint positions across consecutive frames using a configurable stencil. More...
#include <finite_difference_sequence_error_function.h>
Public Member Functions | |
| 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_ |
Base class for error functions that penalize finite difference derivatives of joint positions across consecutive frames using a configurable stencil.
This class provides a generic framework for computing derivatives of arbitrary order using finite difference stencils. Derived classes specify the stencil coefficients to compute specific derivatives:
The residual for each joint is computed as: derivative = sum(stencilCoefficients[i] * pos[t+i]) - targetValue
Note: This error function only constrains position derivatives, not rotation derivatives, as rotation derivatives involve significantly more complex mathematics.
Definition at line 31 of file finite_difference_sequence_error_function.h.
| momentum::FiniteDifferenceSequenceErrorFunctionT< T >::FiniteDifferenceSequenceErrorFunctionT | ( | const Skeleton & | skel, |
| const ParameterTransform & | pt, | ||
| const std::vector< T > & | stencilCoefficients ) |
Definition at line 19 of file finite_difference_sequence_error_function.cpp.
References momentum::SkeletonT< T >::joints, MT_CHECK, and momentum::SequenceErrorFunctionT< T >::SequenceErrorFunctionT().
Referenced by momentum::AccelerationSequenceErrorFunctionT< T >::AccelerationSequenceErrorFunctionT(), momentum::AccelerationSequenceErrorFunctionT< T >::AccelerationSequenceErrorFunctionT(), FiniteDifferenceSequenceErrorFunctionT(), momentum::JerkSequenceErrorFunctionT< T >::JerkSequenceErrorFunctionT(), and momentum::JerkSequenceErrorFunctionT< T >::JerkSequenceErrorFunctionT().
|
explicit |
Definition at line 30 of file finite_difference_sequence_error_function.cpp.
References FiniteDifferenceSequenceErrorFunctionT().
|
nodiscardfinalvirtual |
Reimplemented from momentum::SequenceErrorFunctionT< T >.
Definition at line 64 of file finite_difference_sequence_error_function.cpp.
References MT_CHECK, MT_PROFILE_FUNCTION, momentum::SequenceErrorFunctionT< T >::skeleton_, and momentum::SequenceErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SequenceErrorFunctionT< T >.
Definition at line 95 of file finite_difference_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::activeJointParams_, momentum::gradient_jointParams_to_modelParams(), momentum::kInvalidIndex, momentum::kParametersPerJoint, MT_CHECK, MT_PROFILE_FUNCTION, momentum::SequenceErrorFunctionT< T >::parameterTransform_, momentum::SequenceErrorFunctionT< T >::skeleton_, and momentum::SequenceErrorFunctionT< T >::weight_.
|
finalvirtual |
Reimplemented from momentum::SequenceErrorFunctionT< T >.
Definition at line 194 of file finite_difference_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::activeJointParams_, momentum::jacobian_jointParams_to_modelParams(), momentum::kInvalidIndex, momentum::kParametersPerJoint, MT_CHECK, MT_PROFILE_FUNCTION, momentum::SequenceErrorFunctionT< T >::parameterTransform_, momentum::SequenceErrorFunctionT< T >::skeleton_, and momentum::SequenceErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SequenceErrorFunctionT< T >.
Definition at line 187 of file finite_difference_sequence_error_function.cpp.
|
inlinenodiscard |
Definition at line 91 of file finite_difference_sequence_error_function.h.
|
inlinenodiscard |
Definition at line 87 of file finite_difference_sequence_error_function.h.
Referenced by momentum::AccelerationSequenceErrorFunctionT< float >::getTargetAccelerations(), and momentum::JerkSequenceErrorFunctionT< float >::getTargetJerks().
|
inlinenodiscard |
Definition at line 83 of file finite_difference_sequence_error_function.h.
Referenced by momentum::AccelerationSequenceErrorFunctionT< float >::getTargetWeights(), and momentum::JerkSequenceErrorFunctionT< float >::getTargetWeights().
|
inlinenodiscardfinalvirtual |
Implements momentum::SequenceErrorFunctionT< T >.
Definition at line 41 of file finite_difference_sequence_error_function.h.
| void momentum::FiniteDifferenceSequenceErrorFunctionT< T >::reset | ( | ) |
Reset weights to ones and target values to zero.
Definition at line 39 of file finite_difference_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::skeleton_.
Referenced by momentum::AccelerationSequenceErrorFunctionT< float >::reset(), and momentum::JerkSequenceErrorFunctionT< float >::reset().
| void momentum::FiniteDifferenceSequenceErrorFunctionT< T >::setTargetValue | ( | const Eigen::Vector3< T > & | targetValue | ) |
Set a single target value applied to all joints.
This is a convenience method for uniform targets (e.g., gravity for acceleration).
| targetValue | The target derivative value (e.g., (0, -9.8, 0) * dt^2 for gravity acceleration). |
Definition at line 51 of file finite_difference_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::skeleton_.
Referenced by momentum::AccelerationSequenceErrorFunctionT< float >::setTargetAcceleration(), and momentum::JerkSequenceErrorFunctionT< float >::setTargetJerk().
| void momentum::FiniteDifferenceSequenceErrorFunctionT< T >::setTargetValues | ( | const std::vector< Eigen::Vector3< T > > & | targetValues | ) |
Set per-joint target values.
| targetValues | Vector of target derivative values, one per joint. |
Definition at line 57 of file finite_difference_sequence_error_function.cpp.
References MT_CHECK.
Referenced by momentum::AccelerationSequenceErrorFunctionT< float >::setTargetAccelerations(), and momentum::JerkSequenceErrorFunctionT< float >::setTargetJerks().
| void momentum::FiniteDifferenceSequenceErrorFunctionT< T >::setTargetWeights | ( | const Eigen::VectorX< T > & | weights | ) |
Set the per-joint weights for the derivative error.
| weights | Per-joint weights vector. Size must match the number of joints. |
Definition at line 45 of file finite_difference_sequence_error_function.cpp.
References MT_CHECK.
Referenced by momentum::AccelerationSequenceErrorFunctionT< float >::setTargetWeights(), and momentum::JerkSequenceErrorFunctionT< float >::setTargetWeights().