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

Error function that penalizes frame-to-frame changes in the relative transform between two joints. More...

#include <joint_to_joint_sequence_error_function.h>

Inheritance diagram for momentum::JointToJointSequenceErrorFunctionT< T >:

Public Member Functions

 JointToJointSequenceErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
 JointToJointSequenceErrorFunctionT (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 addConstraint (const JointToJointSequenceConstraintT< T > &constraint)
 Add a constraint using the struct.
void addConstraint (size_t sourceJoint, size_t referenceJoint, T weight=T(1), const std::string &name={})
 Add a constraint with individual parameters.
void clearConstraints ()
 Clear all constraints.
const std::vector< JointToJointSequenceConstraintT< T > > & getConstraints () const
 Get all constraints.
size_t getNumConstraints () const
 Returns the number of constraints.
void setPositionWeight (T w)
void setOrientationWeight (T w)
T getPositionWeight () const
T getOrientationWeight () 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::JointToJointSequenceErrorFunctionT< T >

Error function that penalizes frame-to-frame changes in the relative transform between two joints.

For each constraint with source joint A and reference joint B, computes the relative transform T_rel = T_B^{-1} * T_A at two consecutive frames. This expresses the source joint frame in the reference joint frame. It then penalizes changes in relative translation and relative rotation:

error = weight * ( positionWeight * ||T_rel_{i+1}.translation - T_rel_i.translation||^2

  • orientationWeight * ||R(T_rel_{i+1}) - R(T_rel_i)||_F^2)

The source/reference direction is intentionally fixed; reversing the pair expresses the residual in the other joint's frame and can produce a different translation error when the relative orientation or reference scale changes.

Template Parameters
TScalar type (float or double)

Definition at line 57 of file joint_to_joint_sequence_error_function.h.

Constructor & Destructor Documentation

◆ JointToJointSequenceErrorFunctionT() [1/2]

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

◆ JointToJointSequenceErrorFunctionT() [2/2]

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

Member Function Documentation

◆ addConstraint() [1/2]

template<typename T>
void momentum::JointToJointSequenceErrorFunctionT< T >::addConstraint ( const JointToJointSequenceConstraintT< T > & constraint)

◆ addConstraint() [2/2]

template<typename T>
void momentum::JointToJointSequenceErrorFunctionT< T >::addConstraint ( size_t sourceJoint,
size_t referenceJoint,
T weight = T(1),
const std::string & name = {} )

◆ clearConstraints()

template<typename T>
void momentum::JointToJointSequenceErrorFunctionT< T >::clearConstraints ( )

Clear all constraints.

Definition at line 359 of file joint_to_joint_sequence_error_function.cpp.

◆ getConstraints()

template<typename T>
const std::vector< JointToJointSequenceConstraintT< T > > & momentum::JointToJointSequenceErrorFunctionT< T >::getConstraints ( ) const
inlinenodiscard

Get all constraints.

Definition at line 101 of file joint_to_joint_sequence_error_function.h.

◆ getError()

template<typename T>
double momentum::JointToJointSequenceErrorFunctionT< T >::getError ( std::span< const ModelParametersT< T > > modelParameters,
std::span< const SkeletonStateT< T > > skelStates,
std::span< const MeshStateT< T > > meshStates ) const
finalvirtual

◆ getGradient()

◆ getJacobian()

template<typename T>
double momentum::JointToJointSequenceErrorFunctionT< T >::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
finalvirtual

◆ getJacobianSize()

template<typename T>
size_t momentum::JointToJointSequenceErrorFunctionT< T >::getJacobianSize ( ) const
nodiscardfinalvirtual

◆ getNumConstraints()

template<typename T>
size_t momentum::JointToJointSequenceErrorFunctionT< T >::getNumConstraints ( ) const
inlinenodiscard

Returns the number of constraints.

Definition at line 106 of file joint_to_joint_sequence_error_function.h.

◆ getOrientationWeight()

template<typename T>
T momentum::JointToJointSequenceErrorFunctionT< T >::getOrientationWeight ( ) const
inlinenodiscard

Definition at line 120 of file joint_to_joint_sequence_error_function.h.

◆ getPositionWeight()

template<typename T>
T momentum::JointToJointSequenceErrorFunctionT< T >::getPositionWeight ( ) const
inlinenodiscard

Definition at line 117 of file joint_to_joint_sequence_error_function.h.

◆ numFrames()

template<typename T>
size_t momentum::JointToJointSequenceErrorFunctionT< T >::numFrames ( ) const
inlinenodiscardfinalvirtual

◆ setOrientationWeight()

template<typename T>
void momentum::JointToJointSequenceErrorFunctionT< T >::setOrientationWeight ( T w)
inline

Definition at line 113 of file joint_to_joint_sequence_error_function.h.

◆ setPositionWeight()

template<typename T>
void momentum::JointToJointSequenceErrorFunctionT< T >::setPositionWeight ( T w)
inline

Definition at line 110 of file joint_to_joint_sequence_error_function.h.


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