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

Error function that penalizes the acceleration of joint positions across three consecutive frames using a standard finite difference stencil [1, -2, 1]. More...

#include <acceleration_sequence_error_function.h>

Inheritance diagram for momentum::AccelerationSequenceErrorFunctionT< T >:

Public Member Functions

 AccelerationSequenceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
 AccelerationSequenceErrorFunctionT (const Character &character)
void setTargetWeights (const Eigen::VectorX< T > &weights)
 Set the per-joint weights for the acceleration error.
void setTargetAcceleration (const Eigen::Vector3< T > &acceleration)
 Set a single target acceleration applied to all joints.
void setTargetAccelerations (const std::vector< Eigen::Vector3< T > > &accelerations)
 Set per-joint target accelerations.
void reset ()
 Reset weights to ones and target accelerations to zero.
const Eigen::VectorX< T > & getTargetWeights () const
const std::vector< Eigen::Vector3< T > > & getTargetAccelerations () 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::AccelerationSequenceErrorFunctionT< T >

Error function that penalizes the acceleration of joint positions across three consecutive frames using a standard finite difference stencil [1, -2, 1].

The acceleration residual for each joint is computed as: accel = pos[t-1] - 2*pos[t] + pos[t+1] - targetAcceleration

This is useful for ballistic motion constraints where joints should follow a specific acceleration (e.g., gravity). By default, the target acceleration is zero, which penalizes any non-zero acceleration (smoothness constraint on velocity).

Note: This error function only constrains position acceleration, not rotation acceleration, as rotation acceleration involves significantly more complex mathematics.

Definition at line 29 of file acceleration_sequence_error_function.h.

Constructor & Destructor Documentation

◆ AccelerationSequenceErrorFunctionT() [1/2]

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

◆ AccelerationSequenceErrorFunctionT() [2/2]

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

Member Function Documentation

◆ getTargetAccelerations()

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

Definition at line 62 of file acceleration_sequence_error_function.h.

◆ getTargetWeights()

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

Definition at line 58 of file acceleration_sequence_error_function.h.

◆ reset()

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

Reset weights to ones and target accelerations to zero.

Definition at line 54 of file acceleration_sequence_error_function.h.

◆ setTargetAcceleration()

template<typename T>
void momentum::AccelerationSequenceErrorFunctionT< T >::setTargetAcceleration ( const Eigen::Vector3< T > & acceleration)
inline

Set a single target acceleration applied to all joints.

This is a convenience method for uniform acceleration like gravity.

Parameters
accelerationThe target acceleration vector (e.g., (0, -9.8, 0) * dt^2 for gravity).

Definition at line 43 of file acceleration_sequence_error_function.h.

◆ setTargetAccelerations()

template<typename T>
void momentum::AccelerationSequenceErrorFunctionT< T >::setTargetAccelerations ( const std::vector< Eigen::Vector3< T > > & accelerations)
inline

Set per-joint target accelerations.

Parameters
accelerationsVector of target accelerations, one per joint.

Definition at line 49 of file acceleration_sequence_error_function.h.

◆ setTargetWeights()

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

Set the per-joint weights for the acceleration error.

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

Definition at line 36 of file acceleration_sequence_error_function.h.


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