|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Error function that penalizes the deviation of per-joint velocity magnitude from a target speed. More...
#include <velocity_magnitude_sequence_error_function.h>
Public Member Functions | |
| VelocityMagnitudeSequenceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt) | |
| VelocityMagnitudeSequenceErrorFunctionT (const Character &character) | |
| 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 velocity magnitude error. | |
| void | setTargetSpeed (T speed) |
| Set a single target speed applied to all joints. | |
| void | setTargetSpeeds (const Eigen::VectorX< T > &speeds) |
| Set per-joint target speeds. | |
| void | reset () |
| Reset weights to ones and target speeds to zero. | |
| const Eigen::VectorX< T > & | getTargetWeights () const |
| const Eigen::VectorX< T > & | getTargetSpeeds () 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_ |
Error function that penalizes the deviation of per-joint velocity magnitude from a target speed.
Given two consecutive frames, this error function computes the velocity for each joint as: velocity = pos[t+1] - pos[t]
The velocity magnitude is computed using a smooth approximation to avoid discontinuities: ||v||_smooth = sqrt(||v||^2 + eps^2)
This provides a differentiable approximation to the velocity magnitude with well-defined gradients even when velocity is near zero. The gradient is: d(||v||_smooth)/d(v) = v / ||v||_smooth
The residual for each joint is the difference between the smooth velocity magnitude and a target speed: residual = ||v||_smooth - targetSpeed
This is useful for constraining character motion to maintain a specific speed profile, such as ensuring that joints move at a consistent pace during walking or running animations.
Note: This error function only constrains position velocity magnitude, not rotation velocity.
Definition at line 44 of file velocity_magnitude_sequence_error_function.h.
| momentum::VelocityMagnitudeSequenceErrorFunctionT< T >::VelocityMagnitudeSequenceErrorFunctionT | ( | const Skeleton & | skel, |
| const ParameterTransform & | pt ) |
Definition at line 19 of file velocity_magnitude_sequence_error_function.cpp.
References momentum::SkeletonT< T >::joints, and momentum::SequenceErrorFunctionT< T >::SequenceErrorFunctionT().
Referenced by VelocityMagnitudeSequenceErrorFunctionT().
|
explicit |
Definition at line 28 of file velocity_magnitude_sequence_error_function.cpp.
References VelocityMagnitudeSequenceErrorFunctionT().
|
nodiscardfinalvirtual |
Reimplemented from momentum::SequenceErrorFunctionT< T >.
Definition at line 58 of file velocity_magnitude_sequence_error_function.cpp.
References momentum::kVelocityMagnitudeEpsilon, MT_CHECK, MT_PROFILE_FUNCTION, momentum::SequenceErrorFunctionT< T >::skeleton_, and momentum::SequenceErrorFunctionT< T >::weight_.
|
nodiscardfinalvirtual |
Reimplemented from momentum::SequenceErrorFunctionT< T >.
Definition at line 96 of file velocity_magnitude_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::activeJointParams_, momentum::gradient_jointParams_to_modelParams(), momentum::kInvalidIndex, momentum::kParametersPerJoint, momentum::kVelocityMagnitudeEpsilon, 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 241 of file velocity_magnitude_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::activeJointParams_, momentum::SkeletonStateT< T >::jointState, momentum::kInvalidIndex, momentum::kParametersPerJoint, momentum::kVelocityMagnitudeEpsilon, 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 234 of file velocity_magnitude_sequence_error_function.cpp.
|
inlinenodiscard |
Definition at line 93 of file velocity_magnitude_sequence_error_function.h.
|
inlinenodiscard |
Definition at line 89 of file velocity_magnitude_sequence_error_function.h.
|
inlinenodiscardfinalvirtual |
Implements momentum::SequenceErrorFunctionT< T >.
Definition at line 49 of file velocity_magnitude_sequence_error_function.h.
| void momentum::VelocityMagnitudeSequenceErrorFunctionT< T >::reset | ( | ) |
Reset weights to ones and target speeds to zero.
Definition at line 34 of file velocity_magnitude_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::skeleton_.
| void momentum::VelocityMagnitudeSequenceErrorFunctionT< T >::setTargetSpeed | ( | T | speed | ) |
Set a single target speed applied to all joints.
| speed | The target speed (velocity magnitude) for all joints. |
Definition at line 47 of file velocity_magnitude_sequence_error_function.cpp.
References momentum::SequenceErrorFunctionT< T >::skeleton_.
| void momentum::VelocityMagnitudeSequenceErrorFunctionT< T >::setTargetSpeeds | ( | const Eigen::VectorX< T > & | speeds | ) |
Set per-joint target speeds.
| speeds | Vector of target speeds, one per joint. |
Definition at line 52 of file velocity_magnitude_sequence_error_function.cpp.
References MT_CHECK.
| void momentum::VelocityMagnitudeSequenceErrorFunctionT< T >::setTargetWeights | ( | const Eigen::VectorX< T > & | weights | ) |
Set the per-joint weights for the velocity magnitude error.
| weights | Per-joint weights vector. Size must match the number of joints. |
Definition at line 40 of file velocity_magnitude_sequence_error_function.cpp.
References MT_CHECK.