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

Error function that penalizes deviation from a target orientation expressed relative to a reference joint's coordinate frame. More...

#include <joint_to_joint_orientation_error_function.h>

Inheritance diagram for momentum::JointToJointOrientationErrorFunctionT< T >:

Public Member Functions

 JointToJointOrientationErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
 JointToJointOrientationErrorFunctionT (const Character &character)
double getError (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState) final
double getGradient (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< VectorX< T > > gradient) override
double getJacobian (const ModelParametersT< T > &params, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, Ref< MatrixX< T > > jacobian, Ref< VectorX< T > > residual, int &usedRows) override
size_t getJacobianSize () const final
void addConstraint (size_t sourceJoint, size_t referenceJoint, const Eigen::Quaternion< T > &target, T weight=T(1), const std::string &name={})
 Add a joint-to-joint orientation constraint.
void addConstraint (const JointToJointOrientationDataT< T > &constraint)
 Add a constraint using the JointToJointOrientationDataT struct.
void clearConstraints ()
 Clear all constraints.
const std::vector< JointToJointOrientationDataT< T > > & getConstraints () const
 Get all constraints.
size_t numConstraints () const
 Get number of constraints.
Public Member Functions inherited from momentum::SkeletonErrorFunctionT< T >
 SkeletonErrorFunctionT (const Skeleton &skel, const ParameterTransform &pt)
virtual ~SkeletonErrorFunctionT ()=default
const Skeleton & getSkeleton () const
const ParameterTransform & getParameterTransform () const
virtual const Character * getCharacter () const
 For mesh-based error functions, get access to the underlying character.
void setWeight (T w)
T getWeight () const
void setActiveJoints (const VectorX< bool > &aj)
void setEnabledParameters (const ParameterSet &ps)
virtual double getGradient (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::VectorX< T > >)
virtual double getJacobian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >, Eigen::Ref< Eigen::VectorX< T > >, int &usedRows)
virtual void getHessian (const ModelParametersT< T > &, const SkeletonStateT< T > &, const MeshStateT< T > &, Eigen::Ref< Eigen::MatrixX< T > >)
virtual double getSolverDerivatives (const ModelParametersT< T > &parameters, const SkeletonStateT< T > &state, const MeshStateT< T > &meshState, const size_t actualParameters, Eigen::MatrixX< T > &hess, Eigen::VectorX< T > &grad)
virtual bool needsMesh () const

Additional Inherited Members

Protected Attributes inherited from momentum::SkeletonErrorFunctionT< T >
const Skeleton & skeleton_
const ParameterTransform & parameterTransform_
T weight_
VectorX< bool > activeJointParams_
ParameterSet enabledParameters_
bool useHessian_ {false}

Detailed Description

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

Error function that penalizes deviation from a target orientation expressed relative to a reference joint's coordinate frame.

This is useful for constraints where you want to control the relative orientation between two body parts, such as keeping a hand at a specific orientation relative to the body, or maintaining a specific rotational relationship between two joints.

The error is computed as the Frobenius norm of the difference between the actual and target relative rotation matrices: error = ||R_ref^T * R_src - R_target||_F^2

where R_ref and R_src are the global rotations of the reference and source joints respectively, and R_target is the target relative rotation.

Definition at line 66 of file joint_to_joint_orientation_error_function.h.

Constructor & Destructor Documentation

◆ JointToJointOrientationErrorFunctionT() [1/2]

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

◆ JointToJointOrientationErrorFunctionT() [2/2]

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

Member Function Documentation

◆ addConstraint() [1/2]

◆ addConstraint() [2/2]

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

Add a joint-to-joint orientation constraint.

Parameters
[in]sourceJointIndex of the source joint.
[in]referenceJointIndex of the reference joint.
[in]targetTarget relative orientation (R_ref^T * R_src should match this).
[in]weightWeight for this constraint.
[in]nameName of the constraint (for debugging).

Definition at line 31 of file joint_to_joint_orientation_error_function.cpp.

References MT_CHECK, momentum::JointToJointOrientationDataT< T >::name, momentum::JointToJointOrientationDataT< T >::referenceJoint, momentum::SkeletonErrorFunctionT< T >::skeleton_, momentum::JointToJointOrientationDataT< T >::sourceJoint, momentum::JointToJointOrientationDataT< T >::target, and momentum::JointToJointOrientationDataT< T >::weight.

◆ clearConstraints()

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

Clear all constraints.

Definition at line 68 of file joint_to_joint_orientation_error_function.cpp.

◆ getConstraints()

template<typename T>
const std::vector< JointToJointOrientationDataT< T > > & momentum::JointToJointOrientationErrorFunctionT< T >::getConstraints ( ) const
inlinenodiscard

Get all constraints.

Definition at line 116 of file joint_to_joint_orientation_error_function.h.

◆ getError()

template<typename T>
double momentum::JointToJointOrientationErrorFunctionT< T >::getError ( const ModelParametersT< T > & params,
const SkeletonStateT< T > & state,
const MeshStateT< T > & meshState )
nodiscardfinalvirtual

◆ getGradient()

◆ getJacobian()

◆ getJacobianSize()

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

◆ numConstraints()

template<typename T>
size_t momentum::JointToJointOrientationErrorFunctionT< T >::numConstraints ( ) const
inlinenodiscard

Get number of constraints.

Definition at line 121 of file joint_to_joint_orientation_error_function.h.


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